Repository: kartoza/prj.app

Issue:
Cannot add course type, conveners and training centre
When logged in ad owner, I can *edit* any existing thing and add new courses but cannot add all the rest. the star button is never shown
![image](https://user-images.githubusercontent.com/233663/36860637-28baf14c-1d82-11e8-8763-95368f6489a8.png) the screenshot is while hovering the Course types box
I used to be able to do this or I'm I missing something?


Discussion:

Resolving patch:
diff --git a/django_project/certification/views/certifying_organisation.py b/django_project/certification/views/certifying_organisation.py
--- a/django_project/certification/views/certifying_organisation.py
+++ b/django_project/certification/views/certifying_organisation.py
@@ -196,6 +196,10 @@ def get_context_data(self, **kwargs):
         context = super(
             CertifyingOrganisationDetailView, self).get_context_data(**kwargs)
 
+        # lets set some default permission flags for checks in template.
+        context['user_can_create'] = False
+        context['user_can_delete'] = False
+
         certifying_organisation = context['certifyingorganisation']
         context['trainingcenters'] = TrainingCenter.objects.filter(
             certifying_organisation=certifying_organisation)
@@ -214,9 +218,26 @@ def get_context_data(self, **kwargs):
             certifying_organisation=certifying_organisation)
         context['num_attendees'] = context['attendee'].count()
         context['project_slug'] = project_slug
-        if project_slug:
-            context['the_project'] = Project.objects.get(slug=project_slug)
-            context['project'] = context['the_project']
+        context['the_project'] = Project.objects.get(slug=project_slug)
+        context['project'] = context['the_project']
+
+        if self.request.user.is_staff:
+            context['user_can_create'] = True
+            context['user_can_delete'] = True
+
+        if context['the_project'].certification_managers.filter(
+                project__owner=self.request.user.id).exists():
+            context['user_can_create'] = True
+            context['user_can_delete'] = True
+
+        if self.request.user == context['project'].owner:
+            context['user_can_create'] = True
+            context['user_can_delete'] = True
+
+        if certifying_organisation.organisation_owners.filter(
+                project__owner=self.request.user.id).exists():
+            context['user_can_create'] = True
+            context['user_can_delete'] = True
         return context
 
     def get_queryset(self):
diff --git a/django_project/changes/views/version.py b/django_project/changes/views/version.py
--- a/django_project/changes/views/version.py
+++ b/django_project/changes/views/version.py
@@ -101,9 +101,8 @@ def get_context_data(self, **kwargs):
             context['user_can_edit'] = True
             context['user_can_delete'] = True
 
-        version_managers = (
-            context['project'].changelog_managers.all())
-        if self.request.user in version_managers:
+        if context['project'].changelog_managers.filter(
+                project__owner=self.request.user.id).exists():
             context['user_can_edit'] = True
             context['user_can_delete'] = True
 
diff --git a/django_project/lesson/views/worksheet.py b/django_project/lesson/views/worksheet.py
--- a/django_project/lesson/views/worksheet.py
+++ b/django_project/lesson/views/worksheet.py
@@ -67,9 +67,8 @@ def get_context_data(self, **kwargs):
 
         # Permissions
         context['user_can_edit'] = False
-        lesson_managers = (
-            context['worksheet'].section.project.lesson_managers.all())
-        if self.request.user in lesson_managers:
+        if context['worksheet'].section.project.lesson_managers.filter(
+                project__owner=self.request.user.id).exists():
             context['user_can_edit'] = True
 
         if self.request.user == context['worksheet'].section.project.owner:


Test patch: