From: Perfectfire33 Date: Sun, 10 Jul 2022 19:03:13 +0000 (-0400) Subject: Updated registration form X-Git-Url: http://openhouseparty.us:13001/gitweb/?a=commitdiff_plain;h=be8df7a001c0ddf18923664b95c568a028060273;p=openhouseparty.online%2F.git Updated registration form --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1e2fba4..cc51bf2 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,12 +2,15 @@ - - + + + + + + - - - + + @@ -350,7 +356,7 @@ - + @@ -598,13 +604,6 @@ - - - - - - - @@ -632,128 +631,135 @@ - + - - + + - + - - + + - + - - - - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - - - - + + - + - - + + - - + + - + - - + + - + - - + + - + - - + + - + - - + + + + + - + - - + + - - + + - - + + + + + + + + + + + + diff --git a/flaskr/__pycache__/admin.cpython-37.pyc b/flaskr/__pycache__/admin.cpython-37.pyc index eab560c..d3003e3 100644 Binary files a/flaskr/__pycache__/admin.cpython-37.pyc and b/flaskr/__pycache__/admin.cpython-37.pyc differ diff --git a/flaskr/__pycache__/blog.cpython-37.pyc b/flaskr/__pycache__/blog.cpython-37.pyc index 2501818..c68f75a 100644 Binary files a/flaskr/__pycache__/blog.cpython-37.pyc and b/flaskr/__pycache__/blog.cpython-37.pyc differ diff --git a/flaskr/admin.py b/flaskr/admin.py index ace01fb..3bbcedb 100644 --- a/flaskr/admin.py +++ b/flaskr/admin.py @@ -31,7 +31,7 @@ def delete_user(): 'DELETE FROM xuser WHERE xuser_id = ?', [request.form['user_to_delete']] ) db.commit() - return redirect(url_for('admin.index')) + return redirect(url_for('admin.get_users')) def get_user(user_id): user = get_db().execute( diff --git a/flaskr/auth.py b/flaskr/auth.py index cfe6af9..69ae9f9 100644 --- a/flaskr/auth.py +++ b/flaskr/auth.py @@ -18,6 +18,9 @@ def register(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] + firstname = request.form['firstname'] + lastname = request.form['lastname'] + email = request.form['email'] db = get_db() error = None @@ -29,8 +32,8 @@ def register(): if error is None: try: db.execute( - "INSERT INTO xuser (xuser_username, xuser_password) VALUES (?, ?)", - (username, generate_password_hash(password)), + "INSERT INTO xuser (xuser_username, xuser_password, xuser_firstname, xuser_lastname, xuser_email) VALUES (?, ?, ?, ?, ?)", + (username, generate_password_hash(password), firstname, lastname, email), ) db.commit() except db.IntegrityError: diff --git a/flaskr/blog.py b/flaskr/blog.py index 1759e5a..3651730 100644 --- a/flaskr/blog.py +++ b/flaskr/blog.py @@ -18,6 +18,10 @@ def index(): ' FROM post p JOIN xuser u ON p.post_author_id = u.xuser_id' ' ORDER BY post_created DESC' ).fetchall() + + #print("AAAAAAAAAAAAAA") + #print(posts[0][4]) + #print("AAAAAAAAAAAAAA") return render_template('blog/index.html', posts=posts) @@ -48,31 +52,51 @@ def create(): #if "file1" not in request.files: # return "there is no file1 in form!" file1 = request.files["file1"] - path = os.path.join(upload_folder, file1.filename) - file1.save(path) - - + if file1.filename != '': + path = os.path.join(upload_folder, file1.filename) + file1.save(path) + + title = request.form['title'] + body = request.form['body'] + error = None + short_body = body[0:100] + + if not title: + error = 'Title is required.' + + if error is not None: + flash(error) + else: + db = get_db() + db.execute( + 'INSERT INTO post (post_title, post_body, post_shortbody, post_images, post_author_id)' + ' VALUES (?, ?, ?, ?, ?)', + (title, body, short_body, file1.filename, g.user['xuser_id']) + ) + db.commit() + return redirect(url_for('blog.index')) - - title = request.form['title'] - body = request.form['body'] - error = None - short_body = body[0:100] - - if not title: - error = 'Title is required.' - - if error is not None: - flash(error) else: - db = get_db() - db.execute( - 'INSERT INTO post (post_title, post_body, post_shortbody, post_images, post_author_id)' - ' VALUES (?, ?, ?, ?, ?)', - (title, body, short_body, file1.filename, g.user['xuser_id']) - ) - db.commit() - return redirect(url_for('blog.index')) + title = request.form['title'] + body = request.form['body'] + error = None + short_body = body[0:100] + + if not title: + error = 'Title is required.' + + if error is not None: + flash(error) + else: + db = get_db() + db.execute( + 'INSERT INTO post (post_title, post_body, post_shortbody, post_author_id)' + ' VALUES (?, ?, ?, ?)', + (title, body, short_body, g.user['xuser_id']) + ) + db.commit() + return redirect(url_for('blog.index')) + return render_template('blog/create.html') @@ -123,6 +147,7 @@ def update(id): title = request.form['title'] body = request.form['body'] error = None + short_body = body[0:100] if not title: error = 'Title is required.' @@ -132,9 +157,9 @@ def update(id): else: db = get_db() db.execute( - 'UPDATE post SET post_title = ?, post_body = ?' + 'UPDATE post SET post_title = ?, post_shortbody = ?, post_body = ?' ' WHERE post_id = ?', - (title, body, id) + (title, body, short_body, id) ) db.commit() return redirect(url_for('blog.index')) diff --git a/flaskr/static/style.css b/flaskr/static/style.css index e2cc153..94669dd 100644 --- a/flaskr/static/style.css +++ b/flaskr/static/style.css @@ -1,4 +1,5 @@ -html { font-family: sans-serif; background: #eee; padding: 1rem; } +/* html { font-family: sans-serif; background: #eee; padding: 1rem; } */ +html { font-family: sans-serif; background: white; padding: 1rem; } /* body { max-width: 960px; margin: 0 auto; background: white; } */ body { max-width: 90%; margin: 0 auto; } /* h1 { font-family: serif; color: #377ba8; margin: 1rem 0; } */ @@ -30,7 +31,7 @@ nav ul li a, nav ul li span, header .action { display: block; padding: 0.5rem; } .content textarea { min-height: 12em; resize: vertical; } input.danger { color: #cc2f2e; } input[type=submit] { align-self: start; min-width: 10em; } -.bottom { background: lightyellow; display: flex; align-items: center; padding: 0 0.5rem; } +.bottom { background: white; display: flex; align-items: center; padding: 0 0.5rem; } .post2 { width: 25%; margin-left: 25%;} p2 {background-color: none; color: black; font-size: 25px; margin-left: 35%; } diff --git a/flaskr/templates/admin/user_list.html b/flaskr/templates/admin/user_list.html index c1c7981..f53f2eb 100644 --- a/flaskr/templates/admin/user_list.html +++ b/flaskr/templates/admin/user_list.html @@ -8,7 +8,7 @@
User Name: {{ user.xuser_username }}
- +
diff --git a/flaskr/templates/auth/register.html b/flaskr/templates/auth/register.html index aaa5458..291efab 100644 --- a/flaskr/templates/auth/register.html +++ b/flaskr/templates/auth/register.html @@ -11,6 +11,12 @@ + + + + + +
diff --git a/flaskr/templates/blog/index.html b/flaskr/templates/blog/index.html index 5c44243..be89c92 100644 --- a/flaskr/templates/blog/index.html +++ b/flaskr/templates/blog/index.html @@ -19,7 +19,9 @@ Edit {% endif %} - + {% if post['post_images'] != None %} + + {% endif %}

{{ post['post_shortbody'] }}

{% if not loop.last %} diff --git a/flaskr/upload/IMG_0524.JPG b/flaskr/upload/IMG_0524.JPG new file mode 100644 index 0000000..d9fc9da Binary files /dev/null and b/flaskr/upload/IMG_0524.JPG differ diff --git a/instance/flaskr.sqlite b/instance/flaskr.sqlite index e39bbdb..3235b5a 100644 Binary files a/instance/flaskr.sqlite and b/instance/flaskr.sqlite differ