Skip to content

Commit

Permalink
merger with lsgdev
Browse files Browse the repository at this point in the history
  • Loading branch information
BunnnyBin committed Feb 6, 2020
2 parents 1df631d + d8887da commit a712880
Show file tree
Hide file tree
Showing 22 changed files with 357 additions and 56 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ pyvenv.cfg
.venv
env/
venv/
myvenv/
.myvenv
myvenv.bak/
ENV/
env.bak/
venv.bak/
Expand Down
8 changes: 8 additions & 0 deletions accounts/forms.py
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')
32 changes: 32 additions & 0 deletions accounts/migrations/0001_initial.py
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)),
],
),
]
21 changes: 21 additions & 0 deletions accounts/migrations/0002_auto_20200206_1655.py
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',
),
]
16 changes: 16 additions & 0 deletions accounts/migrations/0003_delete_profile.py
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',
),
]
2 changes: 0 additions & 2 deletions accounts/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from django.db import models

# Create your models here.
34 changes: 18 additions & 16 deletions accounts/templates/accounts/login.html
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 %}
28 changes: 28 additions & 0 deletions accounts/templates/accounts/profile.html
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 %}
24 changes: 24 additions & 0 deletions accounts/templates/accounts/signup.html
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 %}
12 changes: 6 additions & 6 deletions accounts/urls.py
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'),

]
68 changes: 66 additions & 2 deletions accounts/views.py
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')
15 changes: 7 additions & 8 deletions log_share/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
"""

import os

from django.urls import reverse_lazy
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

Expand All @@ -37,11 +38,10 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

# app
'group_management',

'myprofile',

'accounts',
'main',
'post',
Expand Down Expand Up @@ -129,13 +129,12 @@

STATIC_URL = '/static/'


#image
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')


from django.conf.global_settings import LOGIN_REDIRECT_URL

LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/../../'
LOGOUT_REDIRECT_URL = '/'
LOGIN_URL = reverse_lazy('login')
# LOGIN_REDIRECT_URL = reverse_lazy('profile')
LOGOUT_REDIRECT_URL = reverse_lazy('login')
2 changes: 1 addition & 1 deletion log_share/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"""
from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
from django.conf.urls.static import static


urlpatterns = [
Expand Down
1 change: 1 addition & 0 deletions main/templates/main/main_front.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
<div><a href="{% url 'logout' %}">로그아웃</a></div>
{% else %}
<div><a href="{% url 'login' %}">로그인</a></div>
<div><a href="{% url 'signup' %}">회원가입</a></div>
{% endif %}
{% endblock %}
5 changes: 1 addition & 4 deletions myprofile/admin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from django.contrib import admin
from myprofile.models import Profile, Site, BookMark
from myprofile.models import Profile, BookMark

admin.site.register(Profile)


@admin.register(Site)
class SiteAdmin(admin.ModelAdmin):
list_display = ['link', 'profile']

@admin.register(BookMark)
class BookMarkAdmin(admin.ModelAdmin):
Expand Down
36 changes: 36 additions & 0 deletions myprofile/migrations/0002_auto_20200206_1728.py
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',
),
]
Loading

0 comments on commit a712880

Please sign in to comment.