From 26050c0bf6abdb7a1aaf87bc28ee61d353a70e3f Mon Sep 17 00:00:00 2001 From: Corentin Date: Fri, 1 Nov 2024 18:45:40 +0100 Subject: [PATCH] Added styles to pages + starting to refactor code to multiple files --- CourseMaster/settings.py | 2 +- README.md | 10 +- redis_app/static/redis_app/style.css | 202 ++++++++++++++++ redis_app/templates/courses.html | 62 +++-- redis_app/templates/create.html | 63 +++-- redis_app/templates/details.html | 84 ++++--- redis_app/templates/home.html | 26 +- redis_app/templates/login.html | 45 ++-- redis_app/templates/notifications.html | 21 +- redis_app/templates/profile.html | 45 ++-- redis_app/templates/publish_message.html | 55 +++-- redis_app/templates/register.html | 45 ++-- redis_app/templates/search.html | 49 ++-- redis_app/templates/update.html | 83 ++++--- redis_app/utils/model.py | 230 ++++++++++++++++++ redis_app/views.py | 288 +++-------------------- 16 files changed, 840 insertions(+), 470 deletions(-) create mode 100644 redis_app/static/redis_app/style.css create mode 100644 redis_app/utils/model.py diff --git a/CourseMaster/settings.py b/CourseMaster/settings.py index f568ec2..105f98d 100644 --- a/CourseMaster/settings.py +++ b/CourseMaster/settings.py @@ -132,7 +132,7 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.2/howto/static-files/ -STATIC_URL = 'static/' +STATIC_URL = '/static/' # Default primary key field type # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field diff --git a/README.md b/README.md index 57e711c..b263ecf 100644 --- a/README.md +++ b/README.md @@ -84,16 +84,16 @@ OR ### Expiration -Expiration of the course: The course expires after 2 minutes. +Expiration of the course: The course expires after 5 minutes. If a student register to the course, it add 1 minute. --- -### Design +### Students management -Design is not existing yet. +As a teacher, you can't manage students registered to your course. --- -### Students management +### Searching -As a teacher, you can't manage students registered to your course. \ No newline at end of file +The search looks for title, description and level fo the course. There's no advanced search for the moment. \ No newline at end of file diff --git a/redis_app/static/redis_app/style.css b/redis_app/static/redis_app/style.css new file mode 100644 index 0000000..ec83e4f --- /dev/null +++ b/redis_app/static/redis_app/style.css @@ -0,0 +1,202 @@ +body { + margin: 0; + font-family: Arial, sans-serif; + color: #333; + background-color: #f4f4f9; + text-align: center; +} + +nav { + background-color: #333; + padding: 1rem; + display: flex; + justify-content: center; +} + +nav a { + color: white; + text-decoration: none; + margin: 0 1rem; + padding: 0.5rem 1rem; + font-family: Arial, sans-serif; + font-size: 1rem; + border-radius: 4px; + transition: background-color 0.3s ease, color 0.3s ease; +} + +nav a:hover { + background-color: #555; + color: #f5f5f5; +} + +nav a:active { + background-color: #777; +} + +p.no-courses { + text-align: center; + color: #777; + font-size: 1.2rem; + font-style: italic; +} + +.body a, .submit { + display: inline-block; + padding: 0.7rem 0.8rem; + background-color: #4a90e2; + color: white; + text-decoration: none; + border-radius: 5px; + font-size: 1rem; + text-align: center; + transition: background-color 0.3s ease; +} + +.body a { + margin: .5rem; +} + +.body a:hover, .submit:hover { + background-color: #357abd; +} + +.body { + margin-top: 2rem; + display: flex; + justify-content: center; +} + +.container { + width: 60%; + display: flex; + flex-direction: column; + flex-wrap: wrap; + justify-content: center; + align-items: center; +} + +form { + width: 500px; + padding: 1.5rem; + background-color: #f7f7f7; + border-radius: 8px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + font-family: Arial, sans-serif; +} + +fieldset { + border: none; + padding: 0; + margin: 0; +} + +label { + font-weight: bold; + margin-top: 1rem; + display: block; + color: #555; +} + +h1 { + margin-top: 0; + margin-bottom: 0; +} + +legend h1 { + text-align: center; + font-size: 1.8rem; + color: #333; + margin-bottom: 1rem; +} + +input, textarea, select { + padding: 0.6rem; + margin-top: 0.5rem; + border: 1px solid #ccc; + border-radius: 4px; + box-sizing: border-box; + font-size: 1rem; +} + +.input, textarea, select { + width: 100%; +} + +textarea { + height: 100px; + resize: vertical; +} + +.error-message { + background-color: #ee332d; + color: white; + width: 100%; + padding: 15px 0; + border-radius: 5px; + font-weight: bold; + text-align: center; + margin-top: 0.5rem; +} + +.success-message { + background-color: #51c961; + color: white; + width: 100%; + padding: 15px 0; + border-radius: 5px; + font-weight: bold; + text-align: center; + margin-top: 0.5rem; +} + +.submit-container { + display: flex; + flex-direction: column; + justify-content: end; + align-items: end; +} + +.div-container { + width: 500px; + padding: 1.5rem; + background-color: #f7f7f7; + border-radius: 8px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + font-family: Arial, sans-serif; +} + +.create-container { + display: flex; + justify-content: end; + align-items: end; +} + +.plus { + font-size: 30px; + font-weight: bold; + padding: 0; +} + +.create-course { + padding: 0 10 !important; + display: flex !important; + align-items: center !important; + justify-content: center !important; + flex-direction: row !important; + height: auto; +} + +.create-course>p { + margin: 0 5px 0 0 !important; +} + +.notifications { + display: flex; + justify-content: space-between; + flex-direction: row; +} + +.notifications h1 { + vertical-align: middle; + line-height: 50px; +} \ No newline at end of file diff --git a/redis_app/templates/courses.html b/redis_app/templates/courses.html index de03077..bf6d2d1 100644 --- a/redis_app/templates/courses.html +++ b/redis_app/templates/courses.html @@ -1,4 +1,8 @@ + + {% load static %} + + -

Courses for {{ person.name }}

- {% if courses %} - {% for course in courses %} - {{ course.title }} - {% endfor %} - {% else %} -

No course yet

- {% endif %} -

- Register to a course by Searching -

-
- {% if person %} - {% if person.role == "Teacher" %} - Create - {% endif %} - {% endif %} +
+
+
+
+ {% if error_message %} +

{{ error_message }}

+ {% endif %} + {% if success_message %} +

{{ success_message }}

+ {% endif %} + {% if person %} + {% if person.role == "Teacher" %} + + {% endif %} + {% endif %} +
+

Courses for {{ person.name }}

+ {% if courses %} +
+ {% for course in courses %} + {{ course.title }} + {% endfor %} +
+ {% else %} +

No course yet

+ {% endif %} + +
+
+
\ No newline at end of file diff --git a/redis_app/templates/create.html b/redis_app/templates/create.html index 472b5e4..3c512a0 100644 --- a/redis_app/templates/create.html +++ b/redis_app/templates/create.html @@ -1,4 +1,8 @@ + + {% load static %} + + -
- {% csrf_token %} -
-

Create a course

- - {% if error_message %} - {{ error_message }} - {% endif %} - -
-
+
+
+ + {% csrf_token %} +
+

Create a course

+ + {% if error_message %} +

{{ error_message }}

+ {% endif %} + {% if success_message %} +

{{ success_message }}

+ {% endif %} + + + -
-
+ + -
-
+ + -
-
-
- - - + + +
+ +
+ +
+ + + diff --git a/redis_app/templates/details.html b/redis_app/templates/details.html index 553f672..f6cf2e4 100644 --- a/redis_app/templates/details.html +++ b/redis_app/templates/details.html @@ -1,4 +1,8 @@ + + {% load static %} + + - {% if error_message %} - {{ error_message }} - {% endif %} - {% if success_message %} - {{ success_message }} - {% endif %} - {% if course %} -

Welcome in the course {{ course.title }}!

-

- {{ course.summary }} -

-

- This course is for {{ course.getLevel }} students -

-

- There's only {{ course.places }} places -

-

- The course has been created by {{ course.teacher_name }} -

- {% else %} -

No course found!

- {% endif %} - {% if person %} - {% if person.role == "Teacher" %} - Delete - Update - {% else %} - {% if register %} - Unregister - {% else %} - {% if full == False %} - Register +
+
+
+ {% if error_message %} +

{{ error_message }}

+ {% endif %} + {% if success_message %} +

{{ success_message }}

+ {% endif %} + {% if course %} +

Welcome in the course {{ course.title }}!

+

+ {{ course.summary }} +

+

+ This course is for {{ course.level }} students +

+

+ There's only {{ course.places }} places +

+

+ The course has been created by {{ course.teacher_name }} +

{% else %} -

The course if full.

+

No course found!

{% endif %} - {% endif %} - {% endif %} - {% endif %} + {% if person %} + {% if person.role == "Teacher" %} + Delete + Update + {% else %} + {% if register %} + Unregister + {% else %} + {% if full == False %} + Register + {% else %} +

The course if full.

+ {% endif %} + {% endif %} + {% endif %} + {% endif %} +
+
+
\ No newline at end of file diff --git a/redis_app/templates/home.html b/redis_app/templates/home.html index f4c2d81..d72f444 100644 --- a/redis_app/templates/home.html +++ b/redis_app/templates/home.html @@ -1,4 +1,8 @@ + + {% load static %} + + - {% if person != '' %} -

Welcome {{ person.name }}!

- {% else %} -

Welcome young padawan!

- {% endif %} +
+
+
+ {% if error_message %} +

{{ error_message }}

+ {% endif %} + {% if success_message %} +

{{ success_message }}

+ {% endif %} + {% if person != '' %} +

Welcome {{ person.name }}!

+ {% else %} +

Welcome young padawan!

+ {% endif %} +
+
+
\ No newline at end of file diff --git a/redis_app/templates/login.html b/redis_app/templates/login.html index 0f5634a..3075b0e 100644 --- a/redis_app/templates/login.html +++ b/redis_app/templates/login.html @@ -1,4 +1,8 @@ + + {% load static %} + + -
- {% csrf_token %} -
-

Login

- {% if error_message %}

{{ error_message }}

{% endif %} -
-
-
- -
- -
+
+
+
+ {% csrf_token %} +
+

Login

+ {% if error_message %} +

{{ error_message }}

+ {% endif %} + {% if success_message %} +

{{ success_message }}

+ {% endif %} + + + + +
+
+ +
+
+
+
\ No newline at end of file diff --git a/redis_app/templates/notifications.html b/redis_app/templates/notifications.html index 85c786c..a9557b1 100644 --- a/redis_app/templates/notifications.html +++ b/redis_app/templates/notifications.html @@ -1,4 +1,8 @@ + + {% load static %} + + -

Notifications

- {% for message in messages %} - {{ message.data }}
- {% endfor %} - Clear notifications +
+
+
+

Notifications

+ + Clear notifications +
+ {% for message in messages %} + {{ message.data }} + {% endfor %} +
+