Compare commits

..

No commits in common. "98878bda7d68a90752e09e2b989105100cb23630" and "e0e02d54239b78e5640e5dd3430aa549280689c7" have entirely different histories.

4 changed files with 9 additions and 69 deletions

View File

@ -1,7 +1,6 @@
from datetime import date
from flask import flash
from flask_login import UserMixin
from sqlalchemy import func as SQLfunc
from os.path import isfile
from PIL import Image
from app import app, db
@ -78,10 +77,10 @@ class Member(User):
xp = db.Column(db.Integer)
register_date = db.Column(db.Date, default=date.today)
avatar_id = db.Column(db.Integer, default=0)
# Avatars # TODO: rendre ça un peu plus propre
@property
def avatar(self):
return f'{self.id}_{self.avatar_id}.png'
return str(self.id) + '.png'
@property
def level(self):
@ -201,11 +200,6 @@ class Member(User):
size = 128, 128
im = Image.open(avatar)
im.thumbnail(size, Image.ANTIALIAS)
# TODO: verify concurrency behavior
current_id = db.session.query(SQLfunc.max(Member.avatar_id)).first()[0]
self.avatar_id = current_id + 1
db.session.merge(self)
db.session.commit()
im.save(V5Config.AVATARS_FOLDER + self.avatar, 'PNG')
def get_public_data(self):

View File

@ -1,21 +0,0 @@
{% extends "base/base.html" %}
{% import "widgets/editor.html" as widget_editor %}
{% import "widgets/member.html" as widget_member %}
{% import "widgets/pagination.html" as widget_pagination with context %}
{% block title %}
<a href='/forum'>Forum de Planète Casio</a> » <a href="{{ url_for('forum_page', f=t.forum) }}">{{ t.forum.name }}</a> » <h1>{{ t.title }}</h1>
{% endblock %}
{% block content %}
<section>
<h1>Édition du topic {{ t.title }}</h1>
<div class=form>
<h3>Commenter le sujet</h3>
<form action="" method="post" enctype="multipart/form-data">
Un formulaire
</form>
</div>
</section>
{% endblock %}

View File

@ -19,20 +19,16 @@
<table class="thread">
{% for c in comments.items %}
<tr id="{{ c.id }}">
<tr>
{% if c != t.thread.top_comment %}
<td class="member">{{ widget_member.profile(c.author ) }}</td>
<td>
<div>{% if c.date_created != c.date_modified %}
Posté le {{ c.date_created|date }} (Modifié le {{ c.date_modified|date }})
{% else %}
Posté le {{ c.date_created|date }}
{% if c.date_created != c.date_modified %}
Le {{ c.date_created|date }} (Modifié le {{ c.date_modified|date }})
{% elif c.date_created == c.date_modified %}
Le {{ c.date_created|date }}
{% endif %}
| <a href="{{ url_for('forum_topic', f=t.forum, t=t, page=comments.page, _anchor=c.id) }}">#</a>
| <a href="#">Modifier</a>
| <a href="#">Supprimer</a>
</div>
<!--<hr>-->
<hr>
<p>{{ c.text }}</p>
{% elif loop.index0 != 0 %}
<div>Ce message est le top comment</div>
@ -43,7 +39,7 @@
</table>
{{ widget_pagination.paginate(comments, 'forum_topic', {'f': t.forum, 't':t}) }}
<div class=form>
<h3>Commenter le sujet</h3>
<form action="" method="post" enctype="multipart/form-data">

View File

@ -1,29 +0,0 @@
"""Ajout d'un ID d'avatar (#42)
Revision ID: c40b1f0ed821
Revises: c665488fc26e
Create Date: 2019-12-22 14:46:40.598673
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c40b1f0ed821'
down_revision = 'c665488fc26e'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('member', sa.Column('avatar_id', sa.Integer(),
nullable=False, server_default='0'))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('member', 'avatar_id')
# ### end Alembic commands ###