Skip to content

Commit f077fb3

Browse files
committed
implement changes from pull request comment
1 parent eb19c51 commit f077fb3

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

collab_coursebook/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,5 @@
166166
"impress_text": "",
167167
"impress_url": ""
168168
}
169+
170+
ALLOW_PUBLIC_COURSE_EDITING_BY_EVERYONE = True

frontend/locale/de_DE/LC_MESSAGES/django.po

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff 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
7273
msgid "Cancel"
7374
msgstr "Abbrechen"
@@ -235,10 +236,8 @@ msgid "Course '{cleaned_data['title']}' successfully created"
235236
msgstr "Kurs '{cleaned_data['title']}' erfolgreich angelegt"
236237

237238
#: frontend/views/course.py:52
238-
#, fuzzy
239-
#| msgid "Course '{cleaned_data['title']}' successfully created"
240239
msgid "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
244243
msgid "Profile updated"

frontend/templates/frontend/course/view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
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 %}

frontend/templatetags/cc_frontend_tags.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from django import template
22
from django.conf import settings
33

4+
from collab_coursebook.settings import ALLOW_PUBLIC_COURSE_EDITING_BY_EVERYONE
45
from content.models import CONTENT_TYPES
56

67
register = 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)

0 commit comments

Comments
 (0)