Skip to content

Commit

Permalink
Issue #104 restrict access to edit property page
Browse files Browse the repository at this point in the history
  • Loading branch information
2ynn committed Jun 16, 2021
1 parent f4156f7 commit 8b926b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion saskatoon/harvest/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dal import autocomplete
from django.contrib import messages
from django.contrib.messages.views import SuccessMessageMixin
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.http import HttpResponseRedirect
from django.urls import reverse_lazy
from rest_framework.response import Response
Expand Down Expand Up @@ -259,7 +260,8 @@ class PropertyCreatePublicView(SuccessMessageMixin, CreateView):
success_url = 'thanks'
success_message = 'Thanks for adding your property! In case you authorized a harvest for this season, please read the <a href="https://core.lesfruitsdefendus.org/s/bnKoECqGHAbXQqm">Tree Owner Welcome Notice</a>.'

class PropertyUpdateView(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
class PropertyUpdateView(PermissionRequiredMixin, SuccessMessageMixin, UpdateView):
permission_required = 'harvest.change_property'
model = Property
form_class = PropertyForm
template_name = 'app/property_create.html'
Expand Down
7 changes: 5 additions & 2 deletions saskatoon/sitebase/templates/app/property_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ <h4>** PENDING **</h4>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
<div class="breadcomb-report">
{% if perms.harvest.change_property %}
<a href="/property/update/{{ property.id }}">
<button data-placement="left" title="Edit property" class="btn">Edit</button>
<button data-placement="left" title="Edit property" class="btn">
Edit</button>
</a>
{% endif %}
</div>
</div>
</div>
Expand Down Expand Up @@ -93,7 +96,7 @@ <h2>{% trans "Owner" %}
</h2>
{% else %}
<h2>{% trans "Contact" %}
{% if perms.member.change_person %}
{% if perms.member.add_person %}
&nbsp;
<small><a href="/person/create/?pid={{property.id}}">
<i class="fa fa-pencil"></i> register
Expand Down

0 comments on commit 8b926b0

Please sign in to comment.