Revert "Autocomplete from GIS list of CRSs.."

This reverts commit dce53630f7.
This commit is contained in:
Carl van Tonder 2018-04-04 18:02:33 -04:00
parent 0954be4a80
commit 490e6706d9
9 changed files with 17 additions and 101 deletions

View File

@ -1,21 +1,7 @@
from django.contrib import admin
from django import forms
from dal import autocomplete
from leaflet.admin import LeafletGeoAdmin
from .models import CaseStudy, SpatialRefSys
class CaseStudyAdminForm(forms.ModelForm):
class Meta:
model = CaseStudy
widgets = {
'coordinate_reference_system': autocomplete.ModelSelect2(
url='srs-autocomplete'
)
}
fields = '__all__'
from .models import CaseStudy
class CaseStudyAdmin(LeafletGeoAdmin):
@ -44,8 +30,4 @@ class CaseStudyAdmin(LeafletGeoAdmin):
))
unapprove.short_description = "Un-approve selected case studies"
form = CaseStudyAdminForm
admin.site.register(CaseStudy, CaseStudyAdmin)
admin.site.register(SpatialRefSys)

View File

@ -2,11 +2,9 @@ from django.urls import reverse
from django import forms
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit, Layout, HTML, Fieldset, Div
from crispy_forms.bootstrap import Tab, TabHolder, PrependedText, FormActions
from dal import autocomplete
from leaflet.forms.widgets import LeafletWidget
from .models import CaseStudy
@ -70,7 +68,6 @@ class ShortCaseStudyForm(BaseCaseStudyForm):
'community_voices'
]
class LongCaseStudyForm(BaseCaseStudyForm):
"""Long version of the CaseStudy form."""
@ -120,9 +117,6 @@ class LongCaseStudyForm(BaseCaseStudyForm):
choices=POSITIVE_CASE_TYPE_CHOICES
)
self.fields['project_owners'].required = True
self.fields['shareholders'].required = True
self.helper.form_action = reverse('long-form')
self.helper.layout = Layout(
TabHolder(
@ -275,8 +269,3 @@ class LongCaseStudyForm(BaseCaseStudyForm):
class Meta(BaseCaseStudyForm.Meta):
exclude = ('approved',)
widgets = {
'coordinate_reference_system': autocomplete.ModelSelect2(
url='srs-autocomplete'
)
}

View File

@ -1,21 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2018-04-04 00:24
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('map', '0050_auto_20180402_1237'),
]
operations = [
migrations.AlterField(
model_name='casestudy',
name='coordinate_reference_system',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='gis.PostGISSpatialRefSys'),
),
]

View File

@ -1,32 +1,17 @@
import datetime
from urllib import parse
from django.contrib.gis.db import models
from django.contrib.auth.models import User
from django.db import connection
from django.utils.translation import ugettext as _
from django.template.defaultfilters import slugify
from django_extensions.db.fields import AutoSlugField
from django_countries.fields import CountryField
from django.utils.translation import ugettext as _
from django.template.defaultfilters import slugify
from multiselectfield import MultiSelectField
from phonenumber_field.modelfields import PhoneNumberField
from . import validators
class SpatialRefSys(connection.ops.spatial_ref_sys()):
def __str__(self):
return self.__unicode__()
def __unicode__(self):
return '{0.auth_name}:{0.auth_srid} {0.name}'.format(self)
class Meta:
proxy = True
verbose_name = "spatial reference system"
class Shapefile(models.Model):
file = models.FileField(
upload_to='shapefiles/',
@ -1022,9 +1007,13 @@ class CaseStudy(models.Model):
)
# 4.3.2
coordinate_reference_system = models.ForeignKey(
SpatialRefSys, null=True, blank=True,
default=4326
coordinate_reference_system = models.CharField(
verbose_name=_("Coordinate reference system"),
help_text=_("Enter the coordinate reference system of the shapefiles."),
max_length=12,
default=None,
null=True,
blank=True
)
# 4.3.3

View File

@ -1,5 +1,8 @@
{% extends "base_page.html" %}
{% load compress crispy_forms_tags i18n leaflet_tags static %}
{% load compress %}
{% load crispy_forms_tags %}
{% load i18n %}
{% load leaflet_tags %}
{% block stylesheets %}
@ -17,8 +20,6 @@
{% endblock %}
{% block scripts %}
<script type="text/javascript" src="{% static 'admin/js/vendor/jquery/jquery.js' %}"></script>
{{ form.media }}
{% leaflet_js %}
<script type="text/javascript">
YourGeometryField = L.GeometryField.extend({

View File

@ -8,15 +8,11 @@ from . import views
urlpatterns = [
url(r'^$', RedirectView.as_view(url=reverse_lazy('map')), name='index'),
url(r'^data.geojson$', GeoJSONLayerView.as_view(model=CaseStudy, geometry_field='location'), name='data'),
url(r'^case-study/create/?$', views.Create.as_view(), name="create"),
url(r'^case-study/create/short/?$', views.ShortForm.as_view(), name='short-form'),
url(r'^case-study/create/long/?$', views.LongForm.as_view(), name='long-form'),
url(r'^case-study/create/success/?$', views.FormSuccess.as_view(), name='form-success'),
url(r'^case-study/(?P<slug>[-\w]+)/?$', views.CaseStudyDetail.as_view(), name='detail'),
url(r'^map/?$', views.Map.as_view(), name='map'),
# API
url(r'^data.geojson$', GeoJSONLayerView.as_view(model=CaseStudy, geometry_field='location'), name='data'),
url(r'^srs-autocomplete/$', views.SpatialRefSysAutocomplete.as_view(), name='srs-autocomplete'),
url(r'^map/?$', views.Map.as_view(), name='map')
]

View File

@ -1,15 +1,11 @@
from django.core.mail import send_mail
from django.conf import settings
from django.db.models import Q
from django.views.generic import DetailView
from django.views.generic.base import TemplateView
from django.views.generic.edit import CreateView
from django.contrib.auth.mixins import LoginRequiredMixin
from django.urls import reverse
from dal import autocomplete
from .models import CaseStudy, SpatialRefSys
from .models import CaseStudy
from .forms import ShortCaseStudyForm, LongCaseStudyForm
NOTIFY_MESSAGE = """
@ -76,16 +72,3 @@ class CaseStudyDetail(DetailView):
template_name = "map/detail.html"
model = CaseStudy
context_object_name = "case_study"
class SpatialRefSysAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self):
qs = SpatialRefSys.objects.all()
if self.q:
qs = qs.filter(
Q(auth_name__icontains=self.q)
| Q(auth_srid__icontains=self.q)
)
return qs

View File

@ -47,8 +47,6 @@ INSTALLED_APPS = [
'cas_server',
'compressor',
'crispy_forms',
'dal',
'dal_select2',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',

View File

@ -5,7 +5,6 @@ boto3==1.4.7
Django==1.11.6
django-appconf==1.0.2
django-anymail==2.0
django-autocomplete-light==3.2.10
django-avatar==4.0.1
django-bootstrap3==8.2.3
django-braces==1.11.0