Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#22/review api #26

Merged
merged 13 commits into from
Aug 18, 2021
File renamed without changes.
5 changes: 2 additions & 3 deletions server/models/dog.py → server/models/dog_model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# from django.db import models
from djongo import models
from .organization import Organization, OrganizationForm
from .organization_model import AbstractOrganization, OrganizationForm
from django.conf import settings
from djongo.storage import GridFSStorage



class Dog(models.Model):
_id = models.ObjectIdField(primary_key=True)
name = models.CharField(max_length=100)
Expand All @@ -17,7 +16,7 @@ class Dog(models.Model):
image = models.ImageField(upload_to="dogs", null=True)

organization = models.EmbeddedField(
model_container=Organization, model_form_class=OrganizationForm
model_container=AbstractOrganization, model_form_class=OrganizationForm
)

class Meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ class Meta:


class Organization(models.Model):
_id = models.ObjectIdField()
name = models.CharField(max_length=100)
ceo = models.CharField(max_length=100)
description = models.TextField()
phone = models.CharField(max_length=100)
images = models.ArrayField(model_container=Image, model_form_class=ImageForm)
donation = models.CharField(max_length=100)
fax = models.CharField(max_length=100)
email = models.CharField(max_length=100)
sns = models.ArrayField(model_container=SNS, model_form_class=SNSForm)
objects = models.DjongoManager()


class AbstractOrganization(models.Model):
_id = models.ObjectIdField()
Zih0 marked this conversation as resolved.
Show resolved Hide resolved
name = models.CharField(max_length=100)
ceo = models.CharField(max_length=100)
description = models.TextField()
Expand Down
26 changes: 22 additions & 4 deletions server/models/user.py → server/models/user_model.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from django.contrib.auth.models import AbstractBaseUser
from django.db import models
from djongo import models
from django.contrib.auth.models import UserManager
import uuid


class User(AbstractBaseUser):

class BaseUser(AbstractBaseUser):
id = models.ObjectIdField(primary_key=True)
email = models.EmailField(
max_length=100, unique=True, verbose_name="Email", help_text="이메일"
max_length=100,
unique=True,
verbose_name="Email",
help_text="이메일",
)
password = models.CharField(
max_length=128, null=True, verbose_name="password", help_text="비밀번호"
Expand All @@ -28,7 +32,21 @@ class User(AbstractBaseUser):
max_length=255, null=True, verbose_name="token", help_text="Refresh Token"
)

class Meta:
abstract = True


class User(BaseUser):
USERNAME_FIELD = "email"
REQUIRED_FIELDS = []

objects = UserManager()

def __str__(self):
return self.email

def has_perm(self, perm, obj=None):
return True

def has_module_perms(self, app_label):
return True
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions server/serializers/organization_serializer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from rest_framework import serializers
from server.models import Organization


class OrganizationSerializer(serializers.ModelSerializer):
class Meta:
model = Organization
fields = "__all__"
15 changes: 15 additions & 0 deletions server/serializers/review_serializer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from rest_framework import serializers
from server.models import UserReview, OrganizationReview
from server.serializers import *


class UserReviewSerializer(serializers.ModelSerializer):
class Meta:
model = UserReview
fields = "__all__"


class OrganizationReviewSerializer(serializers.ModelSerializer):
class Meta:
model = OrganizationReview
fields = "__all__"
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ class UserSerializer(serializers.ModelSerializer):

class Meta:
model = User
fields = [
"password",
"email",
"phone",
"passport",
"provider",
]
fields = "__all__"

def create(self, validated_data):
if validated_data.get("password"):
Expand Down