-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat : Added Ticket and Event_Form (#103)
* Added Evnet Model Signed-off-by: Priyansh61 <[email protected]> * Added Tickets App Signed-off-by: Priyansh61 <[email protected]> * Added Event Form Model Signed-off-by: Priyansh61 <[email protected]> * minor fixes * Update models.py --------- Signed-off-by: Priyansh61 <[email protected]> Co-authored-by: Armin Patel <[email protected]>
- Loading branch information
1 parent
3e62285
commit 7a3dc1b
Showing
14 changed files
with
140 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
'accounts', | ||
'products', | ||
'events', | ||
'tickets', | ||
] | ||
|
||
REST_FRAMEWORK = { | ||
|
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
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,13 @@ | ||
from rest_framework import viewsets | ||
from .models import Event | ||
from .serializers import EventSerializer | ||
from .serializers import EventSerializer, EventFormSerializer | ||
|
||
# Create your views here. | ||
|
||
class EventViewSet(viewsets.ModelViewSet): | ||
queryset = Event.objects.all() | ||
serializer_class = EventSerializer | ||
|
||
class EventFormViewSet(viewsets.ModelViewSet): | ||
queryset = Event.objects.all() | ||
serializer_class = EventFormSerializer |
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,11 @@ | ||
from django.contrib import admin | ||
from .models import Ticket | ||
|
||
|
||
# Register your models here. | ||
class TicketAdmin(admin.ModelAdmin) : | ||
list_display = ('event', 'buyer', 'purchase_date', 'status') | ||
search_fields = ('event', 'buyer', 'purchase_date', 'status') | ||
list_filter = ('event', 'buyer', 'purchase_date', 'status') | ||
|
||
admin.site.register(Ticket, TicketAdmin) |
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 TicketsConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'tickets' |
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,34 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
|
||
status_enums = [ | ||
('pending','Pending'), | ||
('approved','Approved'), | ||
('rejected','Rejected'), | ||
('cancelled','Cancelled'), | ||
] | ||
|
||
class Ticket (models.Model) : | ||
event = models.ForeignKey( | ||
'events.Event', | ||
on_delete=models.CASCADE, | ||
default=None, | ||
null=False, | ||
blank=False, | ||
) | ||
buyer = models.ForeignKey( | ||
'accounts.Account', | ||
on_delete=models.CASCADE, | ||
default=None, | ||
null=False, | ||
blank=False, | ||
) | ||
response = models.JSONField(default=dict) | ||
purchase_date = models.DateTimeField(auto_now_add=True) | ||
status = models.CharField(max_length=100, | ||
choices=status_enums) | ||
|
||
|
||
def __str__(self): | ||
return f'{self.event.title} {self.buyer.first_name} {self.buyer.last_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from rest_framework import serializers | ||
from .models import Ticket | ||
|
||
class TicketSerializer(serializers.ModelSerializer) : | ||
class Meta: | ||
model = Ticket | ||
fields = [ | ||
'id', | ||
'event', | ||
'buyer', | ||
'response', | ||
'purchase_date', | ||
'status', | ||
] |
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,10 @@ | ||
from django.urls import path,include | ||
from rest_framework.routers import DefaultRouter | ||
from .views import TicketViewSet | ||
|
||
router = DefaultRouter() | ||
router.register('', TicketViewSet, basename='ticket') | ||
|
||
urlpatterns = [ | ||
path('', include(router.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from rest_framework import viewsets | ||
from .models import Ticket | ||
from .serializers import TicketSerializer | ||
|
||
# Create your views here. | ||
|
||
class TicketViewSet(viewsets.ModelViewSet): | ||
queryset = Ticket.objects.all() | ||
serializer_class = TicketSerializer |