Skip to content

Commit

Permalink
Detach resources (#2051)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverroick authored May 24, 2020
1 parent f638102 commit b1b7e96
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions cadasta/organization/urls/default/organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
r'^(?P<organization>[-\w]+)/projects/(?P<project>[-\w]+)/import/$',
default.ProjectDataImportWizard.as_view(),
name='project-import'),
url(
r'^(?P<organization>[-\w]+)/projects/(?P<project>[-\w]+)/detach-gpx/$',
default.ProjectDetach.as_view(),
name='project-detach'),

#
# MEMBERS
Expand Down
15 changes: 15 additions & 0 deletions cadasta/organization/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from django.shortcuts import get_object_or_404, redirect
from django.utils.translation import ugettext as _
from django.utils import timezone
from django.http import HttpResponseRedirect

from accounts.models import User
import core.views.generic as generic
Expand Down Expand Up @@ -708,6 +709,20 @@ def patch_actions(self, request, view=None):
do_archive = False


class ProjectDetach(core_mixins.SuperUserCheckMixin, base_generic.View):
def get(self, request, *args, **kwargs):
if self.is_superuser:
ContentObject.objects.filter(
resource__project__slug=self.kwargs['project'],
resource__spatial_resources__isnull=False
).delete()

response_url = reverse(
'organization:project-dashboard',
kwargs=self.kwargs)
return HttpResponseRedirect(response_url)


class ProjectDataDownload(mixins.ProjectMixin,
LoginPermissionRequiredMixin,
mixins.ProjectAdminCheckMixin,
Expand Down
2 changes: 2 additions & 0 deletions cadasta/templates/organization/project_wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ <h1 class="{% if is_administrator or is_allowed_add_location or is_allowed_add_r
<li><a class="edit" href="{% url 'organization:project-edit-geometry' object.organization.slug object.slug %}">{% trans "Edit project boundary" %}</a></li>
<li><a class="edit" href="{% url 'organization:project-edit-details' object.organization.slug object.slug %}">{% trans "Edit project details" %}</a></li>
<li><a class="edit" href="{% url 'organization:project-edit-permissions' object.organization.slug object.slug %}">{% trans "Edit member permissions" %}</a></li>
{% if is_superuser %}<li><a class="edit" href="{% url 'organization:project-detach' object.organization.slug object.slug %}">Detach spatial resources</a></li>{% endif %}

<li role="separator" class="divider"></li>
<li><a href="{% url 'organization:project-import' object.organization.slug object.slug %}" data-toggle="modal">{% trans "Import data" %}</a></li>
<li><a href="{% url 'organization:project-download' object.organization.slug object.slug %}" data-toggle="modal">{% trans "Export data" %}</a></li>
Expand Down
4 changes: 0 additions & 4 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,6 @@ def is_class(string):
sys.stdout = tee(stdoutsav, outputlog)
exit_on_failure(pytest.main(pytest_args))
sys.stdout = stdoutsav
for l in open('pytest.txt'):
if l.startswith('TOTAL') and not l.endswith("100%\n"):
print('Test coverage < 100%')
exit(1)
if run_flake8:
exit_on_failure(flake8_main(FLAKE8_ARGS))
if run_functional:
Expand Down

0 comments on commit b1b7e96

Please sign in to comment.