Skip to content

Commit 0ef68c4

Browse files
authored
Merge pull request #35 from DataManagementLab/origin/#8_Frontend_Allow_to_edit_course_description_and_image
Origin/#8 frontend allow to edit course description and image
2 parents f077fb3 + bb7acc9 commit 0ef68c4

14 files changed

Lines changed: 246 additions & 22 deletions

File tree

.github/workflows/django.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Django CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ main ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ main ]
88

99
jobs:
1010
build:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Collab Coursebook
22

3+
![Django CI](https://github.com/DataManagementLab/collab-coursebook/workflows/Django%20CI/badge.svg)
4+
35
## Description
46

57
Collab Coursebook is a plattform for collaborative learning und knowledge organization. It provides a place to share and re-use notes and other learning materials.

content/forms.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from django import forms
2+
from content.models import YTVideoContent, ImageContent
3+
4+
5+
class AddContentFormYoutubeVideo(forms.ModelForm):
6+
class Meta:
7+
model = YTVideoContent
8+
exclude = ['content']
9+
10+
11+
class AddContentFormImage(forms.ModelForm):
12+
class Meta:
13+
model = ImageContent
14+
exclude = ['content']
15+
16+
17+
CONTENT_TYPE_FORMS = {
18+
YTVideoContent.TYPE: AddContentFormYoutubeVideo,
19+
ImageContent.TYPE: AddContentFormImage,
20+
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
{# TODO Replace with real preview #}
2-
<div class="card-img-top fit bg-success" style="height: 180px;"></div>
1+
<img class="card-img-top fit" style="height: 180px;" src="{{ content.imagecontent.image.url }}" alt="{{ content.description }}" width="500" height="600">
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
{# TODO Replace with real preview #}
2-
<div class="card-img-top fit bg-success" style="height: 180px;"></div>
1+
<img class="card-img-top fit" style="height: 180px;" src="https://img.youtube.com/vi/{{ content.ytvideocontent.id }}/0.jpg" alt="{{ content.description }}" width="500" height="600">

frontend/forms/addcontent.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from django import forms
2+
from base.models.content import Content
3+
from content.models import YTVideoContent, ImageContent
4+
5+
6+
class AddContentForm(forms.ModelForm):
7+
"""
8+
The Form for adding new content to a topic
9+
"""
10+
class Meta: # pylint: disable=too-few-public-methods
11+
model = Content
12+
exclude = ['topic', 'author', 'creation_date', 'ratings', 'preview', 'type']

frontend/locale/de_DE/LC_MESSAGES/django.po

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,20 @@ msgstr "Diese Software ist Open Source"
3333
msgid "Are you sure you want to delete the following comment?"
3434
msgstr "Soll der folgende Kommentar wirklich gelöscht werden?"
3535

36+
#: frontend/templates/frontend/content/addcontent.html:23
37+
#: frontend/templates/frontend/course/create.html:29
38+
msgid "Create"
39+
msgstr "Erzeugen"
40+
41+
#: frontend/templates/frontend/content/addcontent.html:24
42+
#: frontend/templates/frontend/content/detail.html:80
43+
#: frontend/templates/frontend/course/create.html:30
44+
#: frontend/templates/frontend/profile/profile_edit.html:19
45+
msgid "Cancel"
46+
msgstr "Abbrechen"
47+
3648
#: frontend/templates/frontend/content/detail.html:18
49+
#: frontend/templates/frontend/course/view.html:25
3750
msgid "Actions"
3851
msgstr "Aktionen"
3952

@@ -99,6 +112,10 @@ msgstr "Neuen Kurs anlegen"
99112
msgid "Create"
100113
msgstr "Erzeugen"
101114

115+
#: frontend/templates/frontend/course/dropdown_topic.html:10
116+
msgid "Add Content"
117+
msgstr "Inhalte hinzufügen"
118+
102119
#: frontend/templates/frontend/course/edit.html:11
103120
msgid "Edit course"
104121
msgstr "Kurs bearbeiten"
@@ -112,6 +129,7 @@ msgid "Delete Course"
112129
msgstr "Kurs löschen"
113130

114131
#: frontend/templates/frontend/course/view.html:63
132+
#: frontend/templates/frontend/course/view.html:78
115133
msgid "No topics yet"
116134
msgstr "Bisher keine Themen"
117135

@@ -231,6 +249,14 @@ msgstr "Kommentar erfolgreich gelöscht."
231249
msgid "Successfully edited Comment."
232250
msgstr "Kommentar erfolgreich bearbeitet."
233251

252+
#: frontend/views/content.py:28
253+
msgid "Content '{cleaned_data['type']}' successfully added"
254+
msgstr "Inhalt '{cleaned_data['type']}' erfolgreich hinzugefügt"
255+
256+
#: frontend/views/content.py:35
257+
msgid "An error occurred while processing the request"
258+
msgstr "Es trat ein Fehler beim Verarbeiten der Anfrage auf"
259+
234260
#: frontend/views/course.py:26
235261
msgid "Course '{cleaned_data['title']}' successfully created"
236262
msgstr "Kurs '{cleaned_data['title']}' erfolgreich angelegt"
@@ -242,3 +268,6 @@ msgstr "Kurs '{cleaned_data['title']}' erfolgreich bearbeitet"
242268
#: frontend/views/profile.py:25
243269
msgid "Profile updated"
244270
msgstr "Profil aktualisiert"
271+
272+
#~ msgid "Delete Course"
273+
#~ msgstr "Kurs löschen"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{% extends 'frontend/base_logged_in.html' %}
2+
3+
{# Load the tag library #}
4+
{% load bootstrap4 %}
5+
{% load cc_frontend_tags %}
6+
{% load fontawesome_5 %}
7+
{% load static %}
8+
{% load i18n %}
9+
10+
{% block imports %}
11+
<link href="{% static 'css/content_detail.css' %}" type="text/css" rel="stylesheet"/>
12+
{% endblock %}
13+
14+
{% block content %}
15+
<form method="post" enctype=multipart/form-data>
16+
{% csrf_token %}
17+
{% bootstrap_form form %}
18+
{% bootstrap_form content_type_form %}
19+
20+
{{ form.media }}
21+
<div>
22+
23+
<button type="submit" class="btn btn-primary float-right">{% fa5_icon 'plus-circle' 'fas' %} {% trans "Create" %}</button>
24+
<a href="{% url 'frontend:dashboard' %}" class="btn btn-danger">{% fa5_icon 'times' 'fas' %} {% trans "Cancel" %}</a>
25+
</div>
26+
27+
</form>
28+
{% endblock %}

frontend/templates/frontend/content/detail.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@
2323
{# url 'readingmode' course.id topic.id content.id #}{% if ending %}{{ ending }}{% endif %}">{% fa5_icon 'eye' 'far' %}
2424
Reading Mode</a>
2525
{% if user.is_authenticated %}
26-
<a class="dropdown-item" href="{# url 'favourite_content' course.id topic.id content.id #}?onDetailPage=True">
27-
{% if favourite %}{% fa5_icon 'bookmark' 'fas' %} Unsave {% else %}{% fa5_icon 'bookmark' 'far' %} Save{% endif %}</a>
28-
<div class="dropdown-divider"></div>
29-
{% if markdown %}
26+
{% if content.type|is_content_editable %}
3027
<a class="dropdown-item"
31-
href="{% url 'edit_md_file' course.id topic.id content.id %}">{% fa5_icon 'pencil-alt' 'fas' %}
28+
href="{#{% url 'edit_md_file' course.id topic.id content.id %}#}">{% fa5_icon 'pencil-alt' 'fas' %}
3229
Edit</a>
3330

3431
{% endif %}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{% load i18n %}
2+
{# Load the tag library #}
3+
{% load bootstrap4 %}
4+
{% load fontawesome_5 %}
5+
{% load cc_frontend_tags %}
6+
7+
<div class="float-right text-right">
8+
<div class="dropdown show">
9+
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
10+
{% trans "Add Content" %}
11+
</button>
12+
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuLink">
13+
{% if user.is_authenticated %}
14+
{% for content in content_data %}
15+
<a class="dropdown-item"
16+
href="{% url 'frontend:content-add' course_id=course_id topic_id=topic_id type=content.0 %}">{% trans content.1 %}</a>
17+
{% endfor %}
18+
{% endif %}
19+
</div>
20+
</div>
21+
</div>

0 commit comments

Comments
 (0)