-
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.
Base models for subscriptions, reivews, shops, gallery, and images
- Loading branch information
1 parent
2e200f5
commit 2ef7095
Showing
33 changed files
with
207 additions
and
29 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,17 +1,17 @@ | ||
from django.shortcuts import render | ||
from django.core.mail import send_mail | ||
from rest_framework.response import Response | ||
from rest_framework.decorators import api_view,permission_classes | ||
from rest_framework.decorators import api_view, permission_classes | ||
from rest_framework import permissions | ||
|
||
|
||
@api_view(["GET"]) | ||
def test_send_mail(request): | ||
send_mail( | ||
subject="Test Mail", | ||
message="This is just a test mail", | ||
message="This is just a test mail", | ||
from_email="[email protected]", | ||
recipient_list=["[email protected]"] | ||
recipient_list=["[email protected]"], | ||
) | ||
|
||
return Response({"message": "mail was sent!"}) | ||
|
@@ -26,5 +26,4 @@ def js_test_rout(request): | |
"username": "miclemabasie", | ||
} | ||
|
||
|
||
return Response(data) | ||
return Response(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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
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
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 |
---|---|---|
@@ -1,3 +1,20 @@ | ||
from django.db import models | ||
from apps.common.models import TimeStampedUUIDModel | ||
from django.utils.translation import gettext_lazy as _ | ||
from apps.shop.models import Shop | ||
|
||
# Create your models here. | ||
class Image(TimeStampedUUIDModel): | ||
gallery = models.OneToOneField("Gallery", related_name="images", on_delete=models.CASCADE, verbose_name="Gallery") | ||
name = models.CharField(verbose_name=_("Image Name"), max_length=200) | ||
image = models.ImageField( | ||
verbose_name=_("Gallery Photo"), upload_to="galleries" | ||
) | ||
|
||
|
||
class Gallery(TimeStampedUUIDModel): | ||
shop = models.OneToOneField(Shop, related_name="gallery", on_delete=models.CASCADE) | ||
max_photos = models.PositiveIntegerField(default=0) | ||
|
||
|
||
def __str__(self): | ||
return f"Gallery - {self.shop.shop_name}" |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class ReviewsConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'apps.reviews' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.db import models | ||
from django.contrib.auth import get_user_model | ||
from apps.shop.models import Shop | ||
from apps.common.models import TimeStampedUUIDModel | ||
from django.utils.translation import gettext_lazy as _ | ||
from django.core.validators import MinValueValidator, MaxValueValidator | ||
|
||
User = get_user_model() | ||
|
||
class Review(TimeStampedUUIDModel): | ||
RATING_CHOICES = ( | ||
(1, '1 - Poor'), | ||
(2, '2 - Below Average'), | ||
(3, '3 - Average'), | ||
(4, '4 - Good'), | ||
(5, '5 - Excellent') | ||
) | ||
user = models.ForeignKey(User, related_name="reviews", on_delete=models.CASCADE) | ||
shop = models.ForeignKey(Shop, related_name="reviews", on_delete=models.CASCADE) | ||
rating = models.IntegerField(choices=RATING_CHOICES, validators=[MinValueValidator(1), MaxValueValidator(5)]) | ||
comment = models.TextField() | ||
|
||
|
||
class Meta: | ||
unique_together = ["user", "shop"] | ||
|
||
def __str__(self): | ||
return f"{self.user.username} - {self.shop.shop_name} Review" |
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,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class SettingsConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'apps.settings' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from django.db import models |
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,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views 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
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,44 @@ | ||
from django.db import models | ||
from django.contrib.auth import get_user_model | ||
from apps.subscriptions.models import Subscription | ||
from apps.common.models import TimeStampedUUIDModel | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
# Create your models here. | ||
|
||
User = get_user_model() | ||
|
||
|
||
class Shop(TimeStampedUUIDModel): | ||
user = models.ForeignKey(User, related_name="shop", on_delete=models.CASCADE) | ||
subscription = models.OneToOneField( | ||
Subscription, related_name="shop", on_delete=models.CASCADE | ||
) | ||
shop_name = models.CharField( | ||
verbose_name=_("Shop Name"), max_length=200, unique=True | ||
) | ||
description = models.TextField(verbose_name=_("Description")) | ||
Location = models.CharField(verbose_name=_("Loaction"), max_length=200) | ||
is_verified = False | ||
|
||
def __str__(self): | ||
return f"Shop-{self.shop_name}" | ||
|
||
|
||
class StaffMember(TimeStampedUUIDModel): | ||
STAFF_ROLES = ( | ||
(1, "1 - Poor"), | ||
(2, "2 - Below Average"), | ||
(3, "3 - Average"), | ||
(4, "4 - Good"), | ||
(5, "5 - Excellent"), | ||
) | ||
shop = models.ForeignKey( | ||
Shop, related_name="staff_members", on_delete=models.CASCADE | ||
) | ||
user = models.ForeignKey(User, on_delete=models.CASCADE) | ||
role = models.CharField( | ||
verbose_name=_("Staff Role"), max_length=20, choices=STAFF_ROLES | ||
) | ||
|
||
def __str__(self): | ||
return f"{self.user.username} staff for {self.shop.name}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class SubscriptionsConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'apps.subscriptions' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from django.db import models | ||
from apps.common.models import TimeStampedUUIDModel | ||
from django.utils.translation import gettext_lazy as _ | ||
from django.contrib.auth import get_user_model | ||
|
||
User = get_user_model() | ||
|
||
|
||
class Subscription(TimeStampedUUIDModel): | ||
|
||
PLAN_CHOICES = [ | ||
("basic", "Basic"), | ||
("standard", "Standard"), | ||
("premium", "Premium"), | ||
] | ||
|
||
transaction_id = models.CharField( | ||
verbose_name=_("Transaction_id"), max_length=20, unique=True | ||
) | ||
shop_owner = models.ForeignKey(User, related_name="subscriptions", on_delete=models.CASCADE) | ||
price = models.DecimalField(max_digits=10, decimal_places=2) | ||
plan_type = models.CharField(verbose_name=_("Plan Type"), max_length=20, choices=PLAN_CHOICES) | ||
start_data = models.DateTimeField() | ||
end_data = models.DateTimeField() | ||
is_active = models.BooleanField(default=False) | ||
|
||
|
||
def __str__(self): | ||
return f"subscription-{self.shop}" |
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,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. |