-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
357 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,6 +297,9 @@ pyvenv.cfg | |
.venv | ||
env/ | ||
venv/ | ||
myvenv/ | ||
.myvenv | ||
myvenv.bak/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django import forms | ||
from django.contrib.auth.forms import UserCreationForm | ||
from myprofile.models import Profile | ||
|
||
class SignupForm(forms.ModelForm): | ||
class Meta: | ||
model = Profile | ||
fields = ('name', 'department', 'description', 'photo', 'interested_tag', 'naver', 'daum', 'github', 'other_url') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by Django 2.2.9 on 2020-02-06 07:44 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Profile', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.TextField(max_length=10)), | ||
('department', models.TextField(blank=True, max_length=100, verbose_name='소속')), | ||
('description', models.TextField(max_length=200, null=True, verbose_name='한줄소개')), | ||
('naver', models.URLField(blank=True, null=True, verbose_name='네이버 URL')), | ||
('daum', models.URLField(blank=True, null=True, verbose_name='다음 URL')), | ||
('github', models.URLField(blank=True, null=True, verbose_name='깃 URL')), | ||
('profile_pic', models.ImageField(upload_to='blog/profile_pic')), | ||
('photo', models.ImageField(blank=True, upload_to='blog/%Y/%m/%d')), | ||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 2.2.9 on 2020-02-06 07:55 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('accounts', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='profile', | ||
name='photo', | ||
), | ||
migrations.RemoveField( | ||
model_name='profile', | ||
name='profile_pic', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Generated by Django 2.2.9 on 2020-02-06 08:28 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('accounts', '0002_auto_20200206_1655'), | ||
] | ||
|
||
operations = [ | ||
migrations.DeleteModel( | ||
name='Profile', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
</head> | ||
<body> | ||
{% extends "base.html" %} | ||
|
||
<form action="" method="post"> | ||
{% csrf_token %} | ||
<table> | ||
{{ form.as_table }} | ||
</table> | ||
<input type="submit"/> | ||
</form> | ||
{% block content %} | ||
<div class="container"> | ||
<h1>로그인을 해보자.</h1> | ||
<form method="POST" action="{% url 'login' %}"> | ||
{% csrf_token %} | ||
USERNAME: | ||
<br> | ||
<input name="username" type="text"> | ||
<br> | ||
PASSWORD: | ||
<br> | ||
<input name="password" type="password"> | ||
<br><br> | ||
<input type="submit" class="btn btn-primary" value="sign up"> | ||
|
||
</body> | ||
</html> | ||
</form> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h2>{{ user }}'s Profile</h2> | ||
{# {% if post.photo %}#} | ||
{# path :{{ user.profile.photo.path }} # /Users/nickname/documents/practice/media/jeju_pic.png#} | ||
{# url : {{ user.profile.photo.url }} # /media/jeju_pic.png#} | ||
{# <img src="{{ user.profile.photo.url }}" alt="">#} | ||
{# {% endif %}#} | ||
<br> | ||
유저 이름: {{ user.profile.name }} | ||
<br> | ||
유저 소속:{{ user.profile.department }} | ||
<br> | ||
유저 소속:{{ user.profile.description }} | ||
<br> | ||
유저 소속:{{ user.profile.naver }} | ||
<div> | ||
대표 URL | ||
<br> | ||
네이버 URL:{{ user.profile.naver }} | ||
<br> | ||
다음 URL:{{ user.profile.daum }} | ||
<br> | ||
github URL:{{ user.profile.github }} | ||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<form action="" method="post" enctype="multipart/form-data"> | ||
{% csrf_token %} | ||
<h2>로그인 정보 입력</h2> | ||
USERNAME: | ||
<br> | ||
<input name="username" type="text"> | ||
<br> | ||
PASSWORD: | ||
<br> | ||
<input name="password1" type="password"> | ||
<br> | ||
Confirm PASSWORD: | ||
<br> | ||
<input name="password2" type="password"> | ||
<br> | ||
<hr> | ||
<h2>상세정보 입력</h2> | ||
{{ form.as_p }} | ||
<input type="submit" value="가입"/> | ||
</form> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
from django.urls import path | ||
from django.contrib.auth import views as auth_views | ||
|
||
from . import views | ||
|
||
|
||
|
||
urlpatterns = [ | ||
path('login/', auth_views.LoginView.as_view(template_name ='accounts/login.html'), name='login'), | ||
path('logout/', auth_views.LogoutView.as_view(), name='logout'), | ||
] | ||
path('login/', views.login, name='login'), | ||
path('logout/', views.logout, name='logout'), | ||
path('signup/', views.signup, name='signup'), | ||
path('profile/', views.profile, name='profile'), | ||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,67 @@ | ||
from django.shortcuts import render | ||
from django.contrib.auth.decorators import login_required | ||
from django.shortcuts import redirect, render | ||
from django.contrib.auth.models import User | ||
from django.contrib import auth | ||
|
||
# Create your views here. | ||
from accounts.forms import SignupForm | ||
from myprofile.models import Profile | ||
|
||
|
||
def login(request): | ||
if request.method == "POST": | ||
username = request.POST['username'] | ||
password = request.POST["password"] | ||
user = auth.authenticate(request, username=username, password=password) | ||
if user is not None: | ||
auth.login(request, user) | ||
return redirect('/') | ||
else: | ||
return render(request, 'accounts/login.html', {'error': 'login error'}) | ||
else: | ||
return render(request, 'accounts/login.html') | ||
|
||
|
||
def logout(request): | ||
auth.logout(request) | ||
return redirect('/') | ||
|
||
|
||
def signup(request): | ||
if request.method == "POST": | ||
if request.POST["password1"] == request.POST["password2"]: | ||
user = User.objects.create_user( | ||
username=request.POST["username"], | ||
password=request.POST["password1"] | ||
) | ||
|
||
form = SignupForm( | ||
request.POST, | ||
request.FILES, | ||
) | ||
if form.is_valid(): | ||
# user.last_name = form.cleaned_data['name'][:1] | ||
profile = Profile.objects.create( | ||
user=user, | ||
name=form.cleaned_data['name'], | ||
department=form.cleaned_data['department'], | ||
description=form.cleaned_data['description'], | ||
naver=form.cleaned_data['naver'], | ||
daum=form.cleaned_data['daum'], | ||
github=form.cleaned_data['github'], | ||
photo=form.cleaned_data['photo'], | ||
other_url=form.cleaned_data['other_url'], | ||
interested_tag=form.cleaned_data['interested_tag'], | ||
) | ||
return redirect('/') | ||
|
||
elif request.method == "GET": | ||
form = SignupForm() | ||
|
||
return render(request, 'accounts/signup.html', { | ||
'form': form, | ||
}) | ||
|
||
|
||
@login_required | ||
def profile(request): | ||
return render(request, 'myprofile/profile_detail.html') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Generated by Django 2.2.9 on 2020-02-06 08:28 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('myprofile', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='profile', | ||
name='daum', | ||
field=models.URLField(blank=True, null=True, verbose_name='다음 URL'), | ||
), | ||
migrations.AddField( | ||
model_name='profile', | ||
name='github', | ||
field=models.URLField(blank=True, null=True, verbose_name='깃 URL'), | ||
), | ||
migrations.AddField( | ||
model_name='profile', | ||
name='naver', | ||
field=models.URLField(blank=True, null=True, verbose_name='네이버 URL'), | ||
), | ||
migrations.AddField( | ||
model_name='profile', | ||
name='other_url', | ||
field=models.URLField(blank=True, null=True, verbose_name='기타 URL'), | ||
), | ||
migrations.DeleteModel( | ||
name='Site', | ||
), | ||
] |
Oops, something went wrong.