Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrisc committed Nov 24, 2024
1 parent e21a135 commit 3c9651b
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 20 deletions.
5 changes: 5 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ def users():

return render_template('users.html', users=users)

@app.route('/settings')
@login_required
def settings():
return render_template('settings.html', users=users)

@app.route('/users/edit/<int:id>', methods=['GET', 'POST'])
@login_required
def edit_user(id):
Expand Down
3 changes: 2 additions & 1 deletion db/create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ CREATE TABLE api_calls (
status_code INT,
status varchar,
total_rows_found INT,
error_message TEXT DEFAULT NULL
error_message TEXT DEFAULT NULL,
data_day TIMESTAMPTZ
);

CREATE TABLE daily_visits (
Expand Down
12 changes: 6 additions & 6 deletions templates/course_contents.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1 class="page-title">Course Contents</h1>
<tbody>
{% for course_content in course_contents %}
<tr>
<td style="text-align: center">
<td style="text-align: center; width: 5%">
<input type="checkbox" name="selected_courses" value="{{ course_content.id }}">
</td>
<td style="text-align: center">{{ course_content.type_of }}</td>
Expand All @@ -35,15 +35,15 @@ <h1 class="page-title">Course Contents</h1>
<td style="text-align: right">{{ course_content.lecture_no }} - {{ course_content.ex_number }}</td>
<td style="text-align: left">{{ course_content.ex_instruction }}</td>
{% endif %}
<td style="text-align: center">
<a href="{{ url_for('edit_course_content', id=course_content.id) }}" class="btn btn-warning btn-sm" data-toggle="tooltip" title="Edit"><i class="fas fa-pencil-alt"></i></a>
<form action="{{ url_for('delete_course_content', id=course_content.id) }}" method="post" style="display: inline;">
<button type="submit" class="btn btn-danger btn-sm" data-toggle="tooltip" title="Delete" onclick="return confirm('Are you sure you want to delete this user?')"><i class="fas fa-trash"></i></button>
</form>
<td style="text-align: center; width: 10%">
{% set file_name = course_content.language ~ '_' ~ course_content.type_of ~ '_' ~ course_content.lecture_no ~ '.html' %}
{% if file_exists(file_name) %}
<a href="{{ url_for('download_file', file_name=file_name) }}" class="btn btn-primary btn-sm" data-toggle="tooltip" title="Download"><i class="fas fa-download"></i></a>
{% endif %}
<a href="{{ url_for('edit_course_content', id=course_content.id) }}" class="btn btn-warning btn-sm" data-toggle="tooltip" title="Edit"><i class="fas fa-pencil-alt"></i></a>
<form action="{{ url_for('delete_course_content', id=course_content.id) }}" method="post" style="display: inline;">
<button type="submit" class="btn btn-danger btn-sm" data-toggle="tooltip" title="Delete" onclick="return confirm('Are you sure you want to delete this user?')"><i class="fas fa-trash"></i></button>
</form>
</td>
</tr>
{% endfor %}
Expand Down
18 changes: 12 additions & 6 deletions templates/create_course_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,33 @@
{% block content %}
<h1 class="page-title">Create Course Content</h1>
<form action="{{ url_for('create_course_content') }}" method="post">
<div class="form-group">
<div class="form-group" style="width: 50%;">
<label for="type_of">Type</label>
<input type="text" class="form-control" id="type_of" name="type_of" required>
<select class="form-control" id="type_of" name="type_of" required>
<option value="Lecture">Lecture</option>
<option value="Exercise">Exercise</option>
</select>
</div>
<div class="form-group">
<div class="form-group" style="width: 50%;">
<label for="language">Language</label>
<input type="text" class="form-control" id="language" name="language" required>
<select class="form-control" id="language" name="language" required>
<option value="R">R</option>
<option value="Python">Python</option>
</select>
</div>
<div class="form-group">
<label for="lecture_title">Title</label>
<input type="text" class="form-control" id="lecture_title" name="lecture_title" required>
</div>
<div class="form-group">
<div class="form-group" style="width: 20%;">
<label for="lecture_no">Lecture Number</label>
<input type="number" class="form-control" id="lecture_no" name="lecture_no">
</div>
<div class="form-group">
<label for="youtube_link">YouTube Link</label>
<input type="url" class="form-control" id="youtube_link" name="youtube_link">
</div>
<div class="form-group">
<div class="form-group" style="width: 20%;">
<label for="ex_number">Exercise Number</label>
<input type="number" class="form-control" id="ex_number" name="ex_number">
</div>
Expand Down
20 changes: 13 additions & 7 deletions templates/edit_course_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,33 @@
{% block content %}
<h1 class="page-title">Edit Course Content</h1>
<form action="{{ url_for('edit_course_content', id=course_content.id) }}" method="post">
<div class="form-group">
<div class="form-group" style="width: 30%;">
<label for="type_of">Type</label>
<input type="text" class="form-control" id="type_of" name="type_of" value="{{ course_content.type_of }}" required>
<select class="form-control" id="type_of" name="type_of" required>
<option value="Lecture" {% if course_content.type_of == "Lecture" %}selected{% endif %}>Lecture</option>
<option value="Exercise" {% if course_content.type_of == "Exercise" %}selected{% endif %}>Exercise</option>
</select>
</div>
<div class="form-group">
<div class="form-group" style="width: 30%;">
<label for="language">Language</label>
<input type="text" class="form-control" id="language" name="language" value="{{ course_content.language }}" required>
<select class="form-control" id="language" name="language" required>
<option value="R" {% if course_content.language == "R" %}selected{% endif %}>R</option>
<option value="Python" {% if course_content.language == "Python" %}selected{% endif %}>Python</option>
</select>
</div>
<div class="form-group">
<label for="lecture_title">Title</label>
<input type="text" class="form-control" id="lecture_title" name="lecture_title" value="{{ course_content.lecture_title }}" required>
</div>
<div class="form-group">
<div class="form-group" style="width: 20%;">
<label for="lecture_no">Lecture Number</label>
<input type="number" class="form-control" id="lecture_no" name="lecture_no" value="{{ course_content.lecture_no }}">
</div>
<div class="form-group">
<label for="youtube_link">YouTube Link</label>
<input type="url" class="form-control" id="youtube_link" name="youtube_link" value="{{ course_content.youtube_link }}">
</div>
<div class="form-group">
<div class="form-group" style="width: 20%;">
<label for="ex_number">Exercise Number</label>
<input type="number" class="form-control" id="ex_number" name="ex_number" value="{{ course_content.ex_number }}">
</div>
Expand All @@ -33,7 +39,7 @@ <h1 class="page-title">Edit Course Content</h1>
</div>
<div class="button-group">
<button type="submit" class="btn btn-primary">Save</button>
<a href="{{ url_for('users') }}" class="btn btn-secondary">Cancel</a>
<a href="{{ url_for('course_contents') }}" class="btn btn-secondary">Cancel</a>
</div>
</form>
{% endblock %}
8 changes: 8 additions & 0 deletions templates/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
</div>
</a>
</li>
<li class="c-menu__item {{ 'is-active' if request.endpoint == 'settings' else '' }}" data-toggle="tooltip" title="Settings">
<a class="c-menu__item__inner" href="{{ url_for('settings') }}">
<i class="fa-solid fa-gears"></i>
<div class="c-menu-item__title">
<span>Settings</span>
</div>
</a>
</li>
{# <li class="c-menu__item has-submenu" data-toggle="tooltip" title="Modules">#}
{# <div class="c-menu__item__inner">#}
{# <i class="fa fa-puzzle-piece"></i>#}
Expand Down
17 changes: 17 additions & 0 deletions templates/settings.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% extends "static.html" %}

{% block content %}
<h1 class="page-title">Edit User</h1>
<div class="page-content">
<form action="{{ url_for('edit_user', id=user.id) }}" method="post">
<div class="form-group">
<label for="username">Username</label>
<input type="text" id="username" name="username" class="form-control" value="{{ user.username }}" required>
</div>
<div class="button-group">
<button type="submit" class="btn btn-primary">Save</button>
<a href="{{ url_for('users') }}" class="btn btn-secondary">Cancel</a>
</div>
</form>
</div>
{% endblock %}

0 comments on commit 3c9651b

Please sign in to comment.