Browse Source

Ajouts dans le panel admin

master
Dark-Storm 8 months ago
parent
commit
62729e6058
Signed by: Dark-Storm <l.gatin@neuf.fr> GPG Key ID: F61F10FA138E797C

+ 3
- 1
app/forms/account.py View File

@@ -1,5 +1,5 @@
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, TextAreaField, SubmitField
from wtforms import StringField, PasswordField, BooleanField, TextAreaField, SubmitField, DecimalField
from wtforms.fields.html5 import DateField
from wtforms.validators import DataRequired, Optional, Email, EqualTo
from flask_wtf.file import FileField # Cuz' wtforms' FileField is shitty
@@ -36,6 +36,8 @@ class AdminUpdateAccountForm(FlaskForm):
avatar = FileField('Avatar', validators=[Optional(), vd.avatar])
email = StringField('Adresse Email', validators=[Optional(), Email(), vd.email])
password = PasswordField('Mot de passe :', validators=[Optional(), vd.password])
xp = DecimalField('XP', validators=[Optional()])
innovation = DecimalField('Innovation', validators=[Optional()])
birthday = DateField('Anniversaire', validators=[Optional()])
signature = TextAreaField('Signature', validators=[Optional()])
biography = TextAreaField('Présentation', validators=[Optional()])

+ 5
- 0
app/models/users.py View File

@@ -173,6 +173,11 @@ class Member(User, db.Model):
self.birthday = data["birthday"]
if "newsletter" in data:
self.newsletter = data["newsletter"]
# For admins only
if "xp" in data:
self.xp = data["xp"]
if "innovation" in data:
self.innovation = data["innovation"]

def get_public_data(self):
"""Returns the public information of the member."""

+ 3
- 1
app/routes/admin.py View File

@@ -77,7 +77,9 @@ def adm_edit_account(user_id):
birthday = form.birthday.data,
signature = form.signature.data,
bio = form.biography.data,
newsletter = form.newsletter.data
newsletter = form.newsletter.data,
xp = form.xp.data or None,
innovation = form.innovation.data or None
)
db.session.merge(user)
db.session.commit()

+ 19
- 6
app/static/css/global.css View File

@@ -91,22 +91,35 @@ input[type="checkbox"] {

.bg-green,
.bg-green {
background-color: #149641;
color: #ffffff;
background-color: #149641 !important;
color: #ffffff !important;
}
.bg-green:hover,
.bg-green:focus,
.bg-green:active {
background-color: #0f7331;
background-color: #0f7331 !important;
}

.bg-red,
.bg-red {
background-color: #c0341d;
color: #ffffff;
background-color: #c0341d !important;
color: #ffffff !important;
}
.bg-red:hover,
.bg-red:focus,
.bg-red:active {
background-color: #aa3421;
background-color: #aa3421 !important;
}

.bg-white,
.bg-white {
border: 1px solid #e5e5e5 !important;
background-color: #ffffff !important;
color: #000000 !important;
}
.bg-white:hover,
.bg-white:focus,
.bg-white:active {
background-color: #f0f0f0 !important;
border-color: #e3e3e3 !important;
}

+ 20
- 0
app/templates/admin/edit_account.html View File

@@ -1,6 +1,10 @@
{% extends "base/container.html" %}

{% block content %}
<section class="form">
<a href="{{ url_for('admin') }}" class="button bg-white">Retour à l'administration</a>
</section>

<section class="form">
<h1>Gestion du compte</h1>

@@ -30,6 +34,22 @@
{% endfor %}
</div>

<h2>Participation</h2>
<div>
{{ form.xp.label }}
{{ form.xp(placeholder=user.xp) }}
{% for error in form.xp.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
<div>
{{ form.innovation.label }}
{{ form.innovation(placeholder=user.innovation) }}
{% for error in form.innovation.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>

<h2>À propos</h2>
<div>
{{ form.birthday.label }}

+ 1
- 1
app/templates/admin/index.html View File

@@ -4,7 +4,7 @@
<section>
<form action='' method='POST'>
{{ form.hidden_tag() }}
{{ form.submit }}
{{ form.submit(class="bg-white") }}
</form>

<h2>List of members</h2>

Loading…
Cancel
Save