소스 검색

Modification de la fonction render

- Ajout d'un modificateur pour changer les feuilles de style à la volée
pull/12/head
Dark-Storm 6 달 전
부모
커밋
d482d1a6fb
로그인 계정: Dark-Storm <l.gatin@neuf.fr> GPG Key ID: F61F10FA138E797C
6개의 변경된 파일172개의 추가작업 그리고 91개의 파일을 삭제
  1. 2
    1
      app/routes/admin.py
  2. 59
    0
      app/static/css/admin/form.css
  3. 82
    77
      app/templates/admin/edit_account.html
  4. 2
    2
      app/templates/base/base.html
  5. 3
    9
      app/templates/base/head.html
  6. 24
    2
      app/utils/render.py

+ 2
- 1
app/routes/admin.py 파일 보기

@@ -106,11 +106,12 @@ def adm_edit_account(user_id):
)
db.session.merge(user)
db.session.commit()
# TODO: send an email to member saying his account has been modified
flash('Modifications effectuées', 'ok')
else:
flash('Erreur lors de la modification', 'error')

return render('admin/edit_account.html', user=user, form=form)
return render('admin/edit_account.html', user=user, form=form, styles=['-css/form.css'])

@app.route('/admin/edit-account/<user_id>/delete', methods=['GET', 'POST'])
@priv_required('delete-account')

+ 59
- 0
app/static/css/admin/form.css 파일 보기

@@ -0,0 +1,59 @@
.form .avatar {
width: 128px; height: 128px;
}

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

.form form > div:not(:last-child) {
margin-bottom: 15px;
}

.form form label {
display: inline-block;
margin-bottom: 5px;
}

.form input {
cursor: pointer; /* don't know why it is not a cursor by default */
}

.form input[type='text'],
.form input[type='email'],
.form input[type='date'],
.form input[type='password'],
.form input[type='search'],
.form textarea {
display: block;
width: 100%; padding: 6px 8px;
border: 1px solid #c8c8c8;

/* 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 input[type='search']:focus,
.form textarea:focus {
border-color: #91bfef;
box-shadow: 0 0 0 3px rgba(87, 143, 228, 0.4);
}

.form textarea {
max-width: 100%;
resize: vertical;
}

.form input[type="submit"] {
/*width: 20%;*/
}

.form form .msgerror {
color: red;
font-weight: 400;
margin-top: 5px;
}

+ 82
- 77
app/templates/admin/edit_account.html 파일 보기

@@ -8,85 +8,90 @@
<section class="form">
<form action="{{ url_for('adm_edit_account', user_id=user.id) }}" method="post" enctype="multipart/form-data">
{{ form.hidden_tag() }}

<h2>Général</h2>
<div>
{{ form.avatar.label }}
<fieldset>
<legend>Général</legend>
<div style="float:left;">
{{ form.avatar.label }}
<div>
<img class="avatar" src="{{ url_for('static', filename=user.avatar) }}" meta="{{ user.avatar }}" />
{{ form.avatar }}
</div>
</div>
<div>
<img class="avatar" src="{{ url_for('static', filename=user.avatar) }}" meta="{{ user.avatar }}" />
{{ form.avatar }}
{{ form.username.label }}
{{ form.username(placeholder=user.name) }}
{% for error in form.username.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
</div>
<div>
{{ form.username.label }}
{{ form.username(placeholder=user.name) }}
{% for error in form.username.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
<div>
{{ form.email.label }}
{{ form.email(placeholder=user.email) }}
{% for error in form.email.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
<div>
{{ form.password.label }}
{{ form.password(placeholder='************') }}
{% for error in form.password.errors %}
<span class="msgerror">{{ error }}</span>
{% 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 }}
{{ form.birthday(value=user.birthday) }}
{% for error in form.birthday.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
<div>
{{ form.signature.label }}
<textarea id="{{ form.signature.name }}" name="{{ form.signature.name }}">{{ user.signature }}</textarea>
{% for error in form.signature.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
<div>
{{ form.biography.label }}
<textarea id="{{ form.biography.name }}" name="{{ form.biography.name }}">{{ user.bio }}</textarea>
{% for error in form.biography.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>

<h2>Préférences</h2>
<div>
{{ form.newsletter.label }}
{{ form.newsletter(checked=user.newsletter) }}
<div style="font-size:80%;color:rgba(0,0,0,.5)">{{ form.newsletter.description }}</div>
{% for error in form.newsletter.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
<div>
{{ form.email.label }}
{{ form.email(placeholder=user.email) }}
{% for error in form.email.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
<div>
{{ form.password.label }}
{{ form.password(placeholder='************') }}
{% for error in form.password.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
<div>{{ form.submit(class_="bg-green") }}</div>
</fieldset>
<fieldset>
<legend>Participation</legend>
<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>
</fieldset>
<fieldset>
<legend>À propos</legend>
<div>
{{ form.birthday.label }}
{{ form.birthday(value=user.birthday) }}
{% for error in form.birthday.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
<div>
{{ form.signature.label }}
<textarea id="{{ form.signature.name }}" name="{{ form.signature.name }}">{{ user.signature }}</textarea>
{% for error in form.signature.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
<div>
{{ form.biography.label }}
<textarea id="{{ form.biography.name }}" name="{{ form.biography.name }}">{{ user.bio }}</textarea>
{% for error in form.biography.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
</fieldset>
<fieldset>
<legend>Préférences</legend>
<div>
{{ form.newsletter.label }}
{{ form.newsletter(checked=user.newsletter) }}
<div style="font-size:80%;color:rgba(0,0,0,.5)">{{ form.newsletter.description }}</div>
{% for error in form.newsletter.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
</fieldset>
<div>{{ form.submit(class_="bg-green") }}</div>
</form>


+ 2
- 2
app/templates/base/base.html 파일 보기

@@ -8,8 +8,8 @@
<div class=container>
<header>
<div class=title>{% block title %}<h1>Planète Casio</h1>{% endblock %}</div>
{% include "base/header.html" %}
</header>
{% include "base/header.html" %}
</header>

{% block content %}
{% endblock %}

+ 3
- 9
app/templates/base/head.html 파일 보기

@@ -4,14 +4,8 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" type="text/css" href={{url_for('static', filename = 'css/global.css')}}>
<link rel="stylesheet" type="text/css" href={{url_for('static', filename = 'css/navbar.css')}}>
<link rel="stylesheet" type="text/css" href={{url_for('static', filename = 'css/header.css')}}>
<link rel="stylesheet" type="text/css" href={{url_for('static', filename = 'css/container.css')}}>
<link rel="stylesheet" type="text/css" href={{url_for('static', filename = 'css/form.css')}}>
<link rel="stylesheet" type="text/css" href={{url_for('static', filename = 'css/footer.css')}}>
<link rel="stylesheet" type="text/css" href={{url_for('static', filename = 'css/flash.css')}}>
<link rel="stylesheet" type="text/css" href={{url_for('static', filename = 'css/responsive.css')}}>
<link rel="stylesheet" type="text/css" href={{url_for('static', filename = 'css/table.css')}}>
{% for s in styles %}
<link rel="stylesheet" type="text/css" href={{url_for('static', filename = s)}}>
{% endfor %}
<link rel="stylesheet" media="all and (max-width: 699px)" type="text/css" href={{url_for('static', filename = 'css/light.css')}}>
</head>

+ 24
- 2
app/utils/render.py 파일 보기

@@ -2,13 +2,35 @@ from flask import render_template
from app.forms.login import LoginForm
from app.forms.search import SearchForm

def render(*args, **kwargs):
def render(*args, styles=None, **kwargs):
# TODO: debugguer cette merde : au logout, ça foire
# if current_user.is_authenticated:
# login_form = LoginForm()
# return render_template(*args, **kwargs, login_form=login_form)
# return render_template(*args, **kwargs)

# Pour jouer sur les feuilles de style :
# render('page.html', styles=['-css/form.css', '+css/admin/forms.css'])

styles_= [
'css/global.css',
'css/navbar.css',
'css/header.css',
'css/container.css',
'css/form.css',
'css/footer.css',
'css/flash.css',
'css/responsive.css',
'css/table.css'
]
for s in styles:
print(s[1:])
if s[0] == '-':
styles_.remove(s[1:])
if s[0] == '+':
styles_.append(s[1:])

login_form = LoginForm()
search_form = SearchForm()
return render_template(*args, **kwargs,
login_form=login_form, search_form=search_form)
login_form=login_form, search_form=search_form, styles=styles_)

Loading…
취소
저장