Browse Source

Merge branch 'tests_ds' of https://git.planet-casio.com/devs/PCv5 into tests_ds

master
lephe 8 months ago
parent
commit
52fba7be4d
4 changed files with 17 additions and 15 deletions
  1. 3
    1
      app/forms.py
  2. 9
    9
      app/routes.py
  3. 5
    5
      app/templates/base/navbar/account.html
  4. BIN
      assets/diagramme_1.dia

+ 3
- 1
app/forms.py View File

@@ -28,6 +28,8 @@ def verify_authentication(form, old_password):
if not current_user.check_password(old_password.data):
raise ValidationError('Mot de passe erroné')

def login_form(f):
pass

class LoginForm(FlaskForm):
username = StringField('Pseudonyme :', validators=[DataRequired()])
@@ -54,4 +56,4 @@ class UpdateAccountForm(FlaskForm):
biography = TextAreaField('Présentation', validators=[Optional()])
newsletter = BooleanField('Inscription à la newsletter', description='Un mail par trimestre environ, pour être prévenu des concours, évènements et nouveautés.')
old_password = PasswordField('Ancien mot de passe :', validators=[DataRequired(), verify_authentication])
submit = SubmitField('Mettre à jour')
submit = SubmitField('Mettre à jour')

+ 9
- 9
app/routes.py View File

@@ -8,14 +8,14 @@ from app.models.users import Member

@app.route('/')
def index():
form = LoginForm()
return render_template('index.html', form=form)
login_form = LoginForm()
return render_template('index.html', login_form=login_form)

@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'GET':
return redirect(url_for('index'))
form = LoginForm()
login_form = LoginForm()
if form.validate_on_submit():
member = Member.query.filter_by(username=form.username.data).first()
if member is None or not member.check_password(form.password.data):
@@ -37,7 +37,7 @@ def account():
if not current_user.is_authenticated:
flash('Veuillez vous authentifier', 'warning')
return redirect(url_for('index'))
form = LoginForm()
login_form = LoginForm()
form2 = UpdateAccountForm()
if request.method == "POST":
if form2.validate_on_submit():
@@ -53,13 +53,13 @@ def account():
flash('Modifications effectuées', 'ok')
else:
flash('Erreur lors de la modification', 'error')
return render_template('account.html', form=form, form2=form2)
return render_template('account.html', login_form=login_form, form2=form2)

@app.route('/register', methods=['GET', 'POST'])
def register():
if current_user.is_authenticated:
return redirect(url_for('index'))
form = LoginForm()
login_form = LoginForm()
form2 = RegistrationForm()
if form2.validate_on_submit():
member = Member(form2.username.data, form2.email.data, form2.password.data)
@@ -69,11 +69,11 @@ def register():
db.session.commit()
flash('Inscription réussie', 'ok')
return redirect(url_for('validation'))
return render_template('register.html', title='Register', form=form, form2=form2)
return render_template('register.html', title='Register', login_form=login_form, form2=form2)

@app.route('/register/validation/')
def validation():
if current_user.is_authenticated :
return redirect(url_for('index'))
form = LoginForm()
return render_template('validation.html', form=form)
login_form = LoginForm()
return render_template('validation.html', login_form=login_form)

+ 5
- 5
app/templates/base/navbar/account.html View File

@@ -50,11 +50,11 @@
Invité
</h2>
<form method="post" action="/login" class="login">
{{ form.hidden_tag() }}
{{ form.username(size=32, placeholder="Identifiant") }}
{{ form.password(size=32, placeholder="Mot de passe") }}
{{ form.submit(class_="bg-green") }}
{{ form.remember_me.label }} {{ form.remember_me() }}
{{ login_form.hidden_tag() }}
{{ login_form.username(size=32, placeholder="Identifiant") }}
{{ login_form.password(size=32, placeholder="Mot de passe") }}
{{ login_form.submit(class_="bg-green") }}
{{ login_form.remember_me.label }} {{ login_form.remember_me() }}
</form>
<hr />
<a href="{{ url_for('register') }}">Mot de passe oublié ?</a>

BIN
assets/diagramme_1.dia View File


Loading…
Cancel
Save