Clean up imports
This commit is contained in:
parent
3e5b41de1d
commit
dcb8f4beec
@ -20,11 +20,6 @@ from django.views.generic.edit import UpdateView
|
||||
|
||||
from . import forms
|
||||
from . import models
|
||||
from .forms import LongCaseStudyForm
|
||||
from .forms import ShortCaseStudyForm
|
||||
from .models import CaseStudy
|
||||
from .models import CaseStudyDraft
|
||||
from .models import SpatialRefSys
|
||||
from apps.files.models import File
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -85,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
|
||||
|
||||
|
||||
@ -120,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)
|
||||
@ -139,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"
|
||||
|
||||
|
||||
@ -156,7 +151,7 @@ class CreateCaseStudySuccess(TemplateView):
|
||||
|
||||
class ViewCaseStudyDetail(DetailView):
|
||||
template_name = "map/detail.html"
|
||||
model = CaseStudy
|
||||
model = models.CaseStudy
|
||||
context_object_name = "case_study"
|
||||
|
||||
|
||||
@ -165,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)
|
||||
@ -174,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:
|
||||
@ -191,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(
|
||||
@ -215,14 +210,14 @@ 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(
|
||||
models.CaseStudyDraft.objects.create(
|
||||
author=request.user, data=request.body.decode()
|
||||
)
|
||||
return HttpResponse(status=201) # Created
|
||||
|
@ -1,5 +1,6 @@
|
||||
from django.conf.urls import include
|
||||
from django.urls import include
|
||||
from django.conf.urls import url
|
||||
from django.urls import path
|
||||
from django.conf.urls.i18n import i18n_patterns
|
||||
from django.contrib import admin
|
||||
|
||||
@ -7,17 +8,16 @@ from .views import LanguageDropdownView
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r"^api/", include("apps.api.urls")),
|
||||
url(r"^admin/", admin.site.urls),
|
||||
url(r"^avatar/", include("avatar.urls")),
|
||||
url(r"^cas/", include("cas_server.urls", namespace="cas_server")),
|
||||
url(r"^files/", include("apps.files.urls")),
|
||||
path("api/", include("apps.api.urls")),
|
||||
path("admin/", admin.site.urls),
|
||||
path("avatar/", include("avatar.urls")),
|
||||
path("cas/", include("cas_server.urls", namespace="cas_server")),
|
||||
path("files/", include("apps.files.urls")),
|
||||
url(r"^set_language/(?P<language>[^/]+)$", LanguageDropdownView.as_view()),
|
||||
# url(r'^contact/', include('apps.contact.urls'), name="contact"),
|
||||
]
|
||||
|
||||
urlpatterns += i18n_patterns(
|
||||
url(r"^accounts/profile/", include("apps.profiles.urls", namespace="profile")),
|
||||
url(r"^accounts/", include("registration.backends.default.urls")),
|
||||
url(r"", include("apps.map.urls"), name="map"),
|
||||
path("accounts/profile/", include("apps.profiles.urls", namespace="profile")),
|
||||
path("accounts/", include("registration.backends.default.urls")),
|
||||
path("", include("apps.map.urls"), name="map"),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user