Compare commits

...

10 Commits

116 changed files with 323 additions and 332 deletions

15
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,15 @@
repos:
- repo: https://github.com/ambv/black
rev: 18.9b0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
hooks:
- id: flake8
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.3.5
hooks:
- id: reorder-python-imports

View File

@ -1,9 +1,11 @@
from django.contrib.auth.models import User from django.contrib.auth.models import User
from rest_framework import serializers, viewsets from rest_framework import serializers
from rest_framework import viewsets
from rest_framework_gis import serializers as gis_serializers from rest_framework_gis import serializers as gis_serializers
from apps.files.models import File from apps.files.models import File
from apps.map.models import CaseStudy, PointOfInterest from apps.map.models import CaseStudy
from apps.map.models import PointOfInterest
class UserSerializer(serializers.HyperlinkedModelSerializer): class UserSerializer(serializers.HyperlinkedModelSerializer):

View File

@ -1,10 +0,0 @@
from envelope.forms import ContactForm
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
class ContactForm(ContactForm):
def __init__(self, *args, **kwargs):
super(ContactForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.add_input(Submit("submit", "Submit", css_class="btn-lg pull-right"))

View File

@ -1,21 +0,0 @@
{% extends "base_page.html" %}
{% load bootstrap3 %}
{% load crispy_forms_tags %}
{% load envelope_tags %}
{% block page_name %}Contact{% endblock %}
{% block content %}
<div class="container">
<div class="page-lead">
<h2>Contact</h2>
<p class="lead">Send us your thoughts and feedback.</p>
</div>
{% bootstrap_messages %}
<form action="{% url 'contact' %}" method="post">
{% csrf_token %}
{% antispam_fields %}
{% crispy form %}
</form>
</div>
{% endblock %}

View File

@ -1,3 +0,0 @@
# from django.test import TestCase
# Create your tests here.

View File

@ -1,5 +0,0 @@
from django.conf.urls import url
from . import views
urlpatterns = [url(r"^$", views.ContactView.as_view(), name="contact")]

View File

@ -1,12 +0,0 @@
from braces.views import FormMessagesMixin
from envelope.views import ContactView
from django.utils.translation import ugettext_lazy as _
from .forms import ContactForm
class ContactView(FormMessagesMixin, ContactView):
form_invalid_message = _(u"There was an error in the contact form.")
form_valid_message = _(u"Thanks for your message.")
form_class = ContactForm

View File

@ -1,6 +1,7 @@
from django import forms from django import forms
from .models import File, ImageFile from .models import File
from .models import ImageFile
class FileForm(forms.ModelForm): class FileForm(forms.ModelForm):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-04-23 02:20 # Generated by Django 1.11.6 on 2018-04-23 02:20
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,9 +2,10 @@
# Generated by Django 1.11.6 on 2018-04-29 22:07 # Generated by Django 1.11.6 on 2018-04-29 22:07
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
from django.conf import settings
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,9 +2,10 @@
# Generated by Django 1.11.6 on 2018-05-26 15:47 # Generated by Django 1.11.6 on 2018-05-26 15:47
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
from django.conf import settings
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-05-30 03:08 # Generated by Django 1.11.6 on 2018-05-30 03:08
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.15 on 2018-09-22 17:17 # Generated by Django 1.11.15 on 2018-09-22 17:17
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,6 +1,6 @@
# Generated by Django 2.0.8 on 2018-09-28 13:23 # Generated by Django 2.0.8 on 2018-09-28 13:23
from django.db import migrations
from django.db import migrations, models from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,8 +1,8 @@
# Generated by Django 2.1.1 on 2018-12-01 23:15 # Generated by Django 2.1.1 on 2018-12-01 23:15
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
from django.conf import settings
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,9 +1,8 @@
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.http import QueryDict from django.http import QueryDict
from django.test import TestCase from django.test import TestCase
from django.utils.translation import activate
from django.urls import reverse from django.urls import reverse
from django.utils.translation import activate
from override_storage import override_storage from override_storage import override_storage
from .models import File from .models import File

View File

@ -1,21 +1,14 @@
from django.conf.urls import url from django.urls import path
from .views import ( from . import views
FileUploadView,
FileDeleteView,
ImageFileUploadView,
ImageFileDeleteView,
)
app_name = "files" app_name = "files"
urlpatterns = [ urlpatterns = [
url(r"^upload/$", FileUploadView.as_view(), name="upload"), path("upload/", views.FileUpload.as_view(), name="upload"),
url(r"^upload/image/$", ImageFileUploadView.as_view(), name="upload_image"), path("upload/image/", views.ImageFileUpload.as_view(), name="upload_image"),
url(r"^delete/(?P<pk>\d+)/$", FileDeleteView.as_view(), name="delete"), path("delete/<int:pk>/", views.FileDelete.as_view(), name="delete"),
url( path(
r"^delete/image/(?P<pk>\d+)/$", "delete/image/<int:pk>/", views.ImageFileDelete.as_view(), name="delete_image"
ImageFileDeleteView.as_view(),
name="delete_image",
), ),
] ]

View File

@ -1,13 +1,16 @@
from django.core.exceptions import PermissionDenied
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import PermissionDenied
from django.http import JsonResponse from django.http import JsonResponse
from django.views.generic import FormView, DetailView from django.views.generic import DetailView
from django.views.generic import FormView
from .forms import ImageFileForm, FileForm from .forms import FileForm
from .models import ImageFile, File from .forms import ImageFileForm
from .models import File
from .models import ImageFile
class FileUploadView(LoginRequiredMixin, FormView): class FileUpload(LoginRequiredMixin, FormView):
model = File model = File
form_class = FileForm form_class = FileForm
@ -29,12 +32,12 @@ class FileUploadView(LoginRequiredMixin, FormView):
return JsonResponse({"is_valid": False, "errors": form.errors}) return JsonResponse({"is_valid": False, "errors": form.errors})
class ImageFileUploadView(FileUploadView): class ImageFileUpload(FileUpload):
model = ImageFile model = ImageFile
form_class = ImageFileForm form_class = ImageFileForm
class FileDeleteView(LoginRequiredMixin, DetailView): class FileDelete(LoginRequiredMixin, DetailView):
model = File model = File
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
@ -51,5 +54,5 @@ class FileDeleteView(LoginRequiredMixin, DetailView):
return JsonResponse({"success": True}) return JsonResponse({"success": True})
class ImageFileDeleteView(FileDeleteView): class ImageFileDelete(FileDelete):
model = ImageFile model = ImageFile

View File

@ -1,9 +1,12 @@
from django.contrib import admin
from django import forms
from dal import autocomplete from dal import autocomplete
from django import forms
from django.contrib import admin
from leaflet.admin import LeafletGeoAdmin from leaflet.admin import LeafletGeoAdmin
from .models import CaseStudy, CaseStudyDraft, SpatialRefSys, PointOfInterest from .models import CaseStudy
from .models import CaseStudyDraft
from .models import PointOfInterest
from .models import SpatialRefSys
class CaseStudyDraftAdmin(admin.ModelAdmin): class CaseStudyDraftAdmin(admin.ModelAdmin):

View File

@ -1,19 +1,28 @@
from crispy_forms.bootstrap import FormActions
from crispy_forms.bootstrap import PrependedText
from crispy_forms.bootstrap import Tab
from crispy_forms.bootstrap import TabHolder
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Div
from crispy_forms.layout import Fieldset
from crispy_forms.layout import HTML
from crispy_forms.layout import Layout
from crispy_forms.layout import Submit
from dal import autocomplete
from django import forms from django import forms
from django.urls import reverse, reverse_lazy from django.urls import reverse
from django.urls import reverse_lazy
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.text import format_lazy from django.utils.text import format_lazy
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
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 leaflet.forms.widgets import LeafletWidget
from apps.files.models import File, ImageFile from .models import CaseStudy
from .models import PointOfInterest
from .models import CaseStudy, SpatialRefSys, PointOfInterest from .models import SpatialRefSys
from .widgets import JSONFileListWidget from .widgets import JSONFileListWidget
from apps.files.models import File
from apps.files.models import ImageFile
SECTOR_HELP = { SECTOR_HELP = {

View File

@ -2,11 +2,12 @@
# Generated by Django 1.11.1 on 2017-05-19 21:42 # Generated by Django 1.11.1 on 2017-05-19 21:42
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings
import django.contrib.gis.db.models.fields import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
import django_countries.fields import django_countries.fields
from django.conf import settings
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.10.7 on 2017-10-06 15:59 # Generated by Django 1.10.7 on 2017-10-06 15:59
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.10.7 on 2017-10-06 20:33 # Generated by Django 1.10.7 on 2017-10-06 20:33
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.10.7 on 2017-10-07 13:49 # Generated by Django 1.10.7 on 2017-10-07 13:49
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,8 @@
# Generated by Django 1.10.7 on 2017-10-07 14:23 # Generated by Django 1.10.7 on 2017-10-07 14:23
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations
import django_extensions.db.fields import django_extensions.db.fields
from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.10.7 on 2017-10-07 15:02 # Generated by Django 1.10.7 on 2017-10-07 15:02
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.10.7 on 2017-10-07 15:44 # Generated by Django 1.10.7 on 2017-10-07 15:44
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,10 @@
# Generated by Django 1.11.6 on 2017-10-11 16:06 # Generated by Django 1.11.6 on 2017-10-11 16:06
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations
from django.db import models
import apps.map.validators import apps.map.validators
from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-10-12 15:52 # Generated by Django 1.11.6 on 2017-10-12 15:52
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -3,8 +3,9 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import django.contrib.gis.db.models.fields import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django_countries.fields import django_countries.fields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-10-12 16:40 # Generated by Django 1.11.6 on 2017-10-12 16:40
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-10-25 20:35 # Generated by Django 1.11.6 on 2017-10-25 20:35
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-10-30 15:50 # Generated by Django 1.11.6 on 2017-10-30 15:50
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-10-31 14:42 # Generated by Django 1.11.6 on 2017-10-31 14:42
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-01 15:08 # Generated by Django 1.11.6 on 2017-11-01 15:08
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:05 # Generated by Django 1.11.6 on 2017-11-02 22:05
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:11 # Generated by Django 1.11.6 on 2017-11-02 22:11
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:19 # Generated by Django 1.11.6 on 2017-11-02 22:19
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:23 # Generated by Django 1.11.6 on 2017-11-02 22:23
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:28 # Generated by Django 1.11.6 on 2017-11-02 22:28
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:32 # Generated by Django 1.11.6 on 2017-11-02 22:32
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:50 # Generated by Django 1.11.6 on 2017-11-02 22:50
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 23:00 # Generated by Django 1.11.6 on 2017-11-02 23:00
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 23:26 # Generated by Django 1.11.6 on 2017-11-02 23:26
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 23:46 # Generated by Django 1.11.6 on 2017-11-02 23:46
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 23:58 # Generated by Django 1.11.6 on 2017-11-02 23:58
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-03 13:28 # Generated by Django 1.11.6 on 2017-11-03 13:28
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-03 16:08 # Generated by Django 1.11.6 on 2017-11-03 16:08
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-03 16:10 # Generated by Django 1.11.6 on 2017-11-03 16:10
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-03 17:45 # Generated by Django 1.11.6 on 2017-11-03 17:45
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-03 22:30 # Generated by Django 1.11.6 on 2017-11-03 22:30
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-03 22:54 # Generated by Django 1.11.6 on 2017-11-03 22:54
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-26 01:57 # Generated by Django 1.11.6 on 2018-03-26 01:57
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-27 03:34 # Generated by Django 1.11.6 on 2018-03-27 03:34
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-27 05:49 # Generated by Django 1.11.6 on 2018-03-27 05:49
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-28 01:46 # Generated by Django 1.11.6 on 2018-03-28 01:46
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-28 02:45 # Generated by Django 1.11.6 on 2018-03-28 02:45
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-28 03:09 # Generated by Django 1.11.6 on 2018-03-28 03:09
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-28 06:16 # Generated by Django 1.11.6 on 2018-03-28 06:16
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-28 11:22 # Generated by Django 1.11.6 on 2018-03-28 11:22
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,9 +2,11 @@
# Generated by Django 1.11.6 on 2018-03-29 10:44 # Generated by Django 1.11.6 on 2018-03-29 10:44
from __future__ import unicode_literals from __future__ import unicode_literals
import apps.map.validators
from django.db import migrations, models
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
from django.db import models
import apps.map.validators
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,9 @@
# Generated by Django 1.11.6 on 2018-03-31 04:59 # Generated by Django 1.11.6 on 2018-03-31 04:59
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models
import phonenumber_field.modelfields import phonenumber_field.modelfields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,9 @@
# Generated by Django 1.11.6 on 2018-03-31 05:17 # Generated by Django 1.11.6 on 2018-03-31 05:17
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models
import phonenumber_field.modelfields import phonenumber_field.modelfields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,10 @@
# Generated by Django 1.11.6 on 2018-03-31 06:04 # Generated by Django 1.11.6 on 2018-03-31 06:04
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations
from django.db import models
import apps.map.validators import apps.map.validators
from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-31 06:08 # Generated by Django 1.11.6 on 2018-03-31 06:08
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,9 @@
# Generated by Django 1.11.6 on 2018-03-31 09:33 # Generated by Django 1.11.6 on 2018-03-31 09:33
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-31 11:34 # Generated by Django 1.11.6 on 2018-03-31 11:34
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,8 @@
# Generated by Django 1.11.6 on 2018-04-02 12:37 # Generated by Django 1.11.6 on 2018-04-02 12:37
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -3,8 +3,9 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import django.contrib.gis.db.models.fields import django.contrib.gis.db.models.fields
from django.db import migrations, models
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -3,9 +3,10 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import django.contrib.gis.db.models.fields import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django_countries.fields import django_countries.fields
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,9 +2,10 @@
# Generated by Django 1.11.6 on 2018-04-12 06:50 # Generated by Django 1.11.6 on 2018-04-12 06:50
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
from django.conf import settings
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,10 +2,11 @@
# Generated by Django 1.11.6 on 2018-04-16 03:55 # Generated by Django 1.11.6 on 2018-04-16 03:55
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings
import django.contrib.gis.db.models.fields import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
from django.conf import settings
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,9 @@
# Generated by Django 1.11.6 on 2018-04-19 16:50 # Generated by Django 1.11.6 on 2018-04-19 16:50
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-04-23 02:20 # Generated by Django 1.11.6 on 2018-04-23 02:20
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-04-29 22:05 # Generated by Django 1.11.6 on 2018-04-29 22:05
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,9 @@
# Generated by Django 1.11.6 on 2018-05-19 18:01 # Generated by Django 1.11.6 on 2018-05-19 18:01
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-05-23 16:59 # Generated by Django 1.11.6 on 2018-05-23 16:59
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,9 @@
# Generated by Django 1.11.6 on 2018-05-25 00:35 # Generated by Django 1.11.6 on 2018-05-25 00:35
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-05-25 00:52 # Generated by Django 1.11.6 on 2018-05-25 00:52
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-05-26 15:36 # Generated by Django 1.11.6 on 2018-05-26 15:36
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-05-26 15:47 # Generated by Django 1.11.6 on 2018-05-26 15:47
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,9 @@
# Generated by Django 1.11.6 on 2018-05-30 02:52 # Generated by Django 1.11.6 on 2018-05-30 02:52
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models
import django.utils.timezone import django.utils.timezone
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,9 @@
# Generated by Django 1.11.15 on 2018-09-22 17:43 # Generated by Django 1.11.15 on 2018-09-22 17:43
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
from django.db import models
string_fields = [ string_fields = [
"additional_technical_details", "additional_technical_details",

View File

@ -2,8 +2,9 @@
# Generated by Django 1.11.15 on 2018-09-22 18:06 # Generated by Django 1.11.15 on 2018-09-22 18:06
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,11 +2,12 @@
# Generated by Django 1.11.6 on 2018-10-12 22:48 # Generated by Django 1.11.6 on 2018-10-12 22:48
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings
import django.contrib.gis.db.models.fields import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
import django_extensions.db.fields import django_extensions.db.fields
from django.conf import settings
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,9 +1,9 @@
# Generated by Django 2.1.1 on 2018-12-01 23:15 # Generated by Django 2.1.1 on 2018-12-01 23:15
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
import django_extensions.db.fields import django_extensions.db.fields
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,6 +1,6 @@
# Generated by Django 2.1.1 on 2018-12-02 02:09 # Generated by Django 2.1.1 on 2018-12-02 02:09
from django.db import migrations
from django.db import migrations, models from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,5 +1,4 @@
# Generated by Django 2.1.1 on 2018-12-02 02:23 # Generated by Django 2.1.1 on 2018-12-02 02:23
from django.db import migrations from django.db import migrations

View File

@ -1,6 +1,6 @@
# Generated by Django 2.1.1 on 2019-03-04 20:16 # Generated by Django 2.1.1 on 2019-03-04 20:16
from django.db import migrations
from django.db import migrations, models from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,6 +1,6 @@
# Generated by Django 2.1.1 on 2019-03-04 20:40 # Generated by Django 2.1.1 on 2019-03-04 20:40
from django.db import migrations
from django.db import migrations, models from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,7 +1,7 @@
# Generated by Django 2.1.1 on 2019-03-21 19:24 # Generated by Django 2.1.1 on 2019-03-21 19:24
from django.db import migrations, models
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,8 +1,8 @@
# Generated by Django 2.1.1 on 2019-04-07 15:30 # Generated by Django 2.1.1 on 2019-04-07 15:30
from django.db import migrations, models
import django_countries.fields import django_countries.fields
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,7 +1,7 @@
# Generated by Django 2.1.1 on 2019-04-07 16:04 # Generated by Django 2.1.1 on 2019-04-07 16:04
from django.db import migrations, models
import multiselectfield.db.fields import multiselectfield.db.fields
from django.db import migrations
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -6,9 +6,8 @@ from django.contrib.gis.db import models
from django.db import connection from django.db import connection
from django.template.defaultfilters import slugify from django.template.defaultfilters import slugify
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django_extensions.db.fields import AutoSlugField
from django_countries.fields import CountryField from django_countries.fields import CountryField
from django_extensions.db.fields import AutoSlugField
from multiselectfield import MultiSelectField from multiselectfield import MultiSelectField
from phonenumber_field.modelfields import PhoneNumberField from phonenumber_field.modelfields import PhoneNumberField

View File

@ -7,9 +7,9 @@ from django.test import TestCase
from django.urls import reverse from django.urls import reverse
from django.utils.translation import activate from django.utils.translation import activate
from .views import DraftsAPI
from .models import CaseStudy from .models import CaseStudy
from .models import CaseStudyDraft from .models import CaseStudyDraft
from .views import DraftsAPI
class CaseStudyDraftAPITests(TestCase): class CaseStudyDraftAPITests(TestCase):

View File

@ -1,4 +1,4 @@
from django.conf.urls import url from django.urls import path
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.views.generic import RedirectView from django.views.generic import RedirectView
from django.views.i18n import JavaScriptCatalog from django.views.i18n import JavaScriptCatalog
@ -6,47 +6,35 @@ from django.views.i18n import JavaScriptCatalog
from . import views from . import views
urlpatterns = [ urlpatterns = [
url(r"^$", RedirectView.as_view(url=reverse_lazy("map")), name="index"), path("", RedirectView.as_view(url=reverse_lazy("map")), name="index"),
url( path("map", views.Map.as_view(), name="map"),
r"^case-study/create/?$", views.CreateCaseStudySelector.as_view(), name="create" path("case-study/create", views.CreateCaseStudySelector.as_view(), name="create"),
), path(
url( "case-study/create/short",
r"^case-study/create/short/?$",
views.CreateShortCaseStudy.as_view(), views.CreateShortCaseStudy.as_view(),
name="short-form", name="short-form",
), ),
url( path(
r"^case-study/create/long/?$", "case-study/create/long", views.CreateLongCaseStudy.as_view(), name="long-form"
views.CreateLongCaseStudy.as_view(),
name="long-form",
), ),
url( path(
r"^case-study/create/poi/?$", "case-study/create/poi",
views.CreatePointOfInterest.as_view(), views.CreatePointOfInterest.as_view(),
name="point-of-interest-form", name="point-of-interest-form",
), ),
url( path(
r"^case-study/create/success/?$", "case-study/create/success",
views.CreateCaseStudySuccess.as_view(), views.CreateCaseStudySuccess.as_view(),
name="form-success", name="form-success",
), ),
url( path("case-study/edit/<int:pk>", views.EditCaseStudy.as_view(), name="edit"),
r"^case-study/edit/(?P<pk>[\d]+)/?$", views.EditCaseStudy.as_view(), name="edit" path("case-study/draft", views.DraftsAPI.as_view(), name="drafts"),
),
# Case study drafts
url(r"^case-study/draft/?$", views.DraftsAPI.as_view(), name="drafts"),
# View case studies
# This should be last so that the above options will be tried first! # This should be last so that the above options will be tried first!
url( path("case-study/<slug:slug>", views.ViewCaseStudyDetail.as_view(), name="detail"),
r"^case-study/(?P<slug>[-\w]+)/?$",
views.ViewCaseStudyDetail.as_view(),
name="detail",
),
url(r"^map/?$", views.Map.as_view(), name="map"),
# API # API
url(r"^jsi18n/$", JavaScriptCatalog.as_view(), name="javascript-catalogue"), path("jsi18n", JavaScriptCatalog.as_view(), name="javascript-catalogue"),
url( path(
r"^srs-autocomplete/$", "srs-autocomplete",
views.SpatialRefSysAutocomplete.as_view(), views.SpatialRefSysAutocomplete.as_view(),
name="srs-autocomplete", name="srs-autocomplete",
), ),

View File

@ -1,28 +1,26 @@
import logging
import json import json
import logging
from django.shortcuts import get_object_or_404 from dal import autocomplete
from django.conf import settings from django.conf import settings
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.mixins import UserPassesTestMixin
from django.core.mail import send_mail from django.core.mail import send_mail
from django.db.models import Q from django.db.models import Q
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from django.urls import reverse from django.urls import reverse
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.utils.translation import get_language from django.utils.translation import get_language
from django.views import View from django.views import View
from django.views.generic import DetailView from django.views.generic import DetailView
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django.views.generic.edit import CreateView, UpdateView from django.views.generic.edit import CreateView
from django.views.generic.edit import UpdateView
from dal import autocomplete
from apps.files.models import File
from . import models
from . import forms from . import forms
from .models import CaseStudy, CaseStudyDraft, SpatialRefSys from . import models
from .forms import ShortCaseStudyForm, LongCaseStudyForm from apps.files.models import File
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -82,9 +80,9 @@ def delete_user_draft(user_id):
""" Delete the draft of a given user """ """ Delete the draft of a given user """
try: try:
draft = CaseStudyDraft.objects.get(author=user_id) draft = models.CaseStudyDraft.objects.get(author=user_id)
draft.delete() draft.delete()
except CaseStudyDraft.DoesNotExist: except models.CaseStudyDraft.DoesNotExist:
pass pass
@ -117,7 +115,7 @@ class BaseCreateForm(LoginRequiredMixin, FilesHandlerMixin, CreateView):
template_name = "map/form-case_study.html" template_name = "map/form-case_study.html"
success_url = reverse_lazy("form-success") success_url = reverse_lazy("form-success")
model = CaseStudy model = models.CaseStudy
def form_valid(self, form): def form_valid(self, form):
self.handle_files(form) self.handle_files(form)
@ -136,14 +134,14 @@ class BaseCreateForm(LoginRequiredMixin, FilesHandlerMixin, CreateView):
class CreateShortCaseStudy(BaseCreateForm): class CreateShortCaseStudy(BaseCreateForm):
"""View for short version of case study form.""" """View for short version of case study form."""
form_class = ShortCaseStudyForm form_class = forms.ShortCaseStudyForm
form_type = "short" form_type = "short"
class CreateLongCaseStudy(BaseCreateForm): class CreateLongCaseStudy(BaseCreateForm):
"""View for long version of case study form.""" """View for long version of case study form."""
form_class = LongCaseStudyForm form_class = forms.LongCaseStudyForm
form_type = "long" form_type = "long"
@ -153,7 +151,7 @@ class CreateCaseStudySuccess(TemplateView):
class ViewCaseStudyDetail(DetailView): class ViewCaseStudyDetail(DetailView):
template_name = "map/detail.html" template_name = "map/detail.html"
model = CaseStudy model = models.CaseStudy
context_object_name = "case_study" context_object_name = "case_study"
@ -162,7 +160,7 @@ class BaseEditForm(LoginRequiredMixin, FilesHandlerMixin, UpdateView):
template_name = "map/form-case_study.html" template_name = "map/form-case_study.html"
success_url = reverse_lazy("form-success") success_url = reverse_lazy("form-success")
model = CaseStudy model = models.CaseStudy
def form_valid(self, form): def form_valid(self, form):
self.handle_files(form) self.handle_files(form)
@ -171,7 +169,7 @@ class BaseEditForm(LoginRequiredMixin, FilesHandlerMixin, UpdateView):
class EditCaseStudy(UserPassesTestMixin, BaseEditForm): class EditCaseStudy(UserPassesTestMixin, BaseEditForm):
form_class = ShortCaseStudyForm form_class = forms.ShortCaseStudyForm
def test_func(self): def test_func(self):
if settings.FFCAN_EDIT is False: if settings.FFCAN_EDIT is False:
@ -188,7 +186,7 @@ class EditCaseStudy(UserPassesTestMixin, BaseEditForm):
class SpatialRefSysAutocomplete(autocomplete.Select2QuerySetView): class SpatialRefSysAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self): def get_queryset(self):
qs = SpatialRefSys.objects.all() qs = models.SpatialRefSys.objects.all()
if self.q: if self.q:
qs = qs.filter( qs = qs.filter(
@ -212,14 +210,16 @@ class DraftsAPI(LoginRequiredMixin, View):
def put(self, request): def put(self, request):
try: try:
draft = CaseStudyDraft.objects.get(author=request.user) draft = models.CaseStudyDraft.objects.get(author=request.user)
draft.data = request.body.decode() draft.data = request.body.decode()
draft.save() draft.save()
return HttpResponse(status=200) # OK return HttpResponse(status=200) # OK
except models.CaseStudyDraft.DoesNotExist: except models.CaseStudyDraft.DoesNotExist:
# If it doesn't exist, create it # If it doesn't exist, create it
CaseStudyDraft.objects.create(author=request.user, data=request.body.decode()) models.CaseStudyDraft.objects.create(
author=request.user, data=request.body.decode()
)
return HttpResponse(status=201) # Created return HttpResponse(status=201) # Created
def delete(self, request): def delete(self, request):

View File

@ -1,6 +1,7 @@
import json import json
from django.forms import widgets from django.forms import widgets
from apps.files.models import File from apps.files.models import File

View File

@ -1,3 +0,0 @@
# from django.contrib import admin
# Register your models here.

Some files were not shown because too many files have changed in this diff Show More