Compare commits

..

No commits in common. "c850a99200b726fe168f3180da21d55052848cce" and "73fe51ba9c09bddd5275797c5f869d46089a1d84" have entirely different histories.

116 changed files with 333 additions and 324 deletions

View File

@ -1,15 +0,0 @@
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,11 +1,9 @@
from django.contrib.auth.models import User from django.contrib.auth.models import User
from rest_framework import serializers from rest_framework import serializers, viewsets
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 from apps.map.models import CaseStudy, PointOfInterest
from apps.map.models import PointOfInterest
class UserSerializer(serializers.HyperlinkedModelSerializer): class UserSerializer(serializers.HyperlinkedModelSerializer):

0
apps/contact/__init__.py Normal file
View File

10
apps/contact/forms.py Normal file
View File

@ -0,0 +1,10 @@
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

@ -0,0 +1,21 @@
{% 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 %}

3
apps/contact/tests.py Normal file
View File

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

5
apps/contact/urls.py Normal file
View File

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

12
apps/contact/views.py Normal file
View File

@ -0,0 +1,12 @@
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,7 +1,6 @@
from django import forms from django import forms
from .models import File from .models import File, ImageFile
from .models import ImageFile
class FileForm(forms.ModelForm): class FileForm(forms.ModelForm):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,10 +2,9 @@
# 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
import django.db.models.deletion
from django.conf import settings from django.conf import settings
from django.db import migrations from django.db import migrations, models
from django.db import models import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,10 +2,9 @@
# 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
import django.db.models.deletion
from django.conf import settings from django.conf import settings
from django.db import migrations from django.db import migrations, models
from django.db import models import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 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.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 models from django.db import migrations, 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
import django.db.models.deletion
from django.conf import settings from django.conf import settings
from django.db import migrations from django.db import migrations, models
from django.db import models import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,8 +1,9 @@
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.urls import reverse
from django.utils.translation import activate from django.utils.translation import activate
from django.urls import reverse
from override_storage import override_storage from override_storage import override_storage
from .models import File from .models import File

View File

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

View File

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

View File

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

View File

@ -1,28 +1,19 @@
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 from django.urls import reverse, reverse_lazy
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 .models import CaseStudy from apps.files.models import File, ImageFile
from .models import PointOfInterest
from .models import SpatialRefSys from .models import CaseStudy, SpatialRefSys, PointOfInterest
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,12 +2,11 @@
# 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,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
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
import django_extensions.db.fields
from django.db import migrations from django.db import migrations
import django_extensions.db.fields
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,10 +2,8 @@
# 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,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -3,9 +3,8 @@
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,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
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
import multiselectfield.db.fields
from django.db import migrations from django.db import migrations
import multiselectfield.db.fields
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
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
import multiselectfield.db.fields
from django.db import migrations from django.db import migrations
import multiselectfield.db.fields
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,11 +2,9 @@
# 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 multiselectfield.db.fields
from django.db import migrations
from django.db import models
import apps.map.validators import apps.map.validators
from django.db import migrations, models
import multiselectfield.db.fields
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,9 +2,8 @@
# 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,9 +2,8 @@
# 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,10 +2,8 @@
# 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
import multiselectfield.db.fields
from django.db import migrations from django.db import migrations
import multiselectfield.db.fields
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,9 +2,8 @@
# 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,8 +2,7 @@
# 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 from django.db import migrations, models
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
import multiselectfield.db.fields
from django.db import migrations from django.db import migrations
import multiselectfield.db.fields
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -3,9 +3,8 @@
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,10 +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
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,10 +2,9 @@
# 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
import django.db.models.deletion
from django.conf import settings from django.conf import settings
from django.db import migrations from django.db import migrations, models
from django.db import models import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,11 +2,10 @@
# 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
import django.contrib.gis.db.models.fields
import django.db.models.deletion
from django.conf import settings from django.conf import settings
from django.db import migrations import django.contrib.gis.db.models.fields
from django.db import models from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,9 +2,8 @@
# 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,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,9 +2,8 @@
# 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,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,9 +2,8 @@
# 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,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,7 @@
# 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 from django.db import migrations, models
from django.db import models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,9 +2,8 @@
# 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,9 +2,8 @@
# 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,9 +2,8 @@
# 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,12 +2,11 @@
# 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 models from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,4 +1,5 @@
# 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 models from django.db import migrations, 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 models from django.db import migrations, 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,8 +6,9 @@ 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_countries.fields import CountryField
from django_extensions.db.fields import AutoSlugField from django_extensions.db.fields import AutoSlugField
from django_countries.fields import CountryField
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.urls import path from django.conf.urls import url
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,35 +6,47 @@ from django.views.i18n import JavaScriptCatalog
from . import views from . import views
urlpatterns = [ urlpatterns = [
path("", RedirectView.as_view(url=reverse_lazy("map")), name="index"), url(r"^$", RedirectView.as_view(url=reverse_lazy("map")), name="index"),
path("map", views.Map.as_view(), name="map"), url(
path("case-study/create", views.CreateCaseStudySelector.as_view(), name="create"), r"^case-study/create/?$", views.CreateCaseStudySelector.as_view(), name="create"
path( ),
"case-study/create/short", url(
r"^case-study/create/short/?$",
views.CreateShortCaseStudy.as_view(), views.CreateShortCaseStudy.as_view(),
name="short-form", name="short-form",
), ),
path( url(
"case-study/create/long", views.CreateLongCaseStudy.as_view(), name="long-form" r"^case-study/create/long/?$",
views.CreateLongCaseStudy.as_view(),
name="long-form",
), ),
path( url(
"case-study/create/poi", r"^case-study/create/poi/?$",
views.CreatePointOfInterest.as_view(), views.CreatePointOfInterest.as_view(),
name="point-of-interest-form", name="point-of-interest-form",
), ),
path( url(
"case-study/create/success", r"^case-study/create/success/?$",
views.CreateCaseStudySuccess.as_view(), views.CreateCaseStudySuccess.as_view(),
name="form-success", name="form-success",
), ),
path("case-study/edit/<int:pk>", views.EditCaseStudy.as_view(), name="edit"), url(
path("case-study/draft", views.DraftsAPI.as_view(), name="drafts"), r"^case-study/edit/(?P<pk>[\d]+)/?$", views.EditCaseStudy.as_view(), name="edit"
),
# 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!
path("case-study/<slug:slug>", views.ViewCaseStudyDetail.as_view(), name="detail"), url(
r"^case-study/(?P<slug>[-\w]+)/?$",
views.ViewCaseStudyDetail.as_view(),
name="detail",
),
url(r"^map/?$", views.Map.as_view(), name="map"),
# API # API
path("jsi18n", JavaScriptCatalog.as_view(), name="javascript-catalogue"), url(r"^jsi18n/$", JavaScriptCatalog.as_view(), name="javascript-catalogue"),
path( url(
"srs-autocomplete", r"^srs-autocomplete/$",
views.SpatialRefSysAutocomplete.as_view(), views.SpatialRefSysAutocomplete.as_view(),
name="srs-autocomplete", name="srs-autocomplete",
), ),

View File

@ -1,27 +1,29 @@
import json
import logging import logging
import json
from dal import autocomplete from django.shortcuts import get_object_or_404
from django.conf import settings from django.conf import settings
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
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 from django.views.generic.edit import CreateView, UpdateView
from django.views.generic.edit import UpdateView
from dal import autocomplete
from . import forms
from . import models
from apps.files.models import File from apps.files.models import File
from . import models
from . import forms
from .models import CaseStudy, CaseStudyDraft, SpatialRefSys
from .forms import ShortCaseStudyForm, LongCaseStudyForm
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
NOTIFY_MESSAGE = """ NOTIFY_MESSAGE = """
@ -80,9 +82,9 @@ def delete_user_draft(user_id):
""" Delete the draft of a given user """ """ Delete the draft of a given user """
try: try:
draft = models.CaseStudyDraft.objects.get(author=user_id) draft = CaseStudyDraft.objects.get(author=user_id)
draft.delete() draft.delete()
except models.CaseStudyDraft.DoesNotExist: except CaseStudyDraft.DoesNotExist:
pass pass
@ -115,7 +117,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 = models.CaseStudy model = CaseStudy
def form_valid(self, form): def form_valid(self, form):
self.handle_files(form) self.handle_files(form)
@ -134,14 +136,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 = forms.ShortCaseStudyForm form_class = 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 = forms.LongCaseStudyForm form_class = LongCaseStudyForm
form_type = "long" form_type = "long"
@ -151,7 +153,7 @@ class CreateCaseStudySuccess(TemplateView):
class ViewCaseStudyDetail(DetailView): class ViewCaseStudyDetail(DetailView):
template_name = "map/detail.html" template_name = "map/detail.html"
model = models.CaseStudy model = CaseStudy
context_object_name = "case_study" context_object_name = "case_study"
@ -160,7 +162,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 = models.CaseStudy model = CaseStudy
def form_valid(self, form): def form_valid(self, form):
self.handle_files(form) self.handle_files(form)
@ -169,7 +171,7 @@ class BaseEditForm(LoginRequiredMixin, FilesHandlerMixin, UpdateView):
class EditCaseStudy(UserPassesTestMixin, BaseEditForm): class EditCaseStudy(UserPassesTestMixin, BaseEditForm):
form_class = forms.ShortCaseStudyForm form_class = ShortCaseStudyForm
def test_func(self): def test_func(self):
if settings.FFCAN_EDIT is False: if settings.FFCAN_EDIT is False:
@ -186,7 +188,7 @@ class EditCaseStudy(UserPassesTestMixin, BaseEditForm):
class SpatialRefSysAutocomplete(autocomplete.Select2QuerySetView): class SpatialRefSysAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self): def get_queryset(self):
qs = models.SpatialRefSys.objects.all() qs = SpatialRefSys.objects.all()
if self.q: if self.q:
qs = qs.filter( qs = qs.filter(
@ -210,16 +212,14 @@ class DraftsAPI(LoginRequiredMixin, View):
def put(self, request): def put(self, request):
try: try:
draft = models.CaseStudyDraft.objects.get(author=request.user) draft = 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
models.CaseStudyDraft.objects.create( CaseStudyDraft.objects.create(author=request.user, data=request.body.decode())
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,7 +1,6 @@
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

3
apps/profiles/admin.py Normal file
View File

@ -0,0 +1,3 @@
# 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