Merge lp:~bhavesh-goyal093/postorius/fixed-postorius-method-decorators into lp:postorius

Proposed by Bhavesh Goyal
Status: Merged
Merged at revision: 221
Proposed branch: lp:~bhavesh-goyal093/postorius/fixed-postorius-method-decorators
Merge into: lp:postorius
Diff against target: 38 lines (+9/-4)
2 files modified
src/postorius/auth/decorators.py (+8/-3)
src/postorius/templates/postorius/menu/list_nav.html (+1/-1)
To merge this branch: bzr merge lp:~bhavesh-goyal093/postorius/fixed-postorius-method-decorators
Reviewer Review Type Date Requested Status
Terri Approve
Review via email: mp+256037@code.launchpad.net

Description of the change

Fixed Bug #1435062 which caused postorius to show incorrect nav bar view for members posessing different roles.
The solution was found in correcting permissions for list_nav template and fixing method decorators for list_moderator_required which earlier didn't set is_list_owner to be True even if the user was the owner and as a result the view was shown to be incorrect.
Now the attributes are set correctly according to the roles and the nav bar sows correct view or different and multiple roles.

To post a comment you must log in.
Revision history for this message
Terri (terriko) wrote :

Whoops! Looks like you used tabs instead of spaces. I'll fix it when I do the merge, assuming my tests pass.

Revision history for this message
Bhavesh Goyal (bhavesh-goyal093) wrote :

Sorry for the tabs! I ll take care of them next time onwards...

Revision history for this message
Terri (terriko) wrote :

The update seems to have fixed the test errors I saw earlier; thanks!

Revision history for this message
Terri (terriko) wrote :

Also, it would be awesome if I had some tests for this behaviour. I'll open a separate bug for this.

Revision history for this message
Terri (terriko) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/postorius/auth/decorators.py'
--- src/postorius/auth/decorators.py 2015-02-09 14:35:44 +0000
+++ src/postorius/auth/decorators.py 2015-04-13 21:09:22 +0000
@@ -82,13 +82,18 @@
82 if getattr(user, 'is_list_owner', None):82 if getattr(user, 'is_list_owner', None):
83 return fn(*args, **kwargs)83 return fn(*args, **kwargs)
84 if getattr(user, 'is_list_moderator', None):84 if getattr(user, 'is_list_moderator', None):
85 return fn(*args, **kwargs)85 return fn(*args, **kwargs)
86 mlist = List.objects.get_or_404(fqdn_listname=list_id)86 mlist = List.objects.get_or_404(fqdn_listname=list_id)
87 if user.email not in mlist.moderators and \87 if user.email not in mlist.moderators and \
88 user.email not in mlist.owners:88 user.email not in mlist.owners:
89 raise PermissionDenied89 raise PermissionDenied
90 else:90 else:
91 user.is_list_moderator = True91 if user.email in mlist.moderators and \
92 user.email not in mlist.owners:
93 user.is_list_moderator = True
94 else:
95 user.is_list_moderator = True
96 user.is_list_owner = True
92 return fn(*args, **kwargs)97 return fn(*args, **kwargs)
93 return wrapper98 return wrapper
9499
95100
=== modified file 'src/postorius/templates/postorius/menu/list_nav.html'
--- src/postorius/templates/postorius/menu/list_nav.html 2015-04-13 19:38:03 +0000
+++ src/postorius/templates/postorius/menu/list_nav.html 2015-04-13 21:09:22 +0000
@@ -9,7 +9,7 @@
9 {% if user.is_superuser or user.is_list_owner %}9 {% if user.is_superuser or user.is_list_owner %}
10 <li class="mm_nav_item"><a class="{% nav_active_class current 'list_members' %}" href="{% url 'list_members' list.list_id %}">{% trans "Members" %}</a></li>10 <li class="mm_nav_item"><a class="{% nav_active_class current 'list_members' %}" href="{% url 'list_members' list.list_id %}">{% trans "Members" %}</a></li>
11 {% endif %}11 {% endif %}
12 {% if user.is_superuser or user.is_list_moderator %}12 {% if user.is_superuser or user.is_list_owner or user.is_list_moderator %}
13 <li class="mm_nav_item"><a class="{% nav_active_class current 'list_held_messages' %}" href="{% url 'list_held_messages' list.list_id %}">{% trans "Held Messages" %}</a></li>13 <li class="mm_nav_item"><a class="{% nav_active_class current 'list_held_messages' %}" href="{% url 'list_held_messages' list.list_id %}">{% trans "Held Messages" %}</a></li>
14 {% endif %}14 {% endif %}
15 {% if user.is_superuser or user.is_list_owner %}15 {% if user.is_superuser or user.is_list_owner %}

Subscribers

People subscribed via source and target branches