Skip to content

Commit

Permalink
Removes functionality to attach existing resources from templates (#2050
Browse files Browse the repository at this point in the history
)

* 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
  • Loading branch information
oliverroick authored May 21, 2020
1 parent ea9ca71 commit f638102
Show file tree
Hide file tree
Showing 13 changed files with 7 additions and 90 deletions.
12 changes: 0 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions cadasta/party/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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')
Expand All @@ -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'
Expand Down Expand Up @@ -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')
Expand Down
3 changes: 0 additions & 3 deletions cadasta/party/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions cadasta/resources/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

class ProjectResources(LoginPermissionRequiredMixin,
mixins.ProjectResourceMixin,
mixins.HasUnattachedResourcesMixin,
mixins.DetachableResourcesListMixin,
organization_mixins.ProjectAdminCheckMixin,
generic.ListView):
Expand Down Expand Up @@ -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'
Expand Down
24 changes: 0 additions & 24 deletions cadasta/resources/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions cadasta/spatial/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion cadasta/templates/organization/project_wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h1 class="{% if is_administrator or is_allowed_add_location or is_allowed_add_r
</button>
<ul class="dropdown-menu">
{% if is_allowed_add_party %}<li><a href="{% url 'parties:add' object.organization.slug object.slug %}">{% trans "Add party" %}</a></li>{% endif %}
{% if is_allowed_add_resource %}<li><a href="{% url 'resources:project_add_existing' object.organization.slug object.slug %}">{% trans "Add resource" %}</a></li>{% endif %}
{% if is_allowed_add_resource %}<li><a href="{% url 'resources:project_add_new' object.organization.slug object.slug %}">{% trans "Add resource" %}</a></li>{% endif %}
{% if is_allowed_add_resource and is_allowed_import %}<li role="separator" class="divider"></li>{% endif %}
{% if is_allowed_import %}<li><a href="{% url 'organization:project-import' object.organization.slug object.slug %}" data-toggle="modal">{% trans "Import data" %}</a></li>{% endif %}
</ul>
Expand Down
18 changes: 6 additions & 12 deletions cadasta/templates/party/party_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,18 @@ <h2><span class="entity">{% trans "Party" %} </span>{{ party.name }}</h2>
<div role="tabpanel" class="tab-pane" id="resources">
{% if resource_list %}
<div class="top-btn pull-right top-add">
{% if has_unattached_resources %}
<a class="btn btn-primary btn-sm" href="{% url 'parties:resource_add' object.organization.slug object.slug party.id %}">
{% else %}
<a class="btn btn-primary btn-sm" href="{% url 'parties:resource_new' object.organization.slug object.slug party.id %}">
{% endif %}
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {% trans "Attach" %}</a>
<a class="btn btn-primary btn-sm" href="{% url 'parties:resource_new' object.organization.slug object.slug party.id %}">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {% trans "Attach" %}
</a>
</div>
{% include 'resources/table.html' %}
{% else %}
<div>
<p>{% trans "This party does not have any attached resources. To attach a resource, select the button below." %}</p>
<div class="btn-full">
{% if has_unattached_resources %}
<a class="btn btn-primary" href="{% url 'parties:resource_add' object.organization.slug object.slug party.id %}">
{% else %}
<a class="btn btn-primary" href="{% url 'parties:resource_new' object.organization.slug object.slug party.id %}">
{% endif %}
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {% trans "Attach" %}</a>
<a class="btn btn-primary" href="{% url 'parties:resource_new' object.organization.slug object.slug party.id %}">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {% trans "Attach" %}
</a>
</div>
</div>
{% endif %}
Expand Down
8 changes: 0 additions & 8 deletions cadasta/templates/party/relationship_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,15 @@ <h4>{% trans "Details" %}</h4>
<h4>{% trans "Resources" %}</h4>
{% if resource_list %}
<div class="top-btn pull-right top-add">
{% if has_unattached_resources %}
<a class="btn btn-primary btn-sm" href="{% url 'parties:relationship_resource_add' object.organization.slug object.slug relationship.id %}">
{% else %}
<a class="btn btn-primary btn-sm" href="{% url 'parties:relationship_resource_new' object.organization.slug object.slug relationship.id %}">
{% endif %}
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {% trans "Attach" %}</a>
</div>
{% include 'resources/table_sm.html' %}
{% else %}
<div>
<p>{% trans "This relationship does not have any attached resources. To attach a resource, select the button below." %}</p>
<div class="btn-full">
{% if has_unattached_resources %}
<a class="btn btn-primary" href="{% url 'parties:relationship_resource_add' object.organization.slug object.slug relationship.id %}">
{% else %}
<a class="btn btn-primary" href="{% url 'parties:relationship_resource_new' object.organization.slug object.slug relationship.id %}">
{% endif %}
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {% trans "Attach" %}</a>
</div>
</div>
Expand Down
4 changes: 0 additions & 4 deletions cadasta/templates/resources/modal_add_lib.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
<span aria-hidden="true">&times;</span>
</a>
<h3 class="modal-title">{% trans "Attach from library" %}</h3>
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="" role="tab">{% trans "Attach from library" %}</a></li>
<li role="presentation"><a href="{{ upload_url }}" role="tab">{% trans "Upload new" %}</a></li>
</ul>
</div>

<div class="modal-body">
Expand Down
6 changes: 0 additions & 6 deletions cadasta/templates/resources/modal_upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
<span aria-hidden="true">&times;</span>
</a>
<h3 class="modal-title">{% trans "Upload new resource" %}</h3>
{% if has_unattached_resources %}
<ul class="nav nav-tabs" role="tablist">
<li role="presentation"><a href="{{ add_lib_url }}" role="tab">{% trans "Attach from library" %}</a></li>
<li role="presentation" class="active"><a href="" role="tab">{% trans "Upload new" %}</a></li>
</ul>
{% endif %}
</div>

<div class="modal-body modal-6-12">
Expand Down
4 changes: 0 additions & 4 deletions cadasta/templates/resources/project_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ <h2>{% trans "Resources" %}</h2>
<div class="panel-body">
{% if is_allowed_add_resource %}
<div class="top-btn pull-right top-add">
{% if has_unattached_resources %}
<a class="btn btn-primary btn-sm" href="{% url 'resources:project_add_existing' project=object.slug organization=object.organization.slug %}">
{% else %}
<a class="btn btn-primary btn-sm" href="{% url 'resources:project_add_new' project=object.slug organization=object.organization.slug %}">
{% endif %}
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {% trans "Attach" %}</a>
</div>
{% endif %}
Expand Down
8 changes: 0 additions & 8 deletions cadasta/templates/spatial/location_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,15 @@ <h2 class="short">
<div role="tabpanel" class="tab-pane" id="resources">
{% if resource_list %}
<div class="top-btn pull-right top-add">
{% if has_unattached_resources %}
<a class="btn btn-primary btn-sm" href="{% url 'locations:resource_add' object.organization.slug object.slug location.id %}">
{% else %}
<a class="btn btn-primary btn-sm" href="{% url 'locations:resource_new' object.organization.slug object.slug location.id %}">
{% endif %}
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {% trans "Attach" %}</a>
</div>
{% include 'resources/table_sm.html' %}
{% else %}
<div>
<p>{% trans "This location does not have any attached resources. To attach a resource, select the button below." %}</p>
<div class="btn-full">
{% if has_unattached_resources %}
<a class="btn btn-primary" href="{% url 'locations:resource_add' object.organization.slug object.slug location.id %}">
{% else %}
<a class="btn btn-primary" href="{% url 'locations:resource_new' object.organization.slug object.slug location.id %}">
{% endif %}
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {% trans "Attach" %}</a>
</div>
</div>
Expand Down

0 comments on commit f638102

Please sign in to comment.