From 21b188a2718ef201fd41b8d5fcdb072ba4adad6b Mon Sep 17 00:00:00 2001 From: Julius O Date: Thu, 25 Feb 2016 18:20:18 +0000 Subject: [PATCH] Initial template for adding new web resource --- .../templates/wr_add_webresource.html | 51 ++++++++++++++++++- geokey_webresources/tests/test_views.py | 3 ++ geokey_webresources/views.py | 23 ++++++++- 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/geokey_webresources/templates/wr_add_webresource.html b/geokey_webresources/templates/wr_add_webresource.html index 5d05a92..766e9a3 100644 --- a/geokey_webresources/templates/wr_add_webresource.html +++ b/geokey_webresources/templates/wr_add_webresource.html @@ -12,18 +12,67 @@
-
+ {% csrf_token %}

{% if project.islocked %}{% endif %} Add new web resource for {{ project.name }}

+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + Cancel +
{% endblock %} {% block libraries %} + + + + + + {% endblock %} diff --git a/geokey_webresources/tests/test_views.py b/geokey_webresources/tests/test_views.py index 69c24e9..706db13 100755 --- a/geokey_webresources/tests/test_views.py +++ b/geokey_webresources/tests/test_views.py @@ -16,6 +16,7 @@ from .model_factories import WebResourceFactory from ..helpers.context_helpers import does_not_exist_msg +from ..base import FORMAT from ..models import WebResource from ..views import ( IndexPage, @@ -343,6 +344,7 @@ def test_get_with_admin(self): 'PLATFORM_NAME': get_current_site(self.request).name, 'user': self.request.user, 'messages': get_messages(self.request), + 'data_formats': FORMAT, 'project': self.project } ) @@ -502,6 +504,7 @@ def test_get_with_admin(self): 'PLATFORM_NAME': get_current_site(self.request).name, 'user': self.request.user, 'messages': get_messages(self.request), + 'data_formats': FORMAT, 'project': self.project, 'webresource': self.webresource } diff --git a/geokey_webresources/views.py b/geokey_webresources/views.py index adb16fb..7cfc4aa 100755 --- a/geokey_webresources/views.py +++ b/geokey_webresources/views.py @@ -10,6 +10,7 @@ from geokey.projects.views import ProjectContext from .helpers.context_helpers import does_not_exist_msg +from .base import FORMAT from .models import WebResource @@ -50,6 +51,24 @@ class AddWebResourcePage(LoginRequiredMixin, ProjectContext, TemplateView): template_name = 'wr_add_webresource.html' + def get_context_data(self, *args, **kwargs): + """ + GET method for the template. + + Return the context to render the view. Overwrite the method by adding + available data formats to the context. + + Returns + ------- + dict + Context. + """ + return super(AddWebResourcePage, self).get_context_data( + data_formats=FORMAT, + *args, + **kwargs + ) + class WebResourceContext(LoginRequiredMixin, ProjectContext, TemplateView): """Get web resource mixin.""" @@ -59,7 +78,7 @@ def get_context_data(self, project_id, webresource_id, *args, **kwargs): GET method for the template. Return the context to render the view. Overwrite the method by adding - a web resource to the context. + a web resource and available data formats to the context. Returns ------- @@ -72,6 +91,8 @@ def get_context_data(self, project_id, webresource_id, *args, **kwargs): **kwargs ) + context['data_formats'] = FORMAT + try: context['webresource'] = WebResource.objects.get( pk=webresource_id,