-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add appropriate pages. Add views. Add tests.
- Loading branch information
Showing
18 changed files
with
230 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
from flask import Blueprint, render_template | ||
from flask_login import login_required, current_user | ||
from app.models import Color | ||
from app.templates_paths import not_found_template_path, admin_panel_template_path | ||
from app.models import Color, User | ||
from app.templates_paths import not_found_template_path, admin_colors_template_path, admin_users_template_path | ||
|
||
admin_bp = Blueprint("admin", __name__, template_folder='templates', static_folder='static', | ||
static_url_path='/assets', url_prefix='/admin') | ||
|
||
|
||
@admin_bp.route("/", methods=["GET"]) | ||
@admin_bp.route("/colors", methods=["GET"]) | ||
@login_required | ||
def index(): | ||
def colors(): | ||
if current_user.is_admin is False: | ||
return render_template(not_found_template_path), 404 | ||
|
||
return render_template(admin_panel_template_path, colors=Color.get_all_colors()) | ||
return render_template(admin_colors_template_path, colors=Color.get_all_colors()) | ||
|
||
|
||
@admin_bp.route("/colors", methods=["GET"]) | ||
@admin_bp.route("/users", methods=["GET"]) | ||
@login_required | ||
def colors(): | ||
# TODO Update this. | ||
def users(): | ||
if current_user.is_admin is False: | ||
return render_template(not_found_template_path), 404 | ||
|
||
return render_template(admin_panel_template_path, colors=Color.get_all_colors()) | ||
return render_template(admin_users_template_path, users=User.get_all_users()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* Navbar | ||
-------------------------------------------------- */ | ||
.dropdown-menu { | ||
border-radius: 0px !important; | ||
margin: 0px !important; | ||
padding: 0px !important; | ||
#border: 0px !important; | ||
} | ||
|
||
.dropdown-menu a:hover { | ||
background: #2572e8 !important; /* Blue on hover */ | ||
} | ||
|
||
.dropdown-item { | ||
background-color: #337def !important; /* Blue */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{% extends "general/structure.html" %} | ||
|
||
{% block login %} | ||
{% endblock login %} | ||
|
||
{% block signup %} | ||
{% endblock signup %} | ||
|
||
{% block nav_greeting %} | ||
{% include 'general/menu_pieces/nav_greeting.html' %} | ||
{% endblock nav_greeting %} | ||
|
||
{% block settings %} | ||
{% include 'profile/menu_pieces/settings.html' %} | ||
{% endblock settings %} | ||
|
||
{% block admin %} | ||
{% if current_user.is_admin %} | ||
{% include 'admin/menu_pieces/admin.html' %} | ||
{% endif %} | ||
{% endblock admin %} | ||
|
||
{% block logout %} | ||
{% include 'auth/menu_pieces/logout.html' %} | ||
{% endblock logout %} | ||
|
||
{% block main %} | ||
<div class="content m-auto"> | ||
<h3 class="color-text">Available users</h3> | ||
<br> | ||
<table class="table color-text"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Username</th> | ||
<th scope="col">Color</th> | ||
<th scope="col">Is active</th> | ||
<th scope="col">Action</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for user in users %} | ||
<tr> | ||
<td scope="row" class="align-middle">{{ user.username }}</td> | ||
<td style="background-color:{{ user.favourite_color }}" class="align-middle"></td> | ||
<td class="align-middle">{{ user.is_active }}</td> | ||
<td> | ||
<button class="w-50 btn btn-sm general-button" type="submit"> | ||
TBD | ||
</button> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
{% endblock main %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
<li class="nav-item"> | ||
<a class="nav-link color-text" href="{{ url_for('admin.index') }}">[Admin panel]</a> | ||
</li> | ||
<li class="nav-item dropdown"> | ||
<a class="nav-link color-text dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> | ||
[Admin panel] | ||
</a> | ||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown"> | ||
<li><a class="dropdown-item color-text" href="{{ url_for('admin.colors') }}">[Colors]</a></li> | ||
<li><a class="dropdown-item color-text" href="{{ url_for('admin.users') }}">[Users]</a></li> | ||
</ul> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.