Repository: liqd/a4-opin

Issue:
Spatial Idea Challenge: No comments possible
In the blueprint Spatial Idea Challenge, in phase 1 comments cannot be made (be sure to test with normal user account). We need to fix the blueprint, apparently. See here https://opin-stage.liqd.net/de/maps/test-the-comments/ for an example.


Discussion:
The blueprint and phases setup seems to be correct. Either stage is outdated or this is an permissions issue. I'll update stage as first measure.
didn't work locally either, so i don't think it's that. more like permissions.

Resolving patch:
diff --git a/euth/maps/rules.py b/euth/maps/rules.py
--- a/euth/maps/rules.py
+++ b/euth/maps/rules.py
@@ -3,11 +3,36 @@
 
 from adhocracy4.modules.predicates import (is_context_initiator,
                                            is_context_member,
-                                           is_context_moderator)
-from adhocracy4.phases.predicates import phase_allows_create
-
+                                           is_context_moderator,
+                                           is_owner,
+                                           is_public_context)
+from adhocracy4.phases.predicates import (phase_allows_comment,
+                                          phase_allows_create,
+                                          phase_allows_modify,
+                                          phase_allows_rate)
 from .models import MapIdea
 
-rules.add_perm('euth_maps.propose_idea',
+
+rules.add_perm('euth_maps.rate_mapidea',
+               is_superuser | is_context_moderator | is_context_initiator |
+               (is_context_member & phase_allows_rate))
+
+
+rules.add_perm('euth_maps.comment_mapidea',
+               is_superuser | is_context_moderator | is_context_initiator |
+               (is_context_member & phase_allows_comment))
+
+
+rules.add_perm('euth_maps.modify_mapidea',
+               is_superuser | is_context_moderator | is_context_initiator |
+               (is_context_member & is_owner & phase_allows_modify))
+
+
+rules.add_perm('euth_maps.propose_mapidea',
                is_superuser | is_context_moderator | is_context_initiator |
                (is_context_member & phase_allows_create(MapIdea)))
+
+
+rules.add_perm('euth_maps.view_mapidea',
+               is_superuser | is_context_moderator | is_context_initiator |
+               is_context_member | is_public_context)
diff --git a/euth/maps/views.py b/euth/maps/views.py
--- a/euth/maps/views.py
+++ b/euth/maps/views.py
@@ -50,7 +50,7 @@ def get_context_data(self, **kwargs):
 class MapIdeaCreateView(idea_views.IdeaCreateView):
     model = MapIdea
     form_class = forms.MapIdeaForm
-    permission_required = 'euth_maps.propose_idea'
+    permission_required = 'euth_maps.propose_mapidea'
 
     def get_form_kwargs(self):
         kwargs = super().get_form_kwargs()
@@ -60,6 +60,7 @@ def get_form_kwargs(self):
 
 class MapIdeaUpdateView(idea_views.IdeaUpdateView):
     model = MapIdea
+    permission_required = 'euth_maps.modify_mapidea'
     form_class = forms.MapIdeaForm
 
     def get_form_kwargs(self):
@@ -70,10 +71,12 @@ def get_form_kwargs(self):
 
 class MapIdeaDeleteView(idea_views.IdeaDeleteView):
     model = MapIdea
+    permission_required = 'euth_maps.modify_mapidea'
 
 
 class MapIdeaDetailView(idea_views.IdeaDetailView):
     model = MapIdea
+    permission_required = 'euth_maps.view_mapidea'
     queryset = MapIdea.objects.annotate_positive_rating_count()\
         .annotate_negative_rating_count()
 


Test patch: