Commit 637ea45b authored by fred's avatar fred

finer grained handling of permissions

parent 2128c5b1
......@@ -14,11 +14,11 @@ class User(AbstractUser):
if self.is_staff:
return True
if isinstance(object, Emission):
return object in self.emissions.all()
return self.has_perm('emissions.change_emission') or object in self.emissions.all()
if isinstance(object, Episode):
return object.emission in self.emissions.all()
return self.has_perm('emissions.change_episode') or object.emission in self.emissions.all()
if isinstance(object, SoundFile):
return object.episode.emission in self.emissions.all()
return self.has_perm('emissions.change_soundfile') or object.episode.emission in self.emissions.all()
if isinstance(object, NewsItem):
return object.emission in self.emissions.all()
return self.has_perm('emissions.change_newsitem') or object.emission in self.emissions.all()
return False
{% extends "base.html" %}
{% block appbar %}
{% if user.is_staff %}
{% if perms.emissions.change_emission %}
<span><a href="{% url 'emission-list' %}">Toutes les émissions</a>
-
<a href="{% url 'news-list' %}">Toutes les actus</a></span>
......
......@@ -34,7 +34,7 @@ def decorated_includes(func, includes, *args, **kwargs):
def cms_permission_required(function=None, login_url=None):
def check_cms_permission(user):
if user and user.has_perm('combo.add_page'):
if user and user.has_perm('data.add_page'):
return True
if user and not user.is_anonymous():
raise PermissionDenied()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment