diff options
author | adityacp | 2020-07-01 17:16:27 +0530 |
---|---|---|
committer | adityacp | 2020-07-01 17:16:27 +0530 |
commit | d22be9a00da34a2c0d605482d3aaf91371efc2db (patch) | |
tree | e5a0e51ff139db6935cf6323ea6325d14b743d18 | |
parent | 555632b71cae356580be48f5745de64681682359 (diff) | |
download | workshop_booking-d22be9a00da34a2c0d605482d3aaf91371efc2db.tar.gz workshop_booking-d22be9a00da34a2c0d605482d3aaf91371efc2db.tar.bz2 workshop_booking-d22be9a00da34a2c0d605482d3aaf91371efc2db.zip |
Change templates
- Add custom template tag to check user group
- Disable propose workshop option for the instructor
- Show a generic message info in the propose workshop section
- Fix forgot password
- Make a proper footer
- Remove navbar options in the login page
- Other minor fixes
17 files changed, 203 insertions, 73 deletions
diff --git a/workshop_app/static/workshop_app/css/base.css b/workshop_app/static/workshop_app/css/base.css index 5ad36b2..3c38459 100644 --- a/workshop_app/static/workshop_app/css/base.css +++ b/workshop_app/static/workshop_app/css/base.css @@ -48,10 +48,14 @@ .footer { position: fixed; - right: 0; + z-index: 100; bottom: 0; - left: 0; - background-color: #efefef; + width: 100%; + background-color: #61615F; + color: white; text-align: center; - padding: 10px 0; +} +.base-content { + padding-top: 5em; + padding-bottom: 5em; } diff --git a/workshop_app/templates/registration/password_reset_complete.html b/workshop_app/templates/registration/password_reset_complete.html new file mode 100644 index 0000000..7b07cf8 --- /dev/null +++ b/workshop_app/templates/registration/password_reset_complete.html @@ -0,0 +1,12 @@ +{% extends "workshop_app/base.html" %} + +{% block title %} Forgot Password {% endblock %} + +{% block content %} +<center> +<div class="container"> + <p>Your password has been reset. </p> + <p><a href="{{ login_url }}" class="btn btn-success btn-lg">Log in</a></p> + </div> +</center> +{% endblock %} diff --git a/workshop_app/templates/registration/password_reset_confirm.html b/workshop_app/templates/registration/password_reset_confirm.html new file mode 100644 index 0000000..25d5b41 --- /dev/null +++ b/workshop_app/templates/registration/password_reset_confirm.html @@ -0,0 +1,59 @@ +{% extends "workshop_app/base.html" %} + +{% block title %} Forgot Password {% endblock %} + +{% block script %} +<script type="text/javascript"> + $(document).ready(function() + { + $("#id_new_password1").addClass("form-control"); + $("#id_new_password2").addClass("form-control"); + }); +</script> +{% endblock %} + +{% block content %} +<br><br> +<center><h4>Reset Password</h4> + <div class="container col-md-6"> + {% if validlink %} + <p>Please enter your new password twice so we can verify you typed it in correctly + </p> + <form method="post"> + {% csrf_token %} + <table class="table table-responsive-sm"> + {% if form.errors %} + {% for field in form %} + {% for error in field.errors %} + <div class="alert alert-dismissible alert-danger"> + <button type="button" class="close" data-dismiss="alert"> + <i class="fa fa-close">×</i> + </button> + <strong>{{ error|escape }}</strong> + </div> + {% endfor %} + {% endfor %} + {% for error in form.non_field_errors %} + <div class="alert alert-dismissible alert-danger"> + <button type="button" class="close" data-dismiss="alert"> + <i class="fa fa-close">×</i> + </button> + <strong>{{ error|escape }}</strong> + </div> + {% endfor %} + {% endif %} + {% for field in form %} + <tr> + <td>{{ field.label }}</td> + <td>{{ field }} <small>{{ field.help_text }}</small></td> + </tr> + {% endfor %} + </table> + <button class= "btn btn-success btn-lg" type="submit">Submit</button> + </form> + {% else %} + <p>This reset link is no longer valid!</p> + {% endif %} + </div> +</center> +{% endblock %} diff --git a/workshop_app/templates/registration/password_reset_done.html b/workshop_app/templates/registration/password_reset_done.html new file mode 100644 index 0000000..bc10a8d --- /dev/null +++ b/workshop_app/templates/registration/password_reset_done.html @@ -0,0 +1,14 @@ +{% extends "workshop_app/base.html" %} +{% block title %} Forgot Password {% endblock %} + + +{% block content %} +<center> +<h2>Password reset successful</h2> +<div class="alert alert-success col-md-8"> +Instruction for setting new password has been mailed to your registered email address +</div> +<br> +<a class="btn btn-primary btn-lg" href="{% url 'index' %}">Go to Login</a> +</center> +{% endblock %} diff --git a/workshop_app/templates/registration/password_reset_form.html b/workshop_app/templates/registration/password_reset_form.html new file mode 100644 index 0000000..031fd96 --- /dev/null +++ b/workshop_app/templates/registration/password_reset_form.html @@ -0,0 +1,34 @@ +{% extends "workshop_app/base.html" %} + +{% block title %} Forgot Password {% endblock %} + +{% block content %} +<center> +<h4>Enter your registered email address to reset your password</h4> +<div class="container"> + <div class="row justify-content-center"> + <div class="col-md-6 col-md-offset-6"> + <div class="card border-primary"> + <div class="card-header"><h3>Forgot Password?</h3></div> + <div class="card-body"> + <div class="form-group"> + <form action="" method="post"> + {% csrf_token %} + + {{ form }} + <br><br> + <button class="btn btn-success btn-lg" type="submit"> + Request + </button> + <a href="{% url 'index' %}" class="btn btn-primary btn-lg"> + Cancel + </a> + </form> + </div> + </div> + </div> + </div> + </div> +</div> +</center> +{% endblock content %} diff --git a/workshop_app/templates/workshop_app/base.html b/workshop_app/templates/workshop_app/base.html index cbae805..9655d72 100644 --- a/workshop_app/templates/workshop_app/base.html +++ b/workshop_app/templates/workshop_app/base.html @@ -1,6 +1,7 @@ <!DOCTYPE html> <html> {% load static %} +{% load custom_filters %} <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <title> @@ -31,70 +32,62 @@ </head> -<body style="overflow: scroll;"> +<body> {% block header %} - <nav class=" navbar-custom navbar navbar-expand-lg bg-light"> + <nav class=" navbar-custom navbar navbar-expand-lg bg-light fixed-top"> <a class="navbar-brand" href="/">FOSSEE Python Workshops</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> - <div class="collapse navbar-collapse" id="navbarSupportedContent"> + {% if user.is_authenticated %} <ul class="navbar-nav mr-auto"> - {% if request.user.profile.position == 'coordinator' %} - <li class="nav-item"> - <a class="nav-link" href="{% url 'workshop_status_instructor' %}">Workshop Status</a> - </li> - <li class="nav-item"> - <a class="nav-link" href="{% url 'propose_workshop' %}">Propose Workshop</a> - </li> - <li class="nav-item"> - <a class="nav-link" href="{% url 'workshop_type_list' %}">Workshop Types</a> - </li> - {% elif request.user.profile.position == 'instructor' %} + <li class="nav-item"> + <a class="nav-link" href="{% url 'workshop_status_instructor' %}"> + Workshop Status + </a> + </li> + {% if not request.user|has_group:"instructor" %} <li class="nav-item"> - <a class="nav-link" href="{% url 'workshop_status_instructor' %}">Workshop Status</a> - </li> - <li class="nav-item"> - <a class="nav-link" href="{% url 'workshop_type_list' %}">Workshop Types</a> + <a class="nav-link" href="{% url 'propose_workshop' %}"> + Propose Workshop + </a> </li> {% endif %} + <li class="nav-item"> + <a class="nav-link" href="{% url 'workshop_type_list' %}"> + Workshop Types + </a> + </li> </ul> <div class="my-2 my-lg-0"> - {% if user.is_authenticated %} - <ul class="navbar-nav mr-auto"> - <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" - data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span - class="material-icons" style="vertical-align: middle">account_circle</span> - <p - style="display: inline; vertical-align: middle">{{ user.first_name }} {{ user.last_name }}</p> - </a> - <div class="dropdown-menu" aria-labelledby="navbarDropdown"> - <a class="dropdown-item" href="/view_profile/">Profile</a> - <a class="dropdown-item" href="/logout">Logout</a> - </div> - </li> - </ul> - {% else %} - <ul class="navbar-nav mr-auto"> - <li class="nav-item"> - <a class="nav-link" href="/register/">Register</a> - </li> - <li class="nav-item"> - <a class="nav-link" href="/login/">Login</a> - </li> - </ul> - {% endif %} + <ul class="navbar-nav mr-auto"> + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" + data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> + <span class="material-icons" style="vertical-align: middle">account_circle</span> + <p style="display: inline; vertical-align: middle"> + {{user.get_full_name|title}} + </p> + </a> + <div class="dropdown-menu" aria-labelledby="navbarDropdown"> + <a class="dropdown-item" href="/view_profile/">Profile</a> + <a class="dropdown-item" href="/logout">Logout</a> + </div> + </li> + </ul> </div> + {% endif %} </div> </nav> {% endblock %} -{% block content %} - <h1>Base Template Content. Please override me</h1> -{% endblock %} +<div class="base-content"> + {% block content %} + <h1>Base Template Content. Please override me</h1> + {% endblock %} +</div> <script> {% if messages %} diff --git a/workshop_app/templates/workshop_app/login.html b/workshop_app/templates/workshop_app/login.html index 63f2591..fc50ae8 100644 --- a/workshop_app/templates/workshop_app/login.html +++ b/workshop_app/templates/workshop_app/login.html @@ -20,10 +20,21 @@ <br> {{ form.password }} <br> - <button class="btn btn-success btn-md" style="width: 40%" type="submit">Login</button> + <button class="btn btn-success btn-md" style="width: 40%" type="submit"> + Login + </button> <br><br> - <a href="{{ URL_ROOT }}/forgotpassword/" class="btn btn-default btn-sm" - style="color:#3693C0;">Forgot Password</a> + <div class="row"> + <div class="col-md-6"> + <a class="btn btn-info" href="{% url 'register' %}"> + Register + </a> + </div> + <div class="col-md-5"> + <a href="{% url 'password_reset' %}" class="btn btn-outline-primary">Forgot Password? + </a> + </div> + </div> </form> </div> </div> diff --git a/workshop_app/templates/workshop_app/logout.html b/workshop_app/templates/workshop_app/logout.html index 620e67e..316d3dc 100644 --- a/workshop_app/templates/workshop_app/logout.html +++ b/workshop_app/templates/workshop_app/logout.html @@ -9,7 +9,9 @@ <div class="container" align="center"> <br> <h3>You have logged out successfully.</h3> - <h4>If you want to Login again please <a href="{{ URL_ROOT}}/login/">click here</a></h4> + <h4>If you want to login again please + <a href="{% url 'index' %}">click here</a> + </h4> <br> </div> diff --git a/workshop_app/templates/workshop_app/propose_workshop.html b/workshop_app/templates/workshop_app/propose_workshop.html index ec2e8ca..2c87100 100644 --- a/workshop_app/templates/workshop_app/propose_workshop.html +++ b/workshop_app/templates/workshop_app/propose_workshop.html @@ -59,9 +59,8 @@ <div class="container" align="center"> <div class="alert alert-info"> - Please Note: Students have to take a mandatory test before Advanced Python - Workshop only those who will clear this test will be eligible to attend - the workshop. + Note: Before proposing the workshop, please check about the workshop in the + <strong>Workshop Types</strong> section </div> <br><br> <div class="col-md-6 col-md-offset-6"> diff --git a/workshop_app/templates/workshop_app/registration/register.html b/workshop_app/templates/workshop_app/register.html index cd716f4..cd716f4 100644 --- a/workshop_app/templates/workshop_app/registration/register.html +++ b/workshop_app/templates/workshop_app/register.html diff --git a/workshop_app/templates/workshop_app/view_profile.html b/workshop_app/templates/workshop_app/view_profile.html index 31215fe..5cb5c36 100644 --- a/workshop_app/templates/workshop_app/view_profile.html +++ b/workshop_app/templates/workshop_app/view_profile.html @@ -74,8 +74,9 @@ </tr> {% endif %} {% endfor %} + </table> + </div> + <br><br> {% endif %} - </table> - </div> </div> {% endblock %} diff --git a/workshop_app/templates/workshop_app/workshop_details.html b/workshop_app/templates/workshop_app/workshop_details.html index 388b204..723794d 100644 --- a/workshop_app/templates/workshop_app/workshop_details.html +++ b/workshop_app/templates/workshop_app/workshop_details.html @@ -19,8 +19,7 @@ </tr> <tr> <th><label for="id_email">Coordinator :</label></th> - <td><label for="id_email"><a - href="{% url 'view_profile' workshop.coordinator_id %}">{{ workshop.coordinator }}</a></label> + <td><label for="id_email">{{ workshop.coordinator.get_full_name|title }}</label> </td> </tr> {% if workshop.status %} @@ -30,8 +29,7 @@ </tr> <tr> <th><label for="id_phone_number">Instructor :</label></th> - <td><label for="id_email"><a - href="{% url 'view_profile' workshop.instructor_id %}">{{ workshop.instructor }}</a></label> + <td><label for="id_email">{{ workshop.instructor.get_full_name|title }}</label> </td> </tr> {% else %} diff --git a/workshop_app/templates/workshop_app/workshop_status_instructor.html b/workshop_app/templates/workshop_app/workshop_status_instructor.html index 8818fb3..2cb25d9 100644 --- a/workshop_app/templates/workshop_app/workshop_status_instructor.html +++ b/workshop_app/templates/workshop_app/workshop_status_instructor.html @@ -120,12 +120,8 @@ <td>{{ workshop.date | date }}</td> <td><span class="badge badge-warning">{{ workshop.get_status }}</span></td> <td> - <a href="{% url 'accept_workshop' workshop.id %}"> - <button class="btn btn-primary btn-sm" id="book-btn" data-toggle="popover" - title="Please Note" - data-content="Once Accepted you can't Reject, you have to personally contact the Coordinator if the workshop is to be cancelled"> - Accept - </button> + <a href="{% url 'accept_workshop' workshop.id %}" class="btn btn-primary btn-sm" onclick="return confirm('Once accepted you cannot reject, you have to personally contact the Coordinator if the workshop is to be cancelled. Are you sure you want to accept the workshop?')"> + Accept </a> </td> {% endif %} diff --git a/workshop_app/templates/workshop_app/workshop_type_details.html b/workshop_app/templates/workshop_app/workshop_type_details.html index f27e6b3..c2462c7 100644 --- a/workshop_app/templates/workshop_app/workshop_type_details.html +++ b/workshop_app/templates/workshop_app/workshop_type_details.html @@ -14,7 +14,7 @@ </tr> <tr class="d-flex"> <th class="col-3">Duration :</th> - <td class="col">{{ workshop_type.duration }}</td> + <td class="col">{{ workshop_type.duration }} day(s)</td> </tr> <tr class="d-flex"> <th class="col-3">Description :</th> diff --git a/workshop_app/templates/workshop_app/workshop_type_list.html b/workshop_app/templates/workshop_app/workshop_type_list.html index a3d9c6e..3b60656 100644 --- a/workshop_app/templates/workshop_app/workshop_type_list.html +++ b/workshop_app/templates/workshop_app/workshop_type_list.html @@ -1,5 +1,5 @@ {% extends 'workshop_app/base.html' %} - +{% load custom_filters %} {% block title %} View List of available Workshops {% endblock %} @@ -8,7 +8,7 @@ <div class="container"> <h2 class="text-center">Workshop Types</h2> <br> - {% if request.user.profile.position == 'instructor' %} + {% if request.user|has_group:"instructor" %} <a href="{% url 'add_workshop_type' %}"> <button class="btn btn-md btn-primary float-right mb-3 mx-4">Add Workshop Type</button> </a> @@ -31,7 +31,7 @@ <td scope="row" id="{{ forloop.counter }}">{{ forloop.counter }}</td> <td>{{ w.name }}</td> <td>{{ w.duration }}</td> - <td><a href="{{URL_ROOT}}/workshop_type_details/{{ w.id }}" class="btn btn-default btn-sm" class="accordion-toggle" >View Workshop Details</a></td> + <td><a href="{{URL_ROOT}}/workshop_type_details/{{ w.id }}" class="btn btn-outline-info" class="accordion-toggle" >View Workshop Details</a></td> </tr> </tbody> {% endfor %} diff --git a/workshop_app/templatetags/__init__.py b/workshop_app/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/workshop_app/templatetags/__init__.py diff --git a/workshop_app/templatetags/custom_filters.py b/workshop_app/templatetags/custom_filters.py new file mode 100644 index 0000000..5b476d4 --- /dev/null +++ b/workshop_app/templatetags/custom_filters.py @@ -0,0 +1,7 @@ +from django import template
+
+register = template.Library()
+
+@register.filter(name='has_group')
+def has_group(user, group_name):
+ return user.groups.filter(name=group_name).exists()
|