diff --git a/README.md b/README.md index 8db1ed3..0621cfc 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,11 @@ flask app for plurals to publicly share member lists # config -- create `config.py` in the instance folder and customise the following settings to your needs +- create `config.py` in the instance folder and customise the following settings to your needs\ ``` REGISTRATION: False # only set to True if in a development situation, or to create your first user +UPLOAD_FOLDER = '/uploads' +ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'} ``` # usage diff --git a/myriad/manage.py b/myriad/manage.py index 23c19b6..51cdad1 100644 --- a/myriad/manage.py +++ b/myriad/manage.py @@ -1,6 +1,8 @@ from flask import ( Blueprint, flash, g, redirect, render_template, request, session, url_for ) +from werkzeug.utils import secure_filename +import os from myriad.auth import login_required from myriad.db import get_db @@ -28,9 +30,31 @@ def new(): ) db.commit() - - flash(error) - - return redirect(url_for('home.full_list')) + return redirect(url_for('home.full_list')) + + return render_template('manage/new.html', error=error) - return render_template('manage/new.html') \ No newline at end of file + return render_template('manage/new.html') + +@bp.route("/edit/", methods=('GET', 'POST')) +@login_required +def edit(mid): + db = get_db() + member = db.execute("SELECT * FROM member WHERE id=(?)",(mid,)).fetchone() + icons = db.execute("SELECT * FROM icons WHERE member_id=(?)",(mid,)).fetchall() + + if request.method == "POST": + if "name" in request.form: + name = request.form['name'] + bio = request.form['bio'] + subtitle = request.form['subtitle'] + db.execute("UPDATE member SET member_name=(?), bio=(?), subtitle=(?) WHERE id=(?)",(name, bio, subtitle, mid)) + db.commit() + elif "icon" in request.form: + file = request.form["icon"] + filename = secure_filename(file.filename) + file.save("/static/uploads/" + filename) + + return redirect(url_for("home.full_list")) + + return render_template("manage/edit.html", member=member, icons=icons) \ No newline at end of file diff --git a/myriad/schema.sql b/myriad/schema.sql index 9ac8d85..d99536d 100644 --- a/myriad/schema.sql +++ b/myriad/schema.sql @@ -17,7 +17,7 @@ CREATE TABLE member ( user_id INTEGER NOT NULL, created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, member_name TEXT NOT NULL, - subtitle TEXT, + subtitle TEXT DEFAULT "", bio TEXT, main_icon INTEGER, homepage BOOLEAN NOT NULL DEFAULT 0, diff --git a/myriad/templates/full.html b/myriad/templates/full.html index a6267b0..3d7d2db 100644 --- a/myriad/templates/full.html +++ b/myriad/templates/full.html @@ -10,14 +10,14 @@
{{ member[3] }} {{ member[4] }}
- +
{{ member[5] }}

- + {% if g.user %}{% endif %} + +
{% endfor %} diff --git a/myriad/templates/manage/edit.html b/myriad/templates/manage/edit.html new file mode 100644 index 0000000..cd6a598 --- /dev/null +++ b/myriad/templates/manage/edit.html @@ -0,0 +1,35 @@ +{% extends 'base.html' %} + +{% block header %} +
{% block title %}Edit {{ member[3] }}{% endblock %}
+{% endblock %} + +{% block content %} + +
Edit Details
+ +
+ +
+ +
+ +
+ +
+ +
Manage Icons
+
+ + +
+ + {% for icon in icons %} + + + + {% endfor %} + + {{ error }} + +{% endblock %} \ No newline at end of file diff --git a/myriad/templates/manage/new.html b/myriad/templates/manage/new.html index 8b6111b..3b6f122 100644 --- a/myriad/templates/manage/new.html +++ b/myriad/templates/manage/new.html @@ -8,8 +8,13 @@

+ +

+ + {{ error }} + {% endblock %} \ No newline at end of file