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 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 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):

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 .models import File, ImageFile
from .models import File
from .models import ImageFile
class FileForm(forms.ModelForm):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-04-23 02:20
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):

View File

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

View File

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

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-05-30 03:08
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.15 on 2018-09-22 17:17
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):

View File

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

View File

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

View File

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

View File

@ -1,21 +1,14 @@
from django.conf.urls import url
from django.urls import path
from .views import (
FileUploadView,
FileDeleteView,
ImageFileUploadView,
ImageFileDeleteView,
)
from . import views
app_name = "files"
urlpatterns = [
url(r"^upload/$", FileUploadView.as_view(), name="upload"),
url(r"^upload/image/$", ImageFileUploadView.as_view(), name="upload_image"),
url(r"^delete/(?P<pk>\d+)/$", FileDeleteView.as_view(), name="delete"),
url(
r"^delete/image/(?P<pk>\d+)/$",
ImageFileDeleteView.as_view(),
name="delete_image",
path("upload/", views.FileUpload.as_view(), name="upload"),
path("upload/image/", views.ImageFileUpload.as_view(), name="upload_image"),
path("delete/<int:pk>/", views.FileDelete.as_view(), name="delete"),
path(
"delete/image/<int:pk>/", views.ImageFileDelete.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.core.exceptions import PermissionDenied
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 .models import ImageFile, File
from .forms import FileForm
from .forms import ImageFileForm
from .models import File
from .models import ImageFile
class FileUploadView(LoginRequiredMixin, FormView):
class FileUpload(LoginRequiredMixin, FormView):
model = File
form_class = FileForm
@ -29,12 +32,12 @@ class FileUploadView(LoginRequiredMixin, FormView):
return JsonResponse({"is_valid": False, "errors": form.errors})
class ImageFileUploadView(FileUploadView):
class ImageFileUpload(FileUpload):
model = ImageFile
form_class = ImageFileForm
class FileDeleteView(LoginRequiredMixin, DetailView):
class FileDelete(LoginRequiredMixin, DetailView):
model = File
def get(self, request, *args, **kwargs):
@ -51,5 +54,5 @@ class FileDeleteView(LoginRequiredMixin, DetailView):
return JsonResponse({"success": True})
class ImageFileDeleteView(FileDeleteView):
class ImageFileDelete(FileDelete):
model = ImageFile

View File

@ -1,9 +1,12 @@
from django.contrib import admin
from django import forms
from dal import autocomplete
from django import forms
from django.contrib import admin
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):

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.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.text import format_lazy
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 apps.files.models import File, ImageFile
from .models import CaseStudy, SpatialRefSys, PointOfInterest
from .models import CaseStudy
from .models import PointOfInterest
from .models import SpatialRefSys
from .widgets import JSONFileListWidget
from apps.files.models import File
from apps.files.models import ImageFile
SECTOR_HELP = {

View File

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

View File

@ -2,7 +2,8 @@
# Generated by Django 1.10.7 on 2017-10-06 15:59
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.10.7 on 2017-10-06 20:33
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.10.7 on 2017-10-07 13:49
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):

View File

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

View File

@ -2,7 +2,8 @@
# Generated by Django 1.10.7 on 2017-10-07 15:02
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.10.7 on 2017-10-07 15:44
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):

View File

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

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-10-12 15:52
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):

View File

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

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-10-12 16:40
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-10-25 20:35
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-10-30 15:50
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-10-31 14:42
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-01 15:08
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:05
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:11
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:19
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:23
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:28
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:32
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 22:50
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 23:00
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 23:26
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 23:46
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-02 23:58
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):

View File

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

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-03 16:08
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-03 16:10
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-03 17:45
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-03 22:30
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2017-11-03 22:54
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-26 01:57
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-27 03:34
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-27 05:49
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-28 01:46
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-28 02:45
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-28 03:09
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):

View File

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

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-28 11:22
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):

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-03-31 11:34
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):

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-04-23 02:20
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-04-29 22:05
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):

View File

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

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-05-23 16:59
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):

View File

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

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-05-25 00:52
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-05-26 15:36
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):

View File

@ -2,7 +2,8 @@
# Generated by Django 1.11.6 on 2018-05-26 15:47
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):

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
import json
from django.forms import widgets
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