Compare commits

...

6 Commits

Author SHA1 Message Date
Kostanjevec 64e0c7740d cleanup? 2022-06-15 11:22:41 +02:00
Kostanjevec 4be9665006 added placeholder empty string for settings until implemented 2022-06-15 11:22:09 +02:00
Kostanjevec ba20635544 added email and setings field for user 2022-06-15 11:21:31 +02:00
Kostanjevec 4f299ea07f added access key for share 2022-06-15 11:10:49 +02:00
Kostanjevec cb8492f3ec added email form 2022-06-15 11:10:05 +02:00
Kostanjevec 298fc96624 bug found 2022-06-15 11:09:07 +02:00
6 changed files with 21 additions and 14 deletions

View File

@ -1,3 +1,4 @@
import email
import functools
import imp
@ -18,18 +19,24 @@ def register():
if request.method == 'POST':
username = request.form['username']
password = request.form['password']
mail = request.form['email']
error = None
#@TODO check if this really is an email.
if not username:
error = 'Username is required.'
elif not password:
error = 'Password is required.'
elif not mail:
error = 'Please enter your email adress'
elif dbsession.query(User).filter(User.username == username).first() != None:
error = "Username already exists, please choose another one"
elif dbsession.query(User).filter(User.email == mail).first() != None:
error = "This email adress is already in use, please choose another one"
if error is None:
try:
user = User(username=username, password=md5(password.encode("utf-8")).hexdigest())
user = User(username=username, password=md5(password.encode("utf-8")).hexdigest(), email=mail, settings = "")
dbsession.add(user)
dbsession.commit()
dbsession.close()

View File

@ -24,10 +24,8 @@ class User(Base):
id = Column(Integer, primary_key=True, autoincrement=True)
username = Column(String(64))
password = Column(String(64))
# email = Column(String)
# config
# deck_size = Column(Integer)
email = Column(Text)
settings = Column(Text) #neki json...
class Card(Base):
__tablename__ = 'card'

View File

@ -30,6 +30,7 @@ def get_matches(user_id):
@bp.route("/", methods=("GET", "POST"))
def index():
#@TODO its buggs, not symetrical for users, shouldnt show if only you said yes
if not 'user_id' in session:
redirect(url_for('index'))
@ -40,7 +41,6 @@ def index():
list_of_matches = get_matches(user_id)
#@TODO tu bi morali dodati še nek users object, da own_id pretvorimo v username
#relevant userids, but might be uselessly duplicated
user_ids = []
for match in list_of_matches:
@ -52,6 +52,6 @@ def index():
for id in user_ids:
names_by_ids[id] = users.get(id).username
names_by_ids[id] = users.get(id).username
return render_template("matches.html", username=username, list_of_matches=list_of_matches, names_by_ids=names_by_ids)
return render_template("matches.html", username=username, list_of_matches=list_of_matches, names_by_ids=names_by_ids, users=users)

View File

@ -10,6 +10,8 @@
<input name="username" id="username" required>
<label for="password">Password</label>
<input type="password" name="password" id="password" required>
<label for="email">Email</label>
<input type="email" name="email" id="email" required>
<input type="submit" value="Register">
</form>
{% endblock %}

View File

@ -18,7 +18,7 @@
<button type="submit" name="rate" value="No" accesskey="3">No</button>
<button type="submit" name="rate" value="Delete" accesskey="d">Delete</button>
<button style="margin-top: 1rem" type="submit" name="share" value="share">Share</button>
<button style="margin-top: 1rem" type="submit" name="share" value="share" accesskey="s">Share</button>
</form>
</article>

View File

@ -2,11 +2,11 @@
{% block header %}
<head>Matches</head>
{% endblock %}
{% block content %}
{% if list_of_matches %}
<table>
{% endblock %}
{% block content %}
{% if list_of_matches %}
table>
<tr>
<th>Title</th>
<th>Users</th>