Add edit permission to System Managers

This commit is contained in:
Faris Ansari
2017-08-30 11:57:21 +05:30
parent 15ef5ca554
commit 21fe63a524
2 changed files with 7 additions and 1 deletions

View File

@@ -24,6 +24,11 @@ class Bounty(WebsiteGenerator):
if bounty_left > (self.goal * 0.1) or bounty_left < 0: if bounty_left > (self.goal * 0.1) or bounty_left < 0:
bounty_left = self.goal * 0.1 bounty_left = self.goal * 0.1
# edit permission
can_edit = False
if 'System Manager' in frappe.get_roles() or self.owner == frappe.session.user:
can_edit = True
context.no_cache = True context.no_cache = True
context.no_breadcrumbs = False context.no_breadcrumbs = False
context.days_to_go = date_diff(self.end_date, nowdate()) context.days_to_go = date_diff(self.end_date, nowdate())
@@ -32,6 +37,7 @@ class Bounty(WebsiteGenerator):
context.fmt_money = fmt_money context.fmt_money = fmt_money
context.bounty_left = bounty_left context.bounty_left = bounty_left
context.comment_list = get_comment_list(self.doctype, self.name) context.comment_list = get_comment_list(self.doctype, self.name)
context.can_edit = can_edit
def validate(self): def validate(self):
from frappe.utils.user import get_user_fullname from frappe.utils.user import get_user_fullname

View File

@@ -33,7 +33,7 @@
<div class="main"> <div class="main">
<h1> <h1>
{{ title }} {{ title }}
{% if doc.owner == frappe.session.user %} {% if can_edit %}
<a href="/new-bounty?name={{doc.name}}" class="btn btn-default btn-xs">Edit</a> <a href="/new-bounty?name={{doc.name}}" class="btn btn-default btn-xs">Edit</a>
{% endif %} {% endif %}
<span style="font-size: 14px; line-height: 44px;" class="pull-right small">{{days_to_go}} days to go</span> <span style="font-size: 14px; line-height: 44px;" class="pull-right small">{{days_to_go}} days to go</span>