File tree Expand file tree Collapse file tree
templates/frontend/course Expand file tree Collapse file tree Original file line number Diff line number Diff line change 166166 "impress_text" : "" ,
167167 "impress_url" : ""
168168}
169+
170+ ALLOW_PUBLIC_COURSE_EDITING_BY_EVERYONE = True
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ msgstr ""
6868
6969#: frontend/templates/frontend/content/detail.html:83
7070#: frontend/templates/frontend/course/create.html:30
71+ #: frontend/templates/frontend/course/edit.html:30
7172#: frontend/templates/frontend/profile/profile_edit.html:19
7273msgid "Cancel"
7374msgstr "Abbrechen"
@@ -235,10 +236,8 @@ msgid "Course '{cleaned_data['title']}' successfully created"
235236msgstr "Kurs '{cleaned_data['title']}' erfolgreich angelegt"
236237
237238#: frontend/views/course.py:52
238- #, fuzzy
239- #| msgid "Course '{cleaned_data['title']}' successfully created"
240239msgid "Course '{cleaned_data['title']}' successfully edited"
241- msgstr "Kurs '{cleaned_data['title']}' erfolgreich angelegt "
240+ msgstr "Kurs '{cleaned_data['title']}' erfolgreich bearbeitet "
242241
243242#: frontend/views/profile.py:25
244243msgid "Profile updated"
Original file line number Diff line number Diff line change 2222 {% if course in user.profile.stared_courses.all %}
2323 {% fa5_icon 'bookmark' 'fas' %}
2424 {% endif %}
25- {% if user.profile in course.owners.all %}
25+ {% if user|check_edit_course_permission: course %}
2626 < a href ="{% url 'frontend:course-edit' pk=course.pk %} " class ="btn btn-warning "> {% fa5_icon "pencil-alt" "fas" %} {% trans "Edit Course" %}</ a >
2727 < a href ="{% url 'frontend:course-delete' pk=course.pk %} " class ="btn btn-warning "> {% fa5_icon "trash" "fas" %} {% trans "Delete Course" %}</ a >
2828 {% endif %}
Original file line number Diff line number Diff line change 11from django import template
22from django .conf import settings
33
4+ from collab_coursebook .settings import ALLOW_PUBLIC_COURSE_EDITING_BY_EVERYONE
45from content .models import CONTENT_TYPES
56
67register = template .Library ()
@@ -86,3 +87,10 @@ def content_card(type):
8687 if type in CONTENT_TYPES .keys ():
8788 return f"content/cards/{ type } .html"
8889 return "content/cards/blank.html"
90+
91+
92+ @register .filter
93+ def check_edit_course_permission (user , course ):
94+ # either an user is an owner or the course is public and it is allowed to edit public courses
95+ return (user .profile in course .owners .all ()) or (not course .restrict_changes
96+ and ALLOW_PUBLIC_COURSE_EDITING_BY_EVERYONE )
You can’t perform that action at this time.
0 commit comments