-
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.
Signed-off-by: Priyansh61 <[email protected]>
- Loading branch information
1 parent
ab0c789
commit 3e62285
Showing
11 changed files
with
95 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -39,6 +39,7 @@ | |
'core', | ||
'accounts', | ||
'products', | ||
'events', | ||
] | ||
|
||
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
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 Event | ||
# Register your models here. | ||
|
||
|
||
class EventAdmin(admin.ModelAdmin) : | ||
list_display = ('title', 'date', 'time', 'location', 'ticket_price', 'event_type') | ||
search_fields = ('title', 'description', 'location', 'email') | ||
list_filter = ('event_type', 'date', 'time') | ||
|
||
admin.site.register(Event, EventAdmin) |
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 EventsConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'events' |
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,41 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
|
||
event_type_choices = [ | ||
('virtual','Virtual'), | ||
('physical','Physical'), | ||
] | ||
class Event (models.Model) : | ||
title = models.CharField(max_length=200) | ||
organizer_id = models.OneToOneField( | ||
'accounts.Account', | ||
on_delete=models.CASCADE, | ||
default=None, | ||
null=True, | ||
blank=True, | ||
) | ||
description = models.TextField(max_length=600, | ||
blank=True) | ||
email = models.EmailField(max_length=254, | ||
blank=True) | ||
phone = models.CharField(max_length=15, blank=True) | ||
date = models.DateField( | ||
blank = False, | ||
null = False, | ||
) | ||
time = models.TimeField( | ||
blank = False, | ||
null = False, | ||
) | ||
event_type = models.CharField(max_length=100, | ||
choices=event_type_choices) | ||
|
||
location = models.CharField(max_length=200) | ||
ticket_price = models.DecimalField(max_digits=10, decimal_places=2) | ||
created_at = models.DateTimeField(auto_now_add=True) | ||
updated_at = models.DateTimeField(auto_now=True) | ||
|
||
|
||
def __str__(self): | ||
return self.title |
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,12 @@ | ||
from rest_framework import serializers | ||
from .models import Event | ||
|
||
class EventSerializer(serializers.ModelSerializer) : | ||
class Meta: | ||
model = Event | ||
fields = '__all__' | ||
extra_kwargs = { | ||
'created_at': {'read_only': True}, | ||
'updated_at': {'read_only': True}, | ||
} | ||
|
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 .views import EventViewSet | ||
from rest_framework.routers import DefaultRouter | ||
|
||
router = DefaultRouter() | ||
router.register('', EventViewSet, basename='event') | ||
|
||
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 Event | ||
from .serializers import EventSerializer | ||
|
||
# Create your views here. | ||
|
||
class EventViewSet(viewsets.ModelViewSet): | ||
queryset = Event.objects.all() | ||
serializer_class = EventSerializer |