Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
Merge branch 'issue_41_template_redesign' #41 #21
Browse files Browse the repository at this point in the history
Conflicts:
	templates/_profile.html
	templates/register.html
	user.py

회원가입 간소화 (#21) 이랑 물렸는데 잘 해결했습니다 ㅠㅠ
  • Loading branch information
minhoryang committed Mar 2, 2016
2 parents fe8e708 + dd13fbb commit 5aa88d0
Show file tree
Hide file tree
Showing 23 changed files with 397 additions and 354 deletions.
13 changes: 13 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,18 @@ def index():
return redirect("/%s/" % perhaps_logged_in_username)
return goto("release")


@app.context_processor
def _set_global_variable_for_templates():
"""render_template()에 변수를 넘기지 않고도 사용할 수 있어요!
Flask의 render_template()는 사실 Jinja2라는 Template Engine을 이용해 제공됩니다.
근데 여기에 전역변수를 선언할 수 있다네요. WOW!
"""
return {
"get_logged_in_username": get_logged_in_username(),
}


if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0")
35 changes: 24 additions & 11 deletions nickname.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,20 @@ def RecommendNickname():
target = request.form['target']
nick = request.form['nick']
if not check_username(target, is_internal=True):
return '존재하지 않는 유저에게 추천하려고 하였습니다.', 400
return render_template(
"_error.html",
_error__msg='존재하지 않는 유저에게 추천하려고 하였습니다.',
), 400

found = Nickname.query.filter(
Nickname.username == target,
Nickname.nick == nick,
).first()
if found:
return '이미 해당유저가 사용중인 별명입니다.', 400
return render_template(
"_error.html",
_error__msg='이미 해당유저가 사용중인 별명입니다.',
), 400

new = NickRecom()
new.nick = nick
Expand Down Expand Up @@ -72,7 +78,10 @@ def ManageMyNicknames(link):
"""
username = get_logged_in_username()
if not username:
return '로그인 해주세요!!'
return render_template(
"_error.html",
_error__msg='로그인 해주세요!!',
), 400

found = Nickname.query.filter(
Nickname.username == username,
Expand All @@ -91,11 +100,10 @@ def ManageMyNicknames(link):
recomm['idx'].append(nick.idx)

return render_template(
"profile_manage_nick.html",
username=username,
menu='nicknames',
found=found,
recomm=recomm,
"manager.html",
manager__right_html_for_menu="_includes/manager/nicknames.html",
manager__nickname__my_nickname_classes=found,
manager__nickname__recommended_nicknames_for_me=recomm,
)


Expand All @@ -107,7 +115,10 @@ def DelMyNick(idx):

username = get_logged_in_username()
if not found.username == username:
return 'fuck off', 400
return render_template(
"_error.html",
_error__msg="fuck off",
), 400

db.session.delete(found)
db.session.commit()
Expand All @@ -123,7 +134,10 @@ def ManageRecommNick(idx):

username = get_logged_in_username()
if not found_recomm.username == username:
return 'ㅗㅗ', 400
return render_template(
"_error.html",
_error__msg="ㅗㅗ",
), 400

nick = found_recomm.nick
if request.form.get('use', None):
Expand Down Expand Up @@ -156,4 +170,3 @@ def RemoveRecommNick(nick):
).first()
db.session.delete(del_from_Recomm)
db.session.commit()
return
20 changes: 14 additions & 6 deletions photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,31 @@ def photo_upload(link):
"""
username = get_logged_in_username()
if not username:
return "로그인이 되어있지 않습니다.", 400
return render_template(
"_error.html",
_error__msg="로그인이 되어있지 않습니다.",
), 400
if not link == username:
return "자신이 아닙니다!", 400
return render_template(
"_error.html",
_error__msg="자신이 아닙니다!",
), 400

# 파일을 업로드
if request.method == "GET":
return render_template(
"profile_manage_photo.html",
username=username,
menu='photo',
"manager.html",
manager__right_html_for_menu="_includes/manager/photo.html",
)

# 파일을 업로드 후 저장
else:
file = request.files['upfile']
if not file:
return "이미지를 업로드하지 않았습니다.", 400
return render_template(
"_error.html",
_error__msg="이미지를 업로드하지 않았습니다.",
), 400
filename = username + os.path.splitext(file.filename)[1]

# 폴더가 없다면 만들어줍니다.
Expand Down
4 changes: 4 additions & 0 deletions templates/_error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends "_extends/_index.html" %}
{% block _index__container %}
{{ _error__msg }}
{% endblock %}
23 changes: 23 additions & 0 deletions templates/_extends/__bootstrap.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<!-- Required meta tags always come first -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
{% block __bootstrap__style %}
{% endblock %}
</head>
<body>
{% block __bootstrap__body %}
{% endblock %}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="http://github.hubspot.com/tether/dist/js/tether.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous"></script>
{% block __bootstrap__script %}
{% endblock %}
</body>
</html>
33 changes: 33 additions & 0 deletions templates/_extends/_index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% extends "_extends/__bootstrap.html" %}
{% block __bootstrap__style %}
<style>
@media (min-width: 544px)
.enough-space-from-nav {
padding-top: 4rem;
padding-bottom: 4rem;
margin-bottom: 3rem;
}

.enough-space-from-nav {
padding: 2rem .9375rem;
margin-bottom: 1.5rem;
}

.center {
text-align: center;
}
</style>
{% block _index__style %}
{% endblock %}
{% endblock %}
{% block __bootstrap__body %}
{% include "_includes/top_menu_nav.html" %}
<div class="container enough-space-from-nav">
{% block _index__container %}
{% endblock %}
</div>
{% endblock %}
{% block __bootstrap__script %}
{% block _index__script %}
{% endblock %}
{% endblock %}
23 changes: 23 additions & 0 deletions templates/_includes/manager/nicknames.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
내 닉네임 : <br>
{% for one_of_my_nick_class in manager__nickname__my_nickname_classes %}
<div>
<!-- TODO : 링크를 통해 실행하지 말고 jquery를 이용해 함수를 바로 호출할수 있게 만들기! -->
<form method="POST" action="/api/nickname/delete/{{ one_of_my_nick_class.idx }}/">
{{ one_of_my_nick_class.nick }}
<input type="submit" value="삭제"/>
</form>
</div>
{% endfor %}
<br>

추천받은 닉네임 : <br>
{% for idx in range(0, manager__nickname__recommended_nicknames_for_me['nick'].__len__()) %}
<div>
<!-- TODO : 추천받은 닉네임들이 중복되면 하나만 출력할 수 있도록 수정 -->
<form method="POST" action="/api/nickname/manage/{{ manager__nickname__recommended_nicknames_for_me['idx'][idx] }}/">
{{ manager__nickname__recommended_nicknames_for_me['nick'][idx] }}
<input type="submit" name=use value="사용"/>
<input type="submit" name=reject value="거부"/>
</form>
</div>
{% endfor %}
7 changes: 7 additions & 0 deletions templates/_includes/manager/photo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<FORM METHOD=POST ENCTYPE="multipart/form-data">
File to upload: <INPUT TYPE=FILE NAME="upfile" accept="image/*"><BR>
<INPUT TYPE=SUBMIT VALUE="Submit">
</FORM>
<h3>
정사각형의 사진을 올려주시면 예뻐요.
</h3>
56 changes: 56 additions & 0 deletions templates/_includes/profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{% if not profile__is_in_manager %}
{% if profile__user_class.username == get_logged_in_username %}
<div style="text-align: right">
<form method="GET" action="manage/">
<button type="submit" class="btn btn-danger-outline">수정</button>
</form>
</div>
{% endif %}
{% endif %}
<div class="center">
<a href="#">
{% if profile__photo_url %}
<img style="
width:200px;
height:200px;
display:block;
border-radius:50%;
background-position-y: center;
background-position-x: center;
background-repeat: no-repeat;
background-size: cover;
margin: 0 auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image:url({{ photo }})">
{% else %}
<img src="/static/default.png" class="img-circle center-block">
{% endif %}
</a>
<br><!-- REALLY?!-->
<h1>
{{ profile__user_class.realname }}
</h1>
<!-- Where is H2 -->
<h3>
{% for nickname in profile__user_nickname_classes %}
<div class="row">
{{ nickname.nick }}
</div>
{% endfor %}
</h3>
<!-- more here -->
{% if get_logged_in_username %}
{% if profile__user_class.username != get_logged_in_username %}
{% if not profile__is_in_manager %}
<form action="/api/nickname/recommend/" method="POST">
<input type=text class='nick' id=nick name=nick maxlength="50" placeholder="새 별명" />
<input type=hidden class='target' id=target name=target maxlength="50" value="{{ profile__user_class.username }}"/>
<input type=submit value="추천하기!" />
</form>
{% endif %}
{% endif %}
{% endif %}
</div>
31 changes: 31 additions & 0 deletions templates/_includes/top_menu_nav.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<header>
<nav class="navbar navbar-light bg-faded">
<a class="navbar-brand" href="/">릴리즈 업적관리 사비스</a>
<ul class="nav navbar-nav">
{% if get_logged_in_username %}
<li class="nav-item active">
<a class="nav-link" href="/logout/">로그아웃</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="/{{ get_logged_in_username }}/">내페이지</a>
</li>
{% else %}
<li class="nav-item active">
<a class="nav-link" href="/register/">회원가입</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="/login/">로그인</a>
</li>
{% endif %}
<li class="nav-item">
<a class="nav-link" target="_blank" href="https://github.com/minhoryang/AwesomeTitle/issues">버그신고</a>
</li>
</ul>
<form class="form-inline pull-xs-right -hidden-sm-down" method="POST" action="/question/">
<input class="form-control" type="text" placeholder="다른 친구" name="who">
<button class="btn btn-success-outline" type="submit" name="question">궁금해</button>
<button class="btn btn-warning-outline" type="submit" name="random">랜덤!</button>
</form>
</nav>
<!-- TODO: Logout Please?! -->
</header>
Loading

0 comments on commit 5aa88d0

Please sign in to comment.