-
Notifications
You must be signed in to change notification settings - Fork 0
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
19 changed files
with
332 additions
and
80 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
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,9 +1,18 @@ | ||
|
||
from django.contrib import admin | ||
from django.urls import path, include | ||
from django.contrib import admin | ||
from django.urls import path, include | ||
from rest_framework.permissions import AllowAny | ||
from django.contrib import admin | ||
from django.urls import path, include | ||
from rest_framework import permissions | ||
from django.urls import include, re_path | ||
from rest_framework.permissions import AllowAny | ||
|
||
|
||
urlpatterns = [ | ||
path('admin/', admin.site.urls), | ||
path('users/', include('rebikeuser.urls')), | ||
path('trashs/', include('rebiketrash.urls')), | ||
path('user/', include('rebikeuser.urls')), | ||
path('trash/', include('rebiketrash.urls')), | ||
] |
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 |
---|---|---|
|
@@ -6,4 +6,4 @@ COPY ./ ./ | |
|
||
EXPOSE 8080 | ||
|
||
RUN pip install -r requirements.txt | ||
RUN pip install -r requirements.txt |
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,14 @@ | ||
from django.contrib import admin | ||
|
||
from .models import trash_kind, uploaded_trash_image | ||
|
||
@admin.register(trash_kind) | ||
class TrashkindAdmin(admin.ModelAdmin): | ||
list_display = ['kind', 'way'] | ||
search_fields = ['kind'] | ||
|
||
@admin.register(uploaded_trash_image) | ||
class UploadedtrashimageAdmin(admin.ModelAdmin): | ||
list_display = ['uploaded_trash_image_id', 'img', 'created_at', 'updated_at','user_id', 'trash_kind'] | ||
search_fields = ['uploaded_trash_image_id'] | ||
|
Empty file.
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,13 @@ | ||
from rest_framework import serializers | ||
from .models import trash_kind, uploaded_trash_image | ||
|
||
class TrashkindSerializer(serializers.ModelSerializer) : | ||
class Meta : | ||
model = trash_kind # product 모델 사용 | ||
fields = '__all__' # 모든 필드 포함 | ||
|
||
|
||
class UploadedtrashimageSerializer(serializers.ModelSerializer) : | ||
class Meta : | ||
model = uploaded_trash_image # product 모델 사용 | ||
fields = '__all__' # 모든 필드 포함 |
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,7 +1,21 @@ | ||
from django.urls import path | ||
from django.urls import path, re_path | ||
from . import views | ||
|
||
from django.contrib import admin | ||
from django.urls import include, path, re_path | ||
|
||
urlpatterns = [ | ||
|
||
|
||
urlpatterns =[ | ||
path('mainpage/trashkind/',views.TrashkindListAPI.as_view()), | ||
path('mypage/<user_id>/image/',views.histories, name='histories'), | ||
path('mypage/<user_id>/image/<uploaded_trash_image_id>/',views.UploadedtrashimageListAPI.as_view()), | ||
#path('mypage/<user_id>/statistics/',views.statistics, name='statistics'), | ||
] | ||
|
||
|
||
### 유저 페이지 진입 시 액티브된 계정인지(있는지 없는지 확인) | ||
### 통계페이지 (액티브 상관 없이 받아오기!) | ||
### 자주 쓰이는 코드 유틸화 trashUtils.py | ||
|
||
### swagger, postman 확인 -> 성빈님 |
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,43 @@ | ||
from django.shortcuts import render | ||
from audioop import reverse | ||
from django.shortcuts import render, HttpResponse | ||
from django.db.models import Count | ||
|
||
from .models import trash_kind, uploaded_trash_image | ||
from rebikeuser.models import user | ||
|
||
from rest_framework import status | ||
from rest_framework.response import Response | ||
from rest_framework.views import APIView | ||
from rest_framework.decorators import api_view | ||
from .serializers import TrashkindSerializer, UploadedtrashimageSerializer | ||
|
||
# Create your views here. | ||
class TrashkindListAPI(APIView): | ||
def get(self, request): | ||
queryset = trash_kind.objects.all() | ||
print(queryset) | ||
serializer = TrashkindSerializer(queryset, many=True) | ||
return Response(serializer.data) | ||
|
||
@api_view(['GET']) | ||
def histories(request,user_id): | ||
uploadedTrashs = uploaded_trash_image.objects.filter(user_id=user_id, active=1) | ||
serializer = UploadedtrashimageSerializer(uploadedTrashs, many=True) | ||
return Response(serializer.data) | ||
|
||
class UploadedtrashimageListAPI(APIView): | ||
def get(self, request, user_id, uploaded_trash_image_id): | ||
uploadedTrashs = uploaded_trash_image.objects.filter(user_id=user_id, active=1, uploaded_trash_image_id = int(uploaded_trash_image_id)) | ||
serializer = UploadedtrashimageSerializer(uploadedTrashs, many=True) | ||
return Response(serializer.data) | ||
|
||
def delete(self, request, user_id, uploaded_trash_image_id): | ||
uploadedTrashs = uploaded_trash_image.objects.filter(user_id=user_id, active=1, uploaded_trash_image_id = int(uploaded_trash_image_id)) | ||
uploadedTrashs.delete() | ||
return Response(status=status.HTTP_204_NO_CONTENT) | ||
|
||
@api_view(['GET']) | ||
def statistics(request,user_id): | ||
uploadedTrashs = uploaded_trash_image.objects.filter(user_id=user_id).values('trash_kind') | ||
serializer = UploadedtrashimageSerializer(uploadedTrashs, many=True) | ||
return Response(serializer.data) |
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,6 @@ | ||
from django.contrib import admin | ||
from .models import user | ||
|
||
@admin.register(user) | ||
class UserAdmin(admin.ModelAdmin): | ||
list_display = ['id', 'name', 'alias', 'pw', 'salt', 'email'] |
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 |
---|---|---|
@@ -1,15 +1,19 @@ | ||
from django.db import models | ||
import uuid | ||
|
||
|
||
class user(models.Model): | ||
id = models.UUIDField(primary_key=True, editable=False) | ||
name = models.CharField(unique=True, max_length=20) | ||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) | ||
name = models.CharField(unique=True, max_length=20, null=True, blank=True) | ||
alias = models.CharField(unique=True, max_length=20) | ||
pw = models.BinaryField(max_length=60) | ||
salt = models.BinaryField(max_length=29) | ||
email = models.CharField(unique=True, max_length=50) | ||
active = models.IntegerField(default=1) | ||
created_at = models.DateTimeField() | ||
updated_at = models.DateTimeField() | ||
|
||
class Meta: | ||
managed = False | ||
db_table = 'user' | ||
#, default=str(uuid.uuid4()) | ||
|
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
from django.urls import path | ||
from . import views | ||
from .views import UserSignupAPI | ||
|
||
|
||
#rebikeuser/urls.py | ||
urlpatterns = [ | ||
path('login/', views.user_login), | ||
path('signup/', views.user_signup), | ||
path('signup/', views.UserSignupAPI.as_view()), | ||
path('changepw/', views.user_pw_change), | ||
path('changealias/', views.user_alias_change), | ||
] | ||
] |
Oops, something went wrong.