Skip to content

Commit faf7392

Browse files
committed
Merge branch 'devdev' into feature/golony/ticket
# Conflicts: # account/views.py
2 parents a892c69 + bf142c4 commit faf7392

File tree

6 files changed

+65
-7
lines changed

6 files changed

+65
-7
lines changed

account/urls.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@
44

55
from .views import IdLogin, Logout
66

7+
from .views import login_api, logout_api
8+
79
urlpatterns = [
810
path("auth/", include("dj_rest_auth.urls")),
9-
path("account/login/", IdLogin.as_view(), name='account_login'),
10-
path("account/email/", IdLogin.as_view(), name='account_email'),
11-
path("account/logout/", Logout.as_view(), name='account_logout'),
12-
path("account/singup/", IdLogin.as_view(), name="account_signup"),
11+
path("accounts/login/", IdLogin.as_view(), name='account_login'),
12+
path("accounts/email/", IdLogin.as_view(), name='account_email'),
13+
path("accounts/logout/", Logout.as_view(), name='account_logout'),
14+
path("accounts/signup/", IdLogin.as_view(), name="account_signup"),
1315
path("auth/github/login/", GitHubLogin.as_view(), name="github_login"),
1416
path("auth/google/login/", GoogleLogin.as_view(), name="google_login"),
1517
#path("my-page/payments", MyPage.as_view())
16-
path("my-page/payments/", mypage_payments)
18+
path("my-page/payments/", mypage_payments),
19+
20+
# Endpoints for Seesion Based Login
21+
path("api/login/", login_api, name="login-api"),
22+
path("api/logout/", logout_api, name="logout-api"),
23+
# path("api/logout/", )
24+
1725
]

account/views.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22
from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
33
from allauth.socialaccount.providers.oauth2.client import OAuth2Client
44
from dj_rest_auth.registration.views import SocialLoginView
5+
56
from django.conf import settings
67
from django.contrib.auth.decorators import login_required
78
from django.shortcuts import render
9+
from django.contrib.auth import login, logout, authenticate
10+
11+
from rest_framework.response import Response
812
from rest_framework.views import APIView
13+
from rest_framework.decorators import api_view
914

1015
from ticket.models import Ticket
1116

@@ -37,3 +42,37 @@ def mypage_payments(request):
3742
ticket_list = Ticket.objects.filter(user=request.user)
3843
return render(request, 'account_mypage_payments.html',
3944
context={'ticket_list': ticket_list})
45+
46+
47+
@api_view(["POST"])
48+
def login_api(request):
49+
50+
if request.user.is_authenticated:
51+
return Response({"msg": "already logged in"})
52+
53+
user = authenticate(
54+
request,
55+
username=request.data["username"],
56+
password=request.data["password"]
57+
)
58+
59+
login(request, user, backend="django.contrib.auth.backends.ModelBackend")
60+
61+
response_data = {
62+
"msg": "ok"
63+
}
64+
return Response(response_data)
65+
66+
67+
@api_view(["POST"])
68+
def logout_api(request):
69+
70+
if not request.user.is_authenticated:
71+
return Response({"msg": "not logged in"})
72+
73+
logout(request)
74+
75+
response_data = {
76+
"msg": "ok"
77+
}
78+
return Response(response_data)

pyconkr/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
"drf_spectacular",
6363
# cors
6464
"corsheaders",
65+
# django-import-export
66+
"import_export",
6567
]
6668

6769
MIDDLEWARE = [
@@ -230,3 +232,7 @@
230232

231233
OAUTH_GITHUB_CALLBACK_URL = "http://localhost:8000/accounts/github/login/callback/"
232234
OAUTH_GOOGLE_CALLBACK_URL = "http://localhost:8000/accounts/google/login/callback/"
235+
236+
# login_required view에 로그인 되지 않은 상태로 접속할 경우 리다이렉트할 로그인 페이지를 설정합니다.
237+
# The URL or named URL pattern where requests are redirected for login when using the login_required() decorator
238+
LOGIN_URL = '/accounts/login/'

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dj-rest-auth==3.0.0
55
Django==4.1.5
66
django-allauth==0.52.0
77
django-storages==1.13.2
8-
django-import-export==3.0.2
8+
django-import-export==3.2.0
99
djangorestframework==3.14.0
1010
djangorestframework-simplejwt==5.2.2
1111
Markdown==3.4.1

sponsor/admin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class SponsorAdmin(SummernoteModelAdmin):
1111
"manager_id",
1212
)
1313
list_display = (
14-
"creator",
1514
"name",
1615
"level",
1716
"manager_name",

sponsor/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ def get_queryset(self):
1111

1212

1313
class SponsorLevel(models.Model):
14+
class Meta:
15+
verbose_name = "후원사 등급"
16+
verbose_name_plural = "후원사 등급"
17+
1418
name = models.CharField(max_length=255, blank=True, default="", help_text="후원 등급명")
1519
desc = models.TextField(
1620
null=True, blank=True, help_text="후원 혜택을 입력하면 될 거 같아요 :) 후원사가 등급을 정할 때 볼 문구입니다."
@@ -61,6 +65,8 @@ def logo_image_upload_to(instance, filename):
6165
class Sponsor(models.Model):
6266
class Meta:
6367
ordering = ["paid_at", "id"]
68+
verbose_name = "후원사"
69+
verbose_name_plural = "후원사 목록"
6470

6571
creator = models.ForeignKey(
6672
User,

0 commit comments

Comments
 (0)