Browse Source

minor code and style edits

master
Lephe 8 months ago
parent
commit
05b9328888
11 changed files with 41 additions and 40 deletions
  1. +7
    -7
      app/forms/account.py
  2. +8
    -3
      app/routes/admin.py
  3. +1
    -1
      app/static/css/container.css
  4. +9
    -7
      app/static/css/form.css
  5. +2
    -1
      app/static/css/global.css
  6. +3
    -2
      app/static/css/light.css
  7. +1
    -1
      app/static/css/navbar.css
  8. +5
    -13
      app/static/css/responsive.css
  9. +1
    -1
      app/static/css/table.css
  10. +1
    -2
      app/templates/base/footer.html
  11. +3
    -2
      app/utils/validators.py

+ 7
- 7
app/forms/account.py View File

@@ -6,7 +6,7 @@ from flask_wtf.file import FileField # Cuz' wtforms' FileField is shitty
import app.utils.validators as vd

class RegistrationForm(FlaskForm):
username = StringField('Pseudonyme', validators=[DataRequired(), vd.name])
username = StringField('Pseudonyme', validators=[DataRequired(), vd.name_valid, vd.name_available])
email = StringField('Adresse Email', validators=[DataRequired(), Email(), vd.email])
password = PasswordField('Mot de passe', validators=[DataRequired(), vd.password])
password2 = PasswordField('Répéter le mot de passe', validators=[DataRequired(), EqualTo('password')])
@@ -16,8 +16,8 @@ class RegistrationForm(FlaskForm):

class UpdateAccountForm(FlaskForm):
avatar = FileField('Avatar', validators=[Optional(), vd.avatar])
email = StringField('Adresse Email', validators=[Optional(), Email(), vd.email, vd.old_password])
password = PasswordField('Mot de passe :', validators=[Optional(), vd.password, vd.old_password])
email = StringField('Adresse email', validators=[Optional(), Email(), vd.email, vd.old_password])
password = PasswordField('Mot de passe', validators=[Optional(), vd.password, vd.old_password])
password2 = PasswordField('Répéter le mot de passe', validators=[Optional(), EqualTo('password')])
old_password = PasswordField('Mot de passe actuel', validators=[Optional()])
birthday = DateField('Anniversaire', validators=[Optional()])
@@ -33,10 +33,10 @@ class DeleteAccountForm(FlaskForm):


class AdminUpdateAccountForm(FlaskForm):
username = StringField('Pseudonyme', validators=[DataRequired(), vd.name])
username = StringField('Pseudonyme', validators=[Optional(), vd.name_valid])
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])
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()])
@@ -47,4 +47,4 @@ class AdminUpdateAccountForm(FlaskForm):

class AdminDeleteAccountForm(FlaskForm):
delete = BooleanField('Confirmer la suppression', validators=[DataRequired()], description='Attention, cette opération est irréversible !')
submit = SubmitField('Supprimer le compte')
submit = SubmitField('Supprimer le compte')

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

@@ -73,21 +73,26 @@ def adm_groups():

users = Member.query.all()
groups = Group.query.all()

return render('admin/groups_privileges.html', users=users, groups=groups,
form=form)

@app.route('/admin/edit-account/<user_id>', methods=['GET', 'POST'])
@priv_required('edit-account')
def adm_edit_account(user_id):
user = Member.query.filter_by(id=user_id).first()
if not user:
abort(404)
user = Member.query.filter_by(id=user_id).first_or_404()

form = AdminUpdateAccountForm()
if request.method == "POST":
if form.validate_on_submit():
if form.avatar.data:
f = form.avatar.data
f.save("./app/static/"+user.avatar)

newname = form.username.data
names = list(Member.query.filter(Member.id != user.id).values(Member.name))
if newname in names:
raise Exception(f'{data["name"]} is not available')
user.update(
name = form.username.data or None,
email = form.email.data or None,

+ 1
- 1
app/static/css/container.css View File

@@ -24,6 +24,6 @@ section h2 {

section .avatar {
display: block;
border-radius: 100%;
border-radius: 2px;
width: 150px; height: 150px;
}

+ 9
- 7
app/static/css/form.css View File

@@ -1,11 +1,9 @@
.form .avatar {
display: inline-block; vertical-align: middle;
border-radius: 100%;
width: 150px; height: 150px;
}

.form .avatar + input[type="file"] {
display: inline-block; margin-left: 20px;
margin: 16px 0 0 0;
vertical-align: middle;
}

@@ -28,15 +26,19 @@
.form input[type='password'],
.form textarea {
display: block;
width: 100%; padding: 6px 2.5%;
border: 1px solid #abcdef;
width: 100%; padding: 6px 8px;
border: 1px solid #c0c0c0;

/* Transitions when resizing with the mouse produces apparent lag */
transition: all .15s ease, width 0s, height 0s;
}
.form input[type='text']:focus,
.form input[type='email']:focus,
.form input[type='date']:focus,
.form input[type='password']:focus,
.form textarea:focus {
box-shadow: 0 0 4px rgba(0, 102, 255, .9);
border-color: #91bfef;
box-shadow: 0 0 0 3px rgba(87, 143, 228, 0.42);
}

.form input[type="submit"] {
@@ -47,4 +49,4 @@
color: red;
font-weight: 400;
margin-top: 5px;
}
}

+ 2
- 1
app/static/css/global.css View File

@@ -10,6 +10,8 @@

* {
box-sizing: border-box;
/* This transition value is replicated everywhere transitions are customized,
make sure to track them when editing */
transition: .15s ease;
}

@@ -71,7 +73,6 @@ input[type="submit"] {
padding: 6px 10px; border-radius: 2px;
cursor: pointer;
font-family: 'DejaVu Sans', sans-serif; font-weight: 400;
cursor: pointer;
}
input[type="button"]:hover,
input[type="submit"]:hover,

+ 3
- 2
app/static/css/light.css View File

@@ -134,7 +134,7 @@
margin: 5px 0;
}

@media all and (max-width: 550px) {
@media all and (max-width: 549px) {
#light-menu, #spacer-menu {
height: 40px;
}
@@ -188,7 +188,8 @@ header {
}

section {
margin: 10px;
width: unset;
margin: 16px;
}
.home-title {
padding: 10px;

+ 1
- 1
app/static/css/navbar.css View File

@@ -143,7 +143,7 @@ nav a:focus {
width: 42px; vertical-align: middle;
}
#menu h2 img {
width: 64px; border-radius: 50%; vertical-align: middle; margin-right: 10px;
width: 64px; border-radius: 2px; vertical-align: middle; margin-right: 10px;
}
#menu h2 a:hover,
#menu h2 a:focus {

+ 5
- 13
app/static/css/responsive.css View File

@@ -1,28 +1,20 @@
/*
Responsives rules
*/

@media all and (max-width: 1399px) {
body {
body, input {
font-size: 13px;
}

/*header form {
border-bottom: 1px solid #adb0b4;
}*/
header input[type="search"] {
font-size: 14px;
}

#menu li {
font-size: 10px;
font-size: 10px;
}
#menu a {
font-size: 13px;
}
}


@media all and (min-width: 1400px) {
body, input {
font-size: 13px;
@@ -40,13 +32,13 @@
}
}


@media screen and (max-width: 1100px) {
@media screen and (max-width: 1099px) {
.home-pinned-content article:nth-child(5) {
display: none;
}
}
@media screen and (max-width: 800px) {

@media screen and (max-width: 799px) {
.home-pinned-content article:nth-child(4) {
display: none;
}

+ 1
- 1
app/static/css/table.css View File

@@ -12,7 +12,7 @@ table th {
border-color: #d0d0d0;
border-style: solid;
border-width: 1px 0;
padding: 2px;
padding: 2px 6px;
}
table td {
padding: 4px 6px;

+ 1
- 2
app/templates/base/footer.html View File

@@ -1,5 +1,4 @@
<footer>
<p>Planète Casio est un site communautaire non affilié à Casio. Toute reproduction de Planète Casio, même partielle, est interdite.</p>
<p>Planète Casio est un site communautaire non affilié à CASIO. Toute reproduction de Planète Casio, même partielle, est interdite.</p>
<p>Les programmes et autres publications présentes sur Planète Casio restent la propriété de leurs auteurs et peuvent être soumis à des licences ou des copyrights.</p>
<p>CASIO est une marque déposée par CASIO Computer Co., Ltd.</p>
</footer>

+ 3
- 2
app/utils/validators.py View File

@@ -2,10 +2,11 @@ from flask_login import current_user
from wtforms.validators import ValidationError
from app.models.users import User, Member

def name(form, name):
def name_valid(form, name):
if not User.valid_name(name.data):
raise ValidationError("Nom d'utilisateur invalide.")
# last check: do not ask db if useless

def name_available(form, name):
member = Member.query.filter_by(name=name.data).first()
if member is not None:
raise ValidationError('Pseudo indisponible.')

Loading…
Cancel
Save