From 8691421ce3740bbc974bb369e0a5bbbad38daa6b Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sat, 22 Aug 2020 23:23:44 +0200 Subject: [PATCH 1/5] Change cursor on select --- apps/registration/static/registration/login.css | 1 + note_kfet/static/css/custom.css | 1 + 2 files changed, 2 insertions(+) diff --git a/apps/registration/static/registration/login.css b/apps/registration/static/registration/login.css index 77a2f007..607d2de0 100644 --- a/apps/registration/static/registration/login.css +++ b/apps/registration/static/registration/login.css @@ -15,4 +15,5 @@ Font-Awesome attribution is already done inside SVG files #login-form select { -moz-appearance: none; + cursor: pointer; } \ No newline at end of file diff --git a/note_kfet/static/css/custom.css b/note_kfet/static/css/custom.css index 6ad67d9b..cfd42a86 100644 --- a/note_kfet/static/css/custom.css +++ b/note_kfet/static/css/custom.css @@ -41,6 +41,7 @@ select.language { color: #6c757d; -moz-appearance: none; width: auto; + cursor: pointer; } /* Last BDE colors */ From 196f796570453dcf92adcf9a03d4776fdee32b6c Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sat, 22 Aug 2020 23:54:58 +0200 Subject: [PATCH 2/5] Move alias.js to local static --- {note_kfet/static => apps/member/static/member}/js/alias.js | 0 apps/registration/static/registration/{ => css}/login.css | 4 ++-- apps/registration/static/registration/{ => img}/fa-lock.svg | 0 apps/registration/static/registration/{ => img}/fa-user.svg | 0 note_kfet/templates/registration/login.html | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) rename {note_kfet/static => apps/member/static/member}/js/alias.js (100%) rename apps/registration/static/registration/{ => css}/login.css (63%) rename apps/registration/static/registration/{ => img}/fa-lock.svg (100%) rename apps/registration/static/registration/{ => img}/fa-user.svg (100%) diff --git a/note_kfet/static/js/alias.js b/apps/member/static/member/js/alias.js similarity index 100% rename from note_kfet/static/js/alias.js rename to apps/member/static/member/js/alias.js diff --git a/apps/registration/static/registration/login.css b/apps/registration/static/registration/css/login.css similarity index 63% rename from apps/registration/static/registration/login.css rename to apps/registration/static/registration/css/login.css index 607d2de0..b789b2f7 100644 --- a/apps/registration/static/registration/login.css +++ b/apps/registration/static/registration/css/login.css @@ -4,12 +4,12 @@ Font-Awesome attribution is already done inside SVG files */ #login-form input[type="text"] { - background: #fff right 1rem top 50% / 5% no-repeat url('fa-user.svg'); + background: #fff right 1rem top 50% / 5% no-repeat url('../img/fa-user.svg'); padding-right: 3rem; } #login-form input[type="password"] { - background: #fff right 1rem top 50% / 5% no-repeat url('fa-lock.svg'); + background: #fff right 1rem top 50% / 5% no-repeat url('../img/fa-lock.svg'); padding-right: 3rem; } diff --git a/apps/registration/static/registration/fa-lock.svg b/apps/registration/static/registration/img/fa-lock.svg similarity index 100% rename from apps/registration/static/registration/fa-lock.svg rename to apps/registration/static/registration/img/fa-lock.svg diff --git a/apps/registration/static/registration/fa-user.svg b/apps/registration/static/registration/img/fa-user.svg similarity index 100% rename from apps/registration/static/registration/fa-user.svg rename to apps/registration/static/registration/img/fa-user.svg diff --git a/note_kfet/templates/registration/login.html b/note_kfet/templates/registration/login.html index 027c629d..87ccbd3c 100644 --- a/note_kfet/templates/registration/login.html +++ b/note_kfet/templates/registration/login.html @@ -7,7 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later {% block contenttitle %}{% endblock %} {% block extracss %} - + {% endblock %} {% block content %} From 2c1cf148fa2d8c135aef8c1b13549d976f887df7 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sat, 22 Aug 2020 23:55:22 +0200 Subject: [PATCH 3/5] Remove alias_update.html --- .../member/templates/member/alias_update.html | 12 ---------- apps/member/templates/member/club_alias.html | 23 +++++++++++++++---- apps/member/templates/member/club_detail.html | 3 +++ .../templates/member/profile_alias.html | 23 +++++++++++++++---- 4 files changed, 41 insertions(+), 20 deletions(-) delete mode 100644 apps/member/templates/member/alias_update.html diff --git a/apps/member/templates/member/alias_update.html b/apps/member/templates/member/alias_update.html deleted file mode 100644 index d1f6115b..00000000 --- a/apps/member/templates/member/alias_update.html +++ /dev/null @@ -1,12 +0,0 @@ -{% load django_tables2 crispy_forms_tags i18n %} -
- - -
-
-
- {% render_table aliases %} -
-
diff --git a/apps/member/templates/member/club_alias.html b/apps/member/templates/member/club_alias.html index 4b6f2882..86a25b49 100644 --- a/apps/member/templates/member/club_alias.html +++ b/apps/member/templates/member/club_alias.html @@ -1,10 +1,25 @@ {% extends "member/club_detail.html" %} -{% load i18n static pretty_money django_tables2 crispy_forms_tags %} +{% load static django_tables2 i18n %} {% block profile_content %} -{% include "member/alias_update.html" %} +
+

+ {% trans "Note aliases" %} +

+
+
+ +
+ +
+
+
+ {% render_table aliases %} +
{% endblock %} {% block extrajavascript %} - -{% endblock%} + +{% endblock%} \ No newline at end of file diff --git a/apps/member/templates/member/club_detail.html b/apps/member/templates/member/club_detail.html index 451e4d76..d0f479d7 100644 --- a/apps/member/templates/member/club_detail.html +++ b/apps/member/templates/member/club_detail.html @@ -1,5 +1,8 @@ {% extends "member/noteowner_detail.html" %} +{# Use a fluid-width container #} +{% block containertype %}container-fluid{% endblock %} + {% block profile_info %} {% include "member/club_info.html" %} {% endblock %} diff --git a/apps/member/templates/member/profile_alias.html b/apps/member/templates/member/profile_alias.html index eb6e499a..b5d51253 100644 --- a/apps/member/templates/member/profile_alias.html +++ b/apps/member/templates/member/profile_alias.html @@ -1,10 +1,25 @@ {% extends "member/profile_detail.html" %} -{% load i18n static pretty_money django_tables2 crispy_forms_tags %} +{% load static django_tables2 i18n %} {% block profile_content %} -{% include "member/alias_update.html"%} +
+

+ {% trans "Note aliases" %} +

+
+
+ +
+ +
+
+
+ {% render_table aliases %} +
{% endblock %} {% block extrajavascript %} - -{% endblock%} + +{% endblock%} \ No newline at end of file From 342d3910c7062f678d476b8358239f92511c574c Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sun, 23 Aug 2020 00:03:10 +0200 Subject: [PATCH 4/5] Set fluid container on parent template --- apps/member/templates/member/club_detail.html | 17 +++---- .../templates/member/noteowner_detail.html | 46 +++++++++---------- .../templates/member/profile_detail.html | 3 -- 3 files changed, 30 insertions(+), 36 deletions(-) diff --git a/apps/member/templates/member/club_detail.html b/apps/member/templates/member/club_detail.html index d0f479d7..bd6e8399 100644 --- a/apps/member/templates/member/club_detail.html +++ b/apps/member/templates/member/club_detail.html @@ -1,8 +1,5 @@ {% extends "member/noteowner_detail.html" %} -{# Use a fluid-width container #} -{% block containertype %}container-fluid{% endblock %} - {% block profile_info %} {% include "member/club_info.html" %} {% endblock %} @@ -12,10 +9,10 @@ {% endblock %} {% block extrajavascript %} - -{% endblock %} + +{% endblock %} \ No newline at end of file diff --git a/apps/member/templates/member/noteowner_detail.html b/apps/member/templates/member/noteowner_detail.html index d97f723a..4f5f7a1d 100644 --- a/apps/member/templates/member/noteowner_detail.html +++ b/apps/member/templates/member/noteowner_detail.html @@ -1,32 +1,32 @@ {% extends "base.html" %} -{% load static %} -{% load i18n %} +{% load static i18n pretty_money %} {% load render_table from django_tables2 %} -{% load pretty_money %} + +{# Use a fluid-width container #} +{% block containertype %}container-fluid{% endblock %} {% block content %} -
-
- {% block profile_info %} - {% endblock %} -
-
- {% block profile_content %} - {% endblock %} -
+
+
+ {% block profile_info %} + {% endblock %}
+
+ {% block profile_content %} + {% endblock %} +
+
- {% block extra_content %} - {% endblock %} +{% block extra_content %}{% endblock %} {% endblock %} {% block extrajavascript %} - -{% endblock %} + +{% endblock %} \ No newline at end of file diff --git a/apps/member/templates/member/profile_detail.html b/apps/member/templates/member/profile_detail.html index 35728191..297af21c 100644 --- a/apps/member/templates/member/profile_detail.html +++ b/apps/member/templates/member/profile_detail.html @@ -1,8 +1,5 @@ {% extends "member/noteowner_detail.html" %} -{# Use a fluid-width container #} -{% block containertype %}container-fluid{% endblock %} - {% block profile_info %} {% include "member/profile_info.html" %} {% endblock %} From 0ba77fb8f075e8a21f98c77ba150be1ae3c4531d Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sun, 23 Aug 2020 00:33:36 +0200 Subject: [PATCH 5/5] Make alias form a bit more HTML friendly --- apps/member/static/member/js/alias.js | 76 ++++++++++--------- apps/member/templates/member/club_alias.html | 14 ++-- .../templates/member/profile_alias.html | 14 ++-- 3 files changed, 55 insertions(+), 49 deletions(-) diff --git a/apps/member/static/member/js/alias.js b/apps/member/static/member/js/alias.js index cdb21b2b..2d652dde 100644 --- a/apps/member/static/member/js/alias.js +++ b/apps/member/static/member/js/alias.js @@ -1,37 +1,43 @@ +/** + * On form submit, create a new alias + */ +function create_alias (e) { + // Do not submit HTML form + e.preventDefault(); - $("#alias_input").on('keypress',function(e) { - if(e.which == 13) { - $("#alias_submit").click(); - } - }); - - function create_alias(note_id){ - $.post("/api/note/alias/", - { - "csrfmiddlewaretoken": CSRF_TOKEN, - "name": $("#alias_input").val(), - "note": note_id - } - ).done(function(){ - $("#alias_table").load(location.pathname+ " #alias_table"); - addMsg("Alias ajouté","success"); - }) - .fail(function(xhr, textStatus, error){ - errMsg(xhr.responseJSON); - }); + // Get data and send to API + const formData = new FormData(e.target); + $.post("/api/note/alias/", { + "csrfmiddlewaretoken": formData.get("csrfmiddlewaretoken"), + "name": formData.get("name"), + "note": formData.get("note") + }).done(function () { + // Reload table + $("#alias_table").load(location.pathname + " #alias_table"); + addMsg("Alias ajouté", "success"); + }).fail(function (xhr, _textStatus, _error) { + errMsg(xhr.responseJSON); + }); } - // on click of button "delete" , call the API - function delete_button(button_id){ - $.ajax({ - url:"/api/note/alias/"+button_id+"/", - method:"DELETE", - headers: {"X-CSRFTOKEN": CSRF_TOKEN} - }) - .done(function(){ - addMsg('Alias supprimé','success'); - $("#alias_table").load(location.pathname + " #alias_table"); - }) - .fail(function(xhr,textStatus, error){ - errMsg(xhr.responseJSON); - }); - } + +/** + * On click of "delete", delete the alias + * @param Integer button_id Alias id to remove + */ +function delete_button (button_id) { + $.ajax({ + url: "/api/note/alias/" + button_id + "/", + method: "DELETE", + headers: { "X-CSRFTOKEN": CSRF_TOKEN } + }).done(function () { + addMsg('Alias supprimé', 'success'); + $("#alias_table").load(location.pathname + " #alias_table"); + }).fail(function (xhr, _textStatus, _error) { + errMsg(xhr.responseJSON); + }); +} + +$(document).ready(function () { + // Attach event + document.getElementById("form_alias").addEventListener("submit", create_alias); +}) \ No newline at end of file diff --git a/apps/member/templates/member/club_alias.html b/apps/member/templates/member/club_alias.html index 86a25b49..60e2bef0 100644 --- a/apps/member/templates/member/club_alias.html +++ b/apps/member/templates/member/club_alias.html @@ -6,15 +6,15 @@

{% trans "Note aliases" %}

-
-
- +
+
+ {% csrf_token %} + +
- +
-
+
{% render_table aliases %}
diff --git a/apps/member/templates/member/profile_alias.html b/apps/member/templates/member/profile_alias.html index b5d51253..ee2369e4 100644 --- a/apps/member/templates/member/profile_alias.html +++ b/apps/member/templates/member/profile_alias.html @@ -6,15 +6,15 @@

{% trans "Note aliases" %}

-
-
- +
+
+ {% csrf_token %} + +
- +
-
+
{% render_table aliases %}