Member templates inherit from member/base.html

This commit is contained in:
Alexandre Iooss 2020-08-25 15:39:57 +02:00
parent 63dc184ce4
commit 2e659c63cd
20 changed files with 192 additions and 203 deletions

View File

@ -4,10 +4,6 @@
{% load i18n %} {% load i18n %}
{% load pretty_money %} {% load pretty_money %}
{% block profile_info %}
{% include "member/club_info.html" %}
{% endblock %}
{% block profile_content %} {% block profile_content %}
{% if additional_fee_renewal %} {% if additional_fee_renewal %}
<div class="alert alert-warning"> <div class="alert alert-warning">

View File

@ -11,24 +11,39 @@ SPDX-License-Identifier: GPL-3.0-or-later
<div class="row mt-4"> <div class="row mt-4">
<div class="col-xl-4"> <div class="col-xl-4">
{% block profile_info %} {% block profile_info %}
{% include "member/profile_info.html" %} {% if user_object %}
{% include "member/includes/profile_info.html" %}
{% elif club %}
{% include "member/includes/club_info.html" %}
{% elif note.club.weiclub %}
{% with club=note.club.weiclub %}
{% include "wei/weiclub_info.html" %}
{% endwith %}
{% elif note.club %}
{% with club=note.club %}
{% include "member/includes/club_info.html" %}
{% endwith %}
{% elif note.user %}
{% with user_object=note.user %}
{% include "member/includes/profile_info.html" %}
{% endwith %}
{% endif %}
{% endblock %} {% endblock %}
</div> </div>
<div class="col-xl-8"> <div class="col-xl-8">
{% block profile_content %} {% block profile_content %}
{% include "member/profile_tables.html" %}
{% endblock %} {% endblock %}
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% block extrajavascript %} {% block extrajavascript %}
{% if object %}
<script> <script>
{% if object %}
function refreshHistory() { function refreshHistory() {
$("#history_list").load("{% url 'member:user_detail' pk=object.pk %} #history_list"); $("#history_list").load("{% url 'member:user_detail' pk=object.pk %} #history_list");
$("#profile_infos").load("{% url 'member:user_detail' pk=object.pk %} #profile_infos"); $("#profile_infos").load("{% url 'member:user_detail' pk=object.pk %} #profile_infos");
} }
{% endif %}
</script> </script>
{% endif %}
{% endblock %} {% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "member/club_detail.html" %} {% extends "member/base.html" %}
{% load static django_tables2 i18n %} {% load static django_tables2 i18n %}
{% block profile_content %} {% block profile_content %}

View File

@ -1,11 +1,47 @@
{% extends "member/base.html" %} {% extends "member/base.html" %}
{% load render_table from django_tables2 %}
{% block profile_info %} {% load i18n perms %}
{% include "member/club_info.html" %}
{% endblock %}
{% block profile_content %} {% block profile_content %}
{% include "member/club_tables.html" %} {% if managers.data %}
<div class="card">
<div class="card-header position-relative" id="clubListHeading">
<a class="font-weight-bold">
<i class="fa fa-users"></i> {% trans "Club managers" %}
</a>
</div>
{% render_table managers %}
</div>
<hr>
{% endif %}
{% if member_list.data %}
<div class="card">
<div class="card-header position-relative" id="clubListHeading">
<a class="stretched-link font-weight-bold" href="{% url 'member:club_members' pk=club.pk %}">
<i class="fa fa-users"></i> {% trans "Club members" %}
</a>
</div>
{% render_table member_list %}
</div>
<hr>
{% endif %}
{% if history_list.data %}
<div class="card">
<div class="card-header position-relative" id="historyListHeading">
<a class="stretched-link font-weight-bold" {% if "note.view_note"|has_perm:club.note %}
href="{% url 'note:transactions' pk=club.note.pk %}" {% endif %}>
<i class="fa fa-euro"></i> {% trans "Transaction history" %}
</a>
</div>
<div id="history_list">
{% render_table history_list %}
</div>
</div>
{% endif %}
{% endblock %} {% endblock %}
{% block extrajavascript %} {% block extrajavascript %}

View File

@ -2,10 +2,6 @@
{% load i18n %} {% load i18n %}
{% load render_table from django_tables2 %} {% load render_table from django_tables2 %}
{% block profile_info %}
{% include "member/club_info.html" %}
{% endblock %}
{% block profile_content %} {% block profile_content %}
<input id="searchbar" type="text" class="form-control" placeholder="Nom/prénom/note ..."> <input id="searchbar" type="text" class="form-control" placeholder="Nom/prénom/note ...">
<div class="form-group"> <div class="form-group">

View File

@ -1,5 +0,0 @@
{% extends "member/club_detail.html" %}
{% block profile_content%}
{% include "member/picture_update.html" %}
{% endblock%}

View File

@ -1,42 +0,0 @@
{% load render_table from django_tables2 %}
{% load i18n %}
{% load perms %}
{% if managers.data %}
<div class="card">
<div class="card-header position-relative" id="clubListHeading">
<a class="font-weight-bold">
<i class="fa fa-users"></i> {% trans "Club managers" %}
</a>
</div>
{% render_table managers %}
</div>
<hr>
{% endif %}
{% if member_list.data %}
<div class="card">
<div class="card-header position-relative" id="clubListHeading">
<a class="stretched-link font-weight-bold" href="{% url 'member:club_members' pk=club.pk %}">
<i class="fa fa-users"></i> {% trans "Club members" %}
</a>
</div>
{% render_table member_list %}
</div>
<hr>
{% endif %}
{% if history_list.data %}
<div class="card">
<div class="card-header position-relative" id="historyListHeading">
<a class="stretched-link font-weight-bold" {% if "note.view_note"|has_perm:club.note %} href="{% url 'note:transactions' pk=club.note.pk %}" {% endif %}>
<i class="fa fa-euro"></i> {% trans "Transaction history" %}
</a>
</div>
<div id="history_list">
{% render_table history_list %}
</div>
</div>
{% endif %}

View File

@ -1,5 +1,5 @@
{% extends "base.html" %} {% extends "member/base.html" %}
{% load i18n static pretty_money django_tables2 %} {% load i18n %}
{% block content %} {% block content %}
<div class="alert alert-info"> <div class="alert alert-info">

View File

@ -1,95 +1,105 @@
{% extends "member/base.html" %}
{% load i18n crispy_forms_tags %} {% load i18n crispy_forms_tags %}
{% block profile_content %} {% block profile_content %}
<div class="text-center"> <div class="card bg-light">
<form method="post" enctype="multipart/form-data" id="formUpload"> <h3 class="card-header text-center">
{% csrf_token %} {{ title }}
{{ form |crispy }} </h3>
</form> <div class="card-body">
</div> <div class="text-center">
<!-- MODAL TO CROP THE IMAGE --> <form method="post" enctype="multipart/form-data" id="formUpload">
<div class="modal fade" id="modalCrop"> {% csrf_token %}
<div class="modal-dialog"> {{ form |crispy }}
<div class="modal-content"> </form>
<div class="modal-body"> </div>
<img src="" id="modal-image" style="max-width: 100%;"> <!-- MODAL TO CROP THE IMAGE -->
</div> <div class="modal fade" id="modalCrop">
<div class="modal-footer"> <div class="modal-dialog">
<div class="btn-group pull-left" role="group"> <div class="modal-content">
<button type="button" class="btn btn-default" id="js-zoom-in"> <div class="modal-body">
<span class="glyphicon glyphicon-zoom-in"></span> <img src="" id="modal-image" style="max-width: 100%;">
</button> </div>
<button type="button" class="btn btn-default js-zoom-out"> <div class="modal-footer">
<span class="glyphicon glyphicon-zoom-out"></span> <div class="btn-group pull-left" role="group">
</button> <button type="button" class="btn btn-default" id="js-zoom-in">
<span class="glyphicon glyphicon-zoom-in"></span>
</button>
<button type="button" class="btn btn-default js-zoom-out">
<span class="glyphicon glyphicon-zoom-out"></span>
</button>
</div>
<button type="button" class="btn btn-default" data-dismiss="modal">Nevermind</button>
<button type="button" class="btn btn-primary js-crop-and-upload">Crop and upload</button>
</div>
</div> </div>
<button type="button" class="btn btn-default" data-dismiss="modal">Nevermind</button>
<button type="button" class="btn btn-primary js-crop-and-upload">Crop and upload</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% block extracss %} {% block extracss %}
<link href="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.6/cropper.min.css" rel="stylesheet"> <link href="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.6/cropper.min.css" rel="stylesheet">
{% endblock %} {% endblock %}
{% block extrajavascript%} {% block extrajavascript%}
<script src="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.6/cropper.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.6/cropper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery-cropper@1.0.1/dist/jquery-cropper.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/jquery-cropper@1.0.1/dist/jquery-cropper.min.js"></script>
<script> <script>
$(function () { $(function () {
/* SCRIPT TO OPEN THE MODAL WITH THE PREVIEW */ /* SCRIPT TO OPEN THE MODAL WITH THE PREVIEW */
$("#id_image").change(function (e) { $("#id_image").change(function (e) {
if (this.files && this.files[0]) { if (this.files && this.files[0]) {
var reader = new FileReader(); var reader = new FileReader();
reader.onload = function (e) { reader.onload = function (e) {
$("#modal-image").attr("src", e.target.result); $("#modal-image").attr("src", e.target.result);
$("#modalCrop").modal("show"); $("#modalCrop").modal("show");
} }
reader.readAsDataURL(this.files[0]); reader.readAsDataURL(this.files[0]);
} }
}); });
/* SCRIPTS TO HANDLE THE CROPPER BOX */ /* SCRIPTS TO HANDLE THE CROPPER BOX */
var $image = $("#modal-image"); var $image = $("#modal-image");
var cropBoxData; var cropBoxData;
var canvasData; var canvasData;
$("#modalCrop").on("shown.bs.modal", function () { $("#modalCrop").on("shown.bs.modal", function () {
$image.cropper({ $image.cropper({
viewMode: 1, viewMode: 1,
aspectRatio: 1/1, aspectRatio: 1 / 1,
minCropBoxWidth: 200, minCropBoxWidth: 200,
minCropBoxHeight: 200, minCropBoxHeight: 200,
ready: function () { ready: function () {
$image.cropper("setCanvasData", canvasData); $image.cropper("setCanvasData", canvasData);
$image.cropper("setCropBoxData", cropBoxData); $image.cropper("setCropBoxData", cropBoxData);
} }
}); });
}).on("hidden.bs.modal", function () { }).on("hidden.bs.modal", function () {
cropBoxData = $image.cropper("getCropBoxData"); cropBoxData = $image.cropper("getCropBoxData");
canvasData = $image.cropper("getCanvasData"); canvasData = $image.cropper("getCanvasData");
$image.cropper("destroy"); $image.cropper("destroy");
}); });
$(".js-zoom-in").click(function () { $(".js-zoom-in").click(function () {
$image.cropper("zoom", 0.1); $image.cropper("zoom", 0.1);
}); });
$(".js-zoom-out").click(function () { $(".js-zoom-out").click(function () {
$image.cropper("zoom", -0.1); $image.cropper("zoom", -0.1);
}); });
/* SCRIPT TO COLLECT THE DATA AND POST TO THE SERVER */ /* SCRIPT TO COLLECT THE DATA AND POST TO THE SERVER */
$(".js-crop-and-upload").click(function () { $(".js-crop-and-upload").click(function () {
var cropData = $image.cropper("getData"); var cropData = $image.cropper("getData");
$("#id_x").val(cropData["x"]); $("#id_x").val(cropData["x"]);
$("#id_y").val(cropData["y"]); $("#id_y").val(cropData["y"]);
$("#id_height").val(cropData["height"]); $("#id_height").val(cropData["height"]);
$("#id_width").val(cropData["width"]); $("#id_width").val(cropData["width"]);
$("#formUpload").submit(); $("#formUpload").submit();
}); });
}); });
</script> </script>
{% endblock %} {% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "member/profile_detail.html" %} {% extends "member/base.html" %}
{% load static django_tables2 i18n %} {% load static django_tables2 i18n %}
{% block profile_content %} {% block profile_content %}

View File

@ -1,4 +1,40 @@
{% extends "member/base.html" %} {% extends "member/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n perms %}
{% block profile_content %}
{% if not object.profile.email_confirmed and "member.change_profile_email_confirmed"|has_perm:user_object.profile %}
<div class="alert alert-warning">
{% trans "This user doesn't have confirmed his/her e-mail address." %}
<a href="{% url "registration:email_validation_resend" pk=user_object.pk %}">
{% trans "Click here to resend a validation link." %}
</a>
</div>
{% endif %}
<div class="card">
<div class="card-header position-relative" id="clubListHeading">
<a class="font-weight-bold">
<i class="fa fa-users"></i> {% trans "View my memberships" %}
</a>
</div>
{% render_table club_list %}
</div>
<hr>
<div class="card">
<div class="card-header position-relative" id="historyListHeading">
<a class="stretched-link font-weight-bold" {% if "note.view_note"|has_perm:user_object.note %}
href="{% url 'note:transactions' pk=user_object.note.pk %}" {% endif %}>
<i class="fa fa-euro"></i> {% trans "Transaction history" %}
</a>
</div>
<div id="history_list">
{% render_table history_list %}
</div>
</div>
{% endblock %}
{% block extrajavascript %} {% block extrajavascript %}
<script> <script>

View File

@ -1,5 +0,0 @@
{% extends "member/profile_detail.html" %}
{% block profile_content%}
{% include "member/picture_update.html" %}
{% endblock%}

View File

@ -1,32 +0,0 @@
{% load render_table from django_tables2 %}
{% load i18n %}
{% load perms %}
{% if not object.profile.email_confirmed and "member.change_profile_email_confirmed"|has_perm:user_object.profile %}
<div class="alert alert-warning">
{% trans "This user doesn't have confirmed his/her e-mail address." %}
<a href="{% url "registration:email_validation_resend" pk=user_object.pk %}">{% trans "Click here to resend a validation link." %}</a>
</div>
{% endif %}
<div class="card">
<div class="card-header position-relative" id="clubListHeading">
<a class="font-weight-bold">
<i class="fa fa-users"></i> {% trans "View my memberships" %}
</a>
</div>
{% render_table club_list %}
</div>
<hr>
<div class="card">
<div class="card-header position-relative" id="historyListHeading">
<a class="stretched-link font-weight-bold" {% if "note.view_note"|has_perm:user_object.note %} href="{% url 'note:transactions' pk=user_object.note.pk %}" {% endif %}>
<i class="fa fa-euro"></i> {% trans "Transaction history" %}
</a>
</div>
<div id="history_list">
{% render_table history_list %}
</div>
</div>

View File

@ -1,11 +1,11 @@
{% extends "base.html" %} {% extends "member/base.html" %}
{% load i18n crispy_forms_tags %} {% load i18n crispy_forms_tags %}
{% comment %} {% comment %}
SPDX-License-Identifier: GPL-3.0-or-later SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %} {% endcomment %}
{% block contenttitle %}{% endblock %} {% block contenttitle %}{% endblock %}
{% block content %} {% block profile_content %}
<div class="card bg-light"> <div class="card bg-light">
<h3 class="card-header text-center"> <h3 class="card-header text-center">
{{ title }} {{ title }}

View File

@ -273,7 +273,7 @@ class PictureUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, FormMixin, Det
class ProfilePictureUpdateView(PictureUpdateView): class ProfilePictureUpdateView(PictureUpdateView):
model = User model = User
template_name = 'member/profile_picture_update.html' template_name = 'member/picture_update.html'
context_object_name = 'user_object' context_object_name = 'user_object'
@ -452,7 +452,7 @@ class ClubPictureUpdateView(PictureUpdateView):
Update the profile picture of a club. Update the profile picture of a club.
""" """
model = Club model = Club
template_name = 'member/club_picture_update.html' template_name = 'member/picture_update.html'
context_object_name = 'club' context_object_name = 'club'
def get_success_url(self): def get_success_url(self):

View File

@ -2,22 +2,6 @@
{% load render_table from django_tables2 %} {% load render_table from django_tables2 %}
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% block profile_info %}
{% if note.club.weiclub %}
{% with club=note.club.weiclub %}
{% include "wei/weiclub_info.html" %}
{% endwith %}
{% elif note.club %}
{% with club=note.club %}
{% include "member/club_info.html" %}
{% endwith %}
{% elif note.user %}
{% with user_object=note.user %}
{% include "member/profile_info.html" %}
{% endwith %}
{% endif %}
{% endblock %}
{% block profile_content %} {% block profile_content %}
{% crispy form %} {% crispy form %}
{% endblock %} {% endblock %}

View File

@ -21,7 +21,7 @@ class AmountInput(NumberInput):
class Autocomplete(TextInput): class Autocomplete(TextInput):
template_name = "member/autocomplete_model.html" template_name = "autocomplete_model.html"
def __init__(self, model, resetable=False, attrs=None): def __init__(self, model, resetable=False, attrs=None):
super().__init__(attrs) super().__init__(attrs)