From aedc9ad80d06e423783bd8986f7f9c68e557173f Mon Sep 17 00:00:00 2001 From: JimJeon Date: Wed, 2 Mar 2016 01:51:25 +0900 Subject: [PATCH 01/13] issue #44 updated withdraw_member function Conflicts: templates/_profile_manage.html user.py --- user.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/user.py b/user.py index e076789..fb08076 100644 --- a/user.py +++ b/user.py @@ -26,6 +26,7 @@ def add_routes(app): app.route('/logout/')(logout) app.route('/api/check_pwd/', methods=["POST"])(check_password) app.route('/manage/password/', methods=["GET", "POST"])(change_password) + app.route('//manage/leave/')(withdraw_member) def register(): @@ -219,3 +220,16 @@ def change_password(): db.session.commit() return redirect('/%s/' % username) + + +def withdraw_member(link): + """ issue #44 회원탈퇴 """ + found = User.query.filter( + User.username == link, + ).first() + + db.session.delete(found) + db.session.commit() + session.pop('username', None) + + return redirect('/') From e7ebefc21dcb7a62825768bfd0d898af6e23f738 Mon Sep 17 00:00:00 2001 From: JimJeon Date: Thu, 3 Mar 2016 22:25:22 +0900 Subject: [PATCH 02/13] withdrawal function updated Conflicts: user.py --- app.py | 2 +- templates/_includes/manager/photo.html | 2 +- templates/manager.html | 12 +++++- user.py | 56 ++++++++++++++++++++++++-- 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index f823ac6..3c25307 100644 --- a/app.py +++ b/app.py @@ -62,4 +62,4 @@ def _set_global_variable_for_templates(): if __name__ == "__main__": - app.run(debug=True, host="0.0.0.0") + app.run(debug=True, host="0.0.0.0", port=7000) diff --git a/templates/_includes/manager/photo.html b/templates/_includes/manager/photo.html index ac69c6a..9fbe8e0 100644 --- a/templates/_includes/manager/photo.html +++ b/templates/_includes/manager/photo.html @@ -1,5 +1,5 @@
- File to upload:
+ File to upload:

diff --git a/templates/manager.html b/templates/manager.html index b5ef124..43ce2d1 100644 --- a/templates/manager.html +++ b/templates/manager.html @@ -55,9 +55,19 @@ + {% if manager__right_html_for_menu == "_includes/manager/withdrawal.html" %} + + {% else %} + + {% endif %} + + + diff --git a/user.py b/user.py index fb08076..809da9f 100644 --- a/user.py +++ b/user.py @@ -11,8 +11,14 @@ from db import ( db, User, + URL, + Photo, + Nickname, + NickRecom, N, ) + + from url import addURL @@ -26,7 +32,7 @@ def add_routes(app): app.route('/logout/')(logout) app.route('/api/check_pwd/', methods=["POST"])(check_password) app.route('/manage/password/', methods=["GET", "POST"])(change_password) - app.route('//manage/leave/')(withdraw_member) + app.route('//manage/withdrawal/')(withdraw_member) def register(): @@ -224,12 +230,56 @@ def change_password(): def withdraw_member(link): """ issue #44 회원탈퇴 """ + + username = get_logged_in_username() + found = User.query.filter( - User.username == link, + User.username == username, ).first() db.session.delete(found) + + while True: + found = URL.query.filter( + URL.username == username, + ).first() + + if found: + db.session.delete(found) + else: + break; + + while True: + found = Photo.query.filter( + Photo.username == username, + ).first() + + if found: + db.session.delete(found) + else: + break; + + while True: + found = NickRecom.query.filter( + NickRecom.username == username, + ).first() + + if found: + db.session.delete(found) + else: + break; + + while True: + found = Nickname.query.filter( + Nickname.username == username, + ).first() + + if found: + db.session.delete(found) + else: + break; + db.session.commit() - session.pop('username', None) + session.pop('username', None) return redirect('/') From 3eb6bd89ba4940c7e7c7e3c2d81ffe472fefd2c8 Mon Sep 17 00:00:00 2001 From: JimJeon Date: Thu, 3 Mar 2016 22:51:58 +0900 Subject: [PATCH 03/13] Issue #44 withdrawl complete! --- templates/_includes/manager/withdrawal.html | 1 + templates/_profile_manage_temp.html | 91 +++++++++++++++++++++ user.py | 18 ++-- 3 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 templates/_includes/manager/withdrawal.html create mode 100644 templates/_profile_manage_temp.html diff --git a/templates/_includes/manager/withdrawal.html b/templates/_includes/manager/withdrawal.html new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/templates/_includes/manager/withdrawal.html @@ -0,0 +1 @@ + diff --git a/templates/_profile_manage_temp.html b/templates/_profile_manage_temp.html new file mode 100644 index 0000000..86acfc0 --- /dev/null +++ b/templates/_profile_manage_temp.html @@ -0,0 +1,91 @@ +{% extends "_main.html" %} +{% block content %} + +{% endblock %} diff --git a/user.py b/user.py index 809da9f..09e6574 100644 --- a/user.py +++ b/user.py @@ -18,6 +18,7 @@ N, ) +from os import remove from url import addURL @@ -249,15 +250,14 @@ def withdraw_member(link): else: break; - while True: - found = Photo.query.filter( - Photo.username == username, - ).first() - - if found: - db.session.delete(found) - else: - break; + found = Photo.query.filter( + Photo.username == username, + ).first() + filename = found.filename + if found: + db.session.delete(found) + + os.remove("./DOWNLOADED/" % filename) while True: found = NickRecom.query.filter( From f53d54d123b94d27125c263ed28cbf34d9116bf1 Mon Sep 17 00:00:00 2001 From: JimJeon Date: Fri, 4 Mar 2016 10:09:00 +0900 Subject: [PATCH 04/13] issue #44 error fixed --- user.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/user.py b/user.py index 09e6574..c896ef4 100644 --- a/user.py +++ b/user.py @@ -17,8 +17,8 @@ NickRecom, N, ) - -from os import remove + +import os from url import addURL @@ -253,11 +253,13 @@ def withdraw_member(link): found = Photo.query.filter( Photo.username == username, ).first() - filename = found.filename + + filename = found.photo + if found: db.session.delete(found) - os.remove("./DOWNLOADED/" % filename) + os.remove("./DOWNLOADED/%s" % filename) while True: found = NickRecom.query.filter( From db8f84a2e2b4aeb69fec35ab2d911e8bf221689f Mon Sep 17 00:00:00 2001 From: JimJeon Date: Fri, 4 Mar 2016 10:22:48 +0900 Subject: [PATCH 05/13] issue #44 do not execute deletion when file does not exsit --- user.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/user.py b/user.py index c896ef4..9b82656 100644 --- a/user.py +++ b/user.py @@ -254,12 +254,10 @@ def withdraw_member(link): Photo.username == username, ).first() - filename = found.photo - if found: db.session.delete(found) - - os.remove("./DOWNLOADED/%s" % filename) + filename = found.photo + os.remove("./DOWNLOADED/%s" % filename) while True: found = NickRecom.query.filter( From 72705ffbc02b592695e42ada4bad42086babd743 Mon Sep 17 00:00:00 2001 From: JimJeon Date: Fri, 4 Mar 2016 20:05:22 +0900 Subject: [PATCH 06/13] issue #44 ./DOWNLOADS --> UPLOADED_PHOTO --- user.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/user.py b/user.py index 9b82656..51c1e13 100644 --- a/user.py +++ b/user.py @@ -1,10 +1,11 @@ from datetime import datetime from flask import ( + current_app, render_template, - session, request, redirect, + session, ) from flask.ext.bcrypt import Bcrypt @@ -257,7 +258,11 @@ def withdraw_member(link): if found: db.session.delete(found) filename = found.photo - os.remove("./DOWNLOADED/%s" % filename) + os.remove("%s%s" % ( + current_app.config['UPLOAD_FOLDER'], + filename, + ) + ) while True: found = NickRecom.query.filter( From cfff36a11da9086b9f62486f15a97e0468258d97 Mon Sep 17 00:00:00 2001 From: JMG Date: Fri, 4 Mar 2016 22:06:50 +0900 Subject: [PATCH 07/13] =?UTF-8?q?Issue=20#40=20=ED=9A=8C=EC=9B=90=ED=83=88?= =?UTF-8?q?=ED=87=B4=EA=B8=B0=EB=8A=A5=20=EC=88=98=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 2 +- templates/_profile_manage_temp.html | 91 ----------------------------- user.py | 55 ++++++----------- 3 files changed, 20 insertions(+), 128 deletions(-) delete mode 100644 templates/_profile_manage_temp.html diff --git a/app.py b/app.py index 3c25307..f823ac6 100644 --- a/app.py +++ b/app.py @@ -62,4 +62,4 @@ def _set_global_variable_for_templates(): if __name__ == "__main__": - app.run(debug=True, host="0.0.0.0", port=7000) + app.run(debug=True, host="0.0.0.0") diff --git a/templates/_profile_manage_temp.html b/templates/_profile_manage_temp.html deleted file mode 100644 index 86acfc0..0000000 --- a/templates/_profile_manage_temp.html +++ /dev/null @@ -1,91 +0,0 @@ -{% extends "_main.html" %} -{% block content %} - -{% endblock %} diff --git a/user.py b/user.py index 51c1e13..c630561 100644 --- a/user.py +++ b/user.py @@ -232,59 +232,42 @@ def change_password(): def withdraw_member(link): """ issue #44 회원탈퇴 """ - username = get_logged_in_username() - found = User.query.filter( User.username == username, ).first() - db.session.delete(found) - - while True: - found = URL.query.filter( - URL.username == username, - ).first() - if found: - db.session.delete(found) - else: - break; - + found = URL.query.filter( + URL.username == username, + ).all() + for url in found: + db.session.delete(url) + found = Photo.query.filter( Photo.username == username, ).first() - if found: - db.session.delete(found) filename = found.photo - os.remove("%s%s" % ( - current_app.config['UPLOAD_FOLDER'], + db.session.delete(found) + os.remove(os.path.join( + current_app.config['UPLOAD_FOLDER'], filename, ) ) - while True: - found = NickRecom.query.filter( - NickRecom.username == username, - ).first() - - if found: - db.session.delete(found) - else: - break; + found = NickRecom.query.filter( + NickRecom.username == username, + ).all() + for nickrecomm in found: + db.session.delete(nickrecomm) - while True: - found = Nickname.query.filter( - Nickname.username == username, - ).first() - - if found: - db.session.delete(found) - else: - break; + found = Nickname.query.filter( + Nickname.username == username, + ).all() + for nickname in found: + db.session.delete(nickname) db.session.commit() - session.pop('username', None) return redirect('/') From 8d196e0b9b8a5b74375039f771c1f9cc7e40163d Mon Sep 17 00:00:00 2001 From: JimJeon Date: Sat, 5 Mar 2016 01:29:24 +0900 Subject: [PATCH 08/13] =?UTF-8?q?issue=20#44=20=EC=A3=BC=EC=84=9D=EB=8B=AC?= =?UTF-8?q?=EA=B8=B0=EC=9A=B4=EB=8F=99=EB=B3=B8=EB=B6=80!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Conflicts: user.py --- user.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/user.py b/user.py index c630561..ab290c6 100644 --- a/user.py +++ b/user.py @@ -232,18 +232,22 @@ def change_password(): def withdraw_member(link): """ issue #44 회원탈퇴 """ + + # User DB 삭제 username = get_logged_in_username() found = User.query.filter( User.username == username, ).first() db.session.delete(found) + # URL DB 삭제 found = URL.query.filter( URL.username == username, ).all() for url in found: db.session.delete(url) - + + # Photo DB 삭제 found = Photo.query.filter( Photo.username == username, ).first() @@ -256,6 +260,7 @@ def withdraw_member(link): ) ) + # NickRecom DB 삭제 found = NickRecom.query.filter( NickRecom.username == username, ).all() @@ -268,6 +273,9 @@ def withdraw_member(link): for nickname in found: db.session.delete(nickname) + # DB commit db.session.commit() + + # Logout session.pop('username', None) return redirect('/') From 221f90d90fe0edf79b06b080d239fdff96b8f00a Mon Sep 17 00:00:00 2001 From: JimJeon Date: Sat, 5 Mar 2016 01:54:38 +0900 Subject: [PATCH 09/13] issue #44 fixes and comments Conflicts: user.py --- templates/_includes/manager/withdrawal.html | 1 - user.py | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) delete mode 100644 templates/_includes/manager/withdrawal.html diff --git a/templates/_includes/manager/withdrawal.html b/templates/_includes/manager/withdrawal.html deleted file mode 100644 index 8b13789..0000000 --- a/templates/_includes/manager/withdrawal.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/user.py b/user.py index ab290c6..14f3fae 100644 --- a/user.py +++ b/user.py @@ -232,7 +232,6 @@ def change_password(): def withdraw_member(link): """ issue #44 회원탈퇴 """ - # User DB 삭제 username = get_logged_in_username() found = User.query.filter( @@ -248,6 +247,12 @@ def withdraw_member(link): db.session.delete(url) # Photo DB 삭제 + found = URL.query.filter( + URL.username == username, + ).all() + for url in found: + db.session.delete(url) + found = Photo.query.filter( Photo.username == username, ).first() From e300fafdc2904f28f312be5af6d041a75980b32f Mon Sep 17 00:00:00 2001 From: JimJeon Date: Sat, 5 Mar 2016 02:00:38 +0900 Subject: [PATCH 10/13] issue #44 fixes and comments Conflicts: user.py --- user.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/user.py b/user.py index 14f3fae..fb0814f 100644 --- a/user.py +++ b/user.py @@ -241,37 +241,31 @@ def withdraw_member(link): # URL DB 삭제 found = URL.query.filter( - URL.username == username, - ).all() - for url in found: - db.session.delete(url) - - # Photo DB 삭제 - found = URL.query.filter( - URL.username == username, + URL.username == username, ).all() for url in found: db.session.delete(url) + # Photo DB 삭제 found = Photo.query.filter( Photo.username == username, ).first() if found: - filename = found.photo db.session.delete(found) os.remove(os.path.join( current_app.config['UPLOAD_FOLDER'], - filename, + found.photo, ) ) # NickRecom DB 삭제 found = NickRecom.query.filter( - NickRecom.username == username, + NickRecom.username == username, ).all() for nickrecomm in found: db.session.delete(nickrecomm) + # Nickname DB 삭제 found = Nickname.query.filter( Nickname.username == username, ).all() From 7c9a0525a732685636704318155ab758b3ae3e88 Mon Sep 17 00:00:00 2001 From: JimJeon Date: Sat, 5 Mar 2016 03:08:47 +0900 Subject: [PATCH 11/13] issue #44 updated --- user.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/user.py b/user.py index fb0814f..15eec04 100644 --- a/user.py +++ b/user.py @@ -232,8 +232,12 @@ def change_password(): def withdraw_member(link): """ issue #44 회원탈퇴 """ - # User DB 삭제 + username = get_logged_in_username() + if link != username: + return '누가 당신을 싫어하나봐요 ^^', 400 + + # User DB 삭제 found = User.query.filter( User.username == username, ).first() From 9766929dc61013eaf39af3fd21619d08eae81ef2 Mon Sep 17 00:00:00 2001 From: JimJeon Date: Sun, 6 Mar 2016 21:24:22 +0900 Subject: [PATCH 12/13] issue #44 complete! Conflicts: user.py --- templates/_includes/manager/withdrawal.html | 6 ++++++ templates/manager.html | 4 ++-- user.py | 18 +++++++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 templates/_includes/manager/withdrawal.html diff --git a/templates/_includes/manager/withdrawal.html b/templates/_includes/manager/withdrawal.html new file mode 100644 index 0000000..d180fbd --- /dev/null +++ b/templates/_includes/manager/withdrawal.html @@ -0,0 +1,6 @@ +정말로 탈퇴하시겠습니까?

+

+ + + +
diff --git a/templates/manager.html b/templates/manager.html index 43ce2d1..706427f 100644 --- a/templates/manager.html +++ b/templates/manager.html @@ -56,9 +56,9 @@ {% if manager__right_html_for_menu == "_includes/manager/withdrawal.html" %} - + {% else %} - + {% endif %}