From f63810228aee00afb8e3524de59d10871a26c665 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Thu, 21 May 2020 17:51:00 +0100 Subject: [PATCH] Removes functionality to attach existing resources from templates (#2050) * Removes attach-from-exisiting resource from project templates * Removes attach-from-exisiting resource from location templates * Removes attach-from-exisiting resource from relationship templates * Removes attach-from-exisiting resource from party templates * Deactivate functional tests on CI * Removes attach-from-exisiting resource from project templates * Removes HasUnattachedResourcesMixin from views * Remove dead code --- .travis.yml | 12 ---------- cadasta/party/views/default.py | 4 ---- cadasta/party/views/mixins.py | 3 --- cadasta/resources/views/default.py | 2 -- cadasta/resources/views/mixins.py | 24 ------------------- cadasta/spatial/views/default.py | 2 -- .../organization/project_wrapper.html | 2 +- cadasta/templates/party/party_detail.html | 18 +++++--------- .../templates/party/relationship_detail.html | 8 ------- .../templates/resources/modal_add_lib.html | 4 ---- cadasta/templates/resources/modal_upload.html | 6 ----- cadasta/templates/resources/project_list.html | 4 ---- .../templates/spatial/location_detail.html | 8 ------- 13 files changed, 7 insertions(+), 90 deletions(-) diff --git a/.travis.yml b/.travis.yml index 611db668a..4e9dc412f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,18 +63,6 @@ matrix: - if: type = push env: TOX_ENV=py35-django-unit - - - if: type IN (push, pull_request) AND branch = master - env: TOX_ENV=py35-functional-batch1 - - - if: type IN (push, pull_request) AND branch = master - env: TOX_ENV=py35-functional-batch2 - - - if: type IN (push, pull_request) AND branch = master - env: TOX_ENV=py35-functional-batch3 - - - if: type IN (push, pull_request) AND branch = master - env: TOX_ENV=py35-functional-batch4 script: - tox -e $TOX_ENV diff --git a/cadasta/party/views/default.py b/cadasta/party/views/default.py index a4b029334..9cd847f6c 100644 --- a/cadasta/party/views/default.py +++ b/cadasta/party/views/default.py @@ -46,7 +46,6 @@ class PartiesDetail(LoginPermissionRequiredMixin, JsonAttrsMixin, mixins.PartyObjectMixin, organization_mixins.ProjectAdminCheckMixin, - resource_mixins.HasUnattachedResourcesMixin, resource_mixins.DetachableResourcesListMixin, generic.DetailView): template_name = 'party/party_detail.html' @@ -193,7 +192,6 @@ def post(self, request, *args, **kwargs): class PartyResourcesNew(LoginPermissionRequiredMixin, mixins.PartyResourceMixin, organization_mixins.ProjectAdminCheckMixin, - resource_mixins.HasUnattachedResourcesMixin, generic.CreateView): template_name = 'party/resources_new.html' permission_required = update_permissions('party.resources.add') @@ -204,7 +202,6 @@ class PartyRelationshipDetail(LoginPermissionRequiredMixin, JsonAttrsMixin, mixins.PartyRelationshipObjectMixin, organization_mixins.ProjectAdminCheckMixin, - resource_mixins.HasUnattachedResourcesMixin, resource_mixins.DetachableResourcesListMixin, generic.DetailView): template_name = 'party/relationship_detail.html' @@ -279,7 +276,6 @@ def get_success_url(self): class PartyRelationshipResourceNew(LoginPermissionRequiredMixin, mixins.PartyRelationshipResourceMixin, organization_mixins.ProjectAdminCheckMixin, - resource_mixins.HasUnattachedResourcesMixin, generic.CreateView): template_name = 'party/relationship_resources_new.html' permission_required = update_permissions('tenure_rel.resources.add') diff --git a/cadasta/party/views/mixins.py b/cadasta/party/views/mixins.py index 1f8dd821a..334ca6535 100644 --- a/cadasta/party/views/mixins.py +++ b/cadasta/party/views/mixins.py @@ -123,9 +123,6 @@ def get_object(self): class PartyRelationshipResourceMixin(ResourceViewMixin, PartyRelationshipObjectMixin): - def get_content_object(self): - return self.get_object() - def get_form_kwargs(self, *args, **kwargs): kwargs = { 'project_id': self.get_project().id, diff --git a/cadasta/resources/views/default.py b/cadasta/resources/views/default.py index 543a8cf76..ef10052c8 100644 --- a/cadasta/resources/views/default.py +++ b/cadasta/resources/views/default.py @@ -16,7 +16,6 @@ class ProjectResources(LoginPermissionRequiredMixin, mixins.ProjectResourceMixin, - mixins.HasUnattachedResourcesMixin, mixins.DetachableResourcesListMixin, organization_mixins.ProjectAdminCheckMixin, generic.ListView): @@ -65,7 +64,6 @@ def post(self, request, *args, **kwargs): class ProjectResourcesNew(LoginPermissionRequiredMixin, mixins.ProjectResourceMixin, - mixins.HasUnattachedResourcesMixin, organization_mixins.ProjectAdminCheckMixin, generic.CreateView): template_name = 'resources/project_add_new.html' diff --git a/cadasta/resources/views/mixins.py b/cadasta/resources/views/mixins.py index ca6803c7b..64eecf5a1 100644 --- a/cadasta/resources/views/mixins.py +++ b/cadasta/resources/views/mixins.py @@ -114,30 +114,6 @@ def get_success_url(self): return reverse('resources:project_detail', kwargs=self.kwargs) -class HasUnattachedResourcesMixin(ProjectMixin): - def get_context_data(self, *args, **kwargs): - context = super().get_context_data(*args, **kwargs) - - # Determine the object that can have resources - if hasattr(self, 'get_content_object'): - # This is for views for uploading a new resource - # or the ProjectResources view - object = self.get_content_object() - elif hasattr(self, 'object'): - # This is for views that list entity resources - object = self.object - - project_resource_set_count = self.get_project().resource_set.filter( - archived=False).count() - if ( - project_resource_set_count > 0 and - project_resource_set_count != object.resources.count() - ): - context['has_unattached_resources'] = True - - return context - - class DetachableResourcesListMixin(ProjectMixin): def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) diff --git a/cadasta/spatial/views/default.py b/cadasta/spatial/views/default.py index 07822910a..265f3f794 100644 --- a/cadasta/spatial/views/default.py +++ b/cadasta/spatial/views/default.py @@ -67,7 +67,6 @@ class LocationDetail(LoginPermissionRequiredMixin, JsonAttrsMixin, mixins.SpatialUnitObjectMixin, organization_mixins.ProjectAdminCheckMixin, - resource_mixins.HasUnattachedResourcesMixin, resource_mixins.DetachableResourcesListMixin, generic.DetailView): template_name = 'spatial/location_detail.html' @@ -175,7 +174,6 @@ def post(self, request, *args, **kwargs): class LocationResourceNew(LoginPermissionRequiredMixin, mixins.SpatialUnitResourceMixin, organization_mixins.ProjectAdminCheckMixin, - resource_mixins.HasUnattachedResourcesMixin, generic.CreateView): template_name = 'spatial/resources_new.html' permission_required = update_permissions('spatial.resources.add') diff --git a/cadasta/templates/organization/project_wrapper.html b/cadasta/templates/organization/project_wrapper.html index d1fabc46a..e8f224993 100644 --- a/cadasta/templates/organization/project_wrapper.html +++ b/cadasta/templates/organization/project_wrapper.html @@ -76,7 +76,7 @@

{% if is_allowed_add_party %}
  • {% trans "Add party" %}
  • {% endif %} - {% if is_allowed_add_resource %}
  • {% trans "Add resource" %}
  • {% endif %} + {% if is_allowed_add_resource %}
  • {% trans "Add resource" %}
  • {% endif %} {% if is_allowed_add_resource and is_allowed_import %}{% endif %} {% if is_allowed_import %}
  • {% trans "Import data" %}
  • {% endif %} diff --git a/cadasta/templates/party/party_detail.html b/cadasta/templates/party/party_detail.html index 96b185f9a..459bfce3b 100644 --- a/cadasta/templates/party/party_detail.html +++ b/cadasta/templates/party/party_detail.html @@ -86,24 +86,18 @@

    {% trans "Party" %} {{ party.name }}

    {% if resource_list %} {% include 'resources/table.html' %} {% else %}

    {% trans "This party does not have any attached resources. To attach a resource, select the button below." %}

    {% endif %} diff --git a/cadasta/templates/party/relationship_detail.html b/cadasta/templates/party/relationship_detail.html index 6d31ebb03..e54aacbe7 100644 --- a/cadasta/templates/party/relationship_detail.html +++ b/cadasta/templates/party/relationship_detail.html @@ -44,11 +44,7 @@

    {% trans "Details" %}

    {% trans "Resources" %}

    {% if resource_list %}
    - {% if has_unattached_resources %} - - {% else %} - {% endif %} {% trans "Attach" %}
    {% include 'resources/table_sm.html' %} @@ -56,11 +52,7 @@

    {% trans "Resources" %}

    {% trans "This relationship does not have any attached resources. To attach a resource, select the button below." %}

    - {% if has_unattached_resources %} - - {% else %} - {% endif %} {% trans "Attach" %}
    diff --git a/cadasta/templates/resources/modal_add_lib.html b/cadasta/templates/resources/modal_add_lib.html index 2581150e7..e086686c0 100644 --- a/cadasta/templates/resources/modal_add_lib.html +++ b/cadasta/templates/resources/modal_add_lib.html @@ -10,10 +10,6 @@ -