├── home ├── __init__.py ├── migrations │ └── __init__.py ├── tests.py ├── apps.py ├── admin.py ├── templates │ └── register.html ├── models.py ├── views.py ├── forms.py └── fixtures │ └── data.json ├── movie ├── __init__.py ├── migrations │ └── __init__.py ├── tests.py ├── apps.py ├── admin.py ├── urls.py ├── templates │ └── movie │ │ ├── movie_list.html │ │ └── movie_detail.html ├── views.py └── models.py ├── BoxOffice ├── __init__.py ├── wsgi.py ├── urls.py └── settings.py ├── booking ├── __init__.py ├── migrations │ └── __init__.py ├── tests.py ├── apps.py ├── admin.py ├── forms.py ├── templates │ ├── payment_confirmation.html │ ├── booking │ │ ├── booking_list.html │ │ ├── booking_confirm_delete.html │ │ └── booking_detail.html │ ├── reserve_seat.html │ └── payment_gateway.html ├── urls.py ├── models.py └── views.py ├── theatre ├── __init__.py ├── migrations │ └── __init__.py ├── tests.py ├── apps.py ├── admin.py ├── urls.py ├── templates │ └── theatre │ │ ├── theatre_list.html │ │ └── theatre_detail.html ├── models.py └── views.py ├── media_cdn ├── Koala.jpg ├── Thumbs.db ├── vimal.jpg ├── Desert.jpg ├── Penguins.jpg ├── Tulips.jpg ├── Hydrangeas.jpg ├── Jellyfish.jpg ├── Lighthouse.jpg ├── spiderman.jpg ├── Chrysanthemum.jpg ├── Dhadak-Poster.jpg ├── Hydrangeas_iSO6RvW.jpg ├── Jellyfish_A0BbLJ6.jpg ├── Penguins_WgeUYGD.jpg ├── aquaman-poster_1.jpg ├── venompostertransform.jpg ├── pantherposterhandsmain.jpg ├── shazam-2019-4j-1280x720.jpg ├── avengers-imax-main-large.jpg ├── 6e4c9a46586277.585a697fc8756.jpg ├── aquaman_in_justice_league-wallpaper-1280x720.jpg ├── venom_superhero_movie_tom_hardy-wallpaper-1280x720.jpg ├── official_shazam__movie_poster_by_superman9838-dccc6l9.jpg ├── captain_america_civil_war_black_panther-wallpaper-1280x720.jpg ├── venom_superhero_movie_tom_hardy-wallpaper-1280x720_PYx4juP.jpg └── avengers_infinity_war_2018_movie_fan_art-wallpaper-1280x720.jpg ├── static ├── images │ ├── Thumbs.db │ ├── ui-icons_444444_256x240.png │ ├── ui-icons_555555_256x240.png │ ├── ui-icons_777620_256x240.png │ ├── ui-icons_777777_256x240.png │ ├── ui-icons_cc0000_256x240.png │ └── ui-icons_ffffff_256x240.png ├── bootstrap │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ ├── js │ │ ├── npm.js │ │ └── bootstrap.min.js │ └── css │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap-theme.min.css.map │ │ └── bootstrap-theme.css ├── style.css └── common.js ├── .gitattributes ├── .project ├── manage.py ├── .pydevproject ├── README.md └── templates ├── search.html ├── registration └── login.html ├── home.html └── base.html /home/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /movie/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /BoxOffice/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /booking/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /theatre/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /home/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /movie/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /booking/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /theatre/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /booking/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /home/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /movie/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /theatre/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /home/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class HomeConfig(AppConfig): 5 | name = 'home' 6 | -------------------------------------------------------------------------------- /movie/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class MovieConfig(AppConfig): 5 | name = 'movie' 6 | -------------------------------------------------------------------------------- /media_cdn/Koala.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/Koala.jpg -------------------------------------------------------------------------------- /media_cdn/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/Thumbs.db -------------------------------------------------------------------------------- /media_cdn/vimal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/vimal.jpg -------------------------------------------------------------------------------- /booking/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class BookingConfig(AppConfig): 5 | name = 'booking' 6 | -------------------------------------------------------------------------------- /media_cdn/Desert.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/Desert.jpg -------------------------------------------------------------------------------- /media_cdn/Penguins.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/Penguins.jpg -------------------------------------------------------------------------------- /media_cdn/Tulips.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/Tulips.jpg -------------------------------------------------------------------------------- /theatre/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class TheatreConfig(AppConfig): 5 | name = 'theatre' 6 | -------------------------------------------------------------------------------- /media_cdn/Hydrangeas.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/Hydrangeas.jpg -------------------------------------------------------------------------------- /media_cdn/Jellyfish.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/Jellyfish.jpg -------------------------------------------------------------------------------- /media_cdn/Lighthouse.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/Lighthouse.jpg -------------------------------------------------------------------------------- /media_cdn/spiderman.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/spiderman.jpg -------------------------------------------------------------------------------- /static/images/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/static/images/Thumbs.db -------------------------------------------------------------------------------- /media_cdn/Chrysanthemum.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/Chrysanthemum.jpg -------------------------------------------------------------------------------- /media_cdn/Dhadak-Poster.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/Dhadak-Poster.jpg -------------------------------------------------------------------------------- /movie/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Movie 3 | # Register your models here. 4 | admin.site.register(Movie) -------------------------------------------------------------------------------- /media_cdn/Hydrangeas_iSO6RvW.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/Hydrangeas_iSO6RvW.jpg -------------------------------------------------------------------------------- /media_cdn/Jellyfish_A0BbLJ6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/Jellyfish_A0BbLJ6.jpg -------------------------------------------------------------------------------- /media_cdn/Penguins_WgeUYGD.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/Penguins_WgeUYGD.jpg -------------------------------------------------------------------------------- /media_cdn/aquaman-poster_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/aquaman-poster_1.jpg -------------------------------------------------------------------------------- /media_cdn/venompostertransform.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/venompostertransform.jpg -------------------------------------------------------------------------------- /media_cdn/pantherposterhandsmain.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/pantherposterhandsmain.jpg -------------------------------------------------------------------------------- /media_cdn/shazam-2019-4j-1280x720.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/shazam-2019-4j-1280x720.jpg -------------------------------------------------------------------------------- /media_cdn/avengers-imax-main-large.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/avengers-imax-main-large.jpg -------------------------------------------------------------------------------- /media_cdn/6e4c9a46586277.585a697fc8756.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/6e4c9a46586277.585a697fc8756.jpg -------------------------------------------------------------------------------- /static/images/ui-icons_444444_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/static/images/ui-icons_444444_256x240.png -------------------------------------------------------------------------------- /static/images/ui-icons_555555_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/static/images/ui-icons_555555_256x240.png -------------------------------------------------------------------------------- /static/images/ui-icons_777620_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/static/images/ui-icons_777620_256x240.png -------------------------------------------------------------------------------- /static/images/ui-icons_777777_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/static/images/ui-icons_777777_256x240.png -------------------------------------------------------------------------------- /static/images/ui-icons_cc0000_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/static/images/ui-icons_cc0000_256x240.png -------------------------------------------------------------------------------- /static/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/static/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /theatre/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Theatre ,Show 3 | # Register your models here. 4 | admin.site.register(Theatre) 5 | admin.site.register(Show) -------------------------------------------------------------------------------- /static/bootstrap/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/static/bootstrap/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /static/bootstrap/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/static/bootstrap/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /static/bootstrap/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/static/bootstrap/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /static/bootstrap/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/static/bootstrap/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /media_cdn/aquaman_in_justice_league-wallpaper-1280x720.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/aquaman_in_justice_league-wallpaper-1280x720.jpg -------------------------------------------------------------------------------- /media_cdn/venom_superhero_movie_tom_hardy-wallpaper-1280x720.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/venom_superhero_movie_tom_hardy-wallpaper-1280x720.jpg -------------------------------------------------------------------------------- /media_cdn/official_shazam__movie_poster_by_superman9838-dccc6l9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/official_shazam__movie_poster_by_superman9838-dccc6l9.jpg -------------------------------------------------------------------------------- /BoxOffice/wsgi.py: -------------------------------------------------------------------------------- 1 | 2 | import os 3 | 4 | from django.core.wsgi import get_wsgi_application 5 | 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "BoxOffice.settings") 7 | 8 | application = get_wsgi_application() 9 | -------------------------------------------------------------------------------- /media_cdn/captain_america_civil_war_black_panther-wallpaper-1280x720.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/captain_america_civil_war_black_panther-wallpaper-1280x720.jpg -------------------------------------------------------------------------------- /media_cdn/venom_superhero_movie_tom_hardy-wallpaper-1280x720_PYx4juP.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/venom_superhero_movie_tom_hardy-wallpaper-1280x720_PYx4juP.jpg -------------------------------------------------------------------------------- /media_cdn/avengers_infinity_war_2018_movie_fan_art-wallpaper-1280x720.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimalpillai21/online-movie-ticket-booking-system/HEAD/media_cdn/avengers_infinity_war_2018_movie_fan_art-wallpaper-1280x720.jpg -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | media_cdn/* linguist-detectable=false 2 | static/* linguist-detectable=false 3 | templates/* linguist-detectable=false 4 | movie/templates/* linguist-detectable=false 5 | theatre/templates/* linguist-detectable=false 6 | -------------------------------------------------------------------------------- /booking/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import BookedSeat,Booking,Seat 3 | # Register your models here. 4 | 5 | admin.site.register(BookedSeat) 6 | admin.site.register(Booking) 7 | admin.site.register(Seat) 8 | -------------------------------------------------------------------------------- /theatre/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | from .views import TheatreListView, theatre_details 3 | app_name = 'theatre' 4 | urlpatterns = [ 5 | url(r'^$', TheatreListView.as_view(), name='list'), 6 | url(r'^(?P\d+)/$', theatre_details, name='detail') 7 | ] -------------------------------------------------------------------------------- /movie/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | from .views import MovieListView, movie_details 3 | 4 | app_name = 'movie' 5 | 6 | urlpatterns = [ 7 | 8 | url(r'^$', MovieListView.as_view(), name='list'), 9 | url(r'^(?P\d+)/$', movie_details, name='detail'), 10 | 11 | ] -------------------------------------------------------------------------------- /booking/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from .models import Seat, Booking 3 | 4 | 5 | class SeatForm(forms.ModelForm): 6 | 7 | class Meta: 8 | model = Seat 9 | fields = ('seat_type',) 10 | 11 | 12 | class BookingForm(forms.ModelForm): 13 | 14 | class Meta: 15 | model = Booking 16 | fields = ('payment_type',) -------------------------------------------------------------------------------- /booking/templates/payment_confirmation.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %} 4 | BoxOffice | Payment 5 | {% endblock %} 6 | 7 | {% block content %} 8 | 9 |

Payment Confirmation

10 |




11 |

Booking Done!

12 | 13 | 14 | {% endblock %} -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BoxOffice 4 | 5 | 6 | 7 | 8 | 9 | org.python.pydev.PyDevBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.python.pydev.pythonNature 16 | org.python.pydev.django.djangoNature 17 | 18 | 19 | -------------------------------------------------------------------------------- /static/bootstrap/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "BoxOffice.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /.pydevproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DJANGO_MANAGE_LOCATION 5 | manage.py 6 | 7 | 8 | /${PROJECT_DIR_NAME} 9 | 10 | python interpreter 11 | Default 12 | 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # online-movie-ticket-booking-system 2 | This is an online movie ticket booking website made using following technologies:- 3 | 1. Python-3.6 4 | 2. Django-2.0.3 5 | 3. JavaScript 6 | 4. JQuery-3.3.1 7 | 5. Bootstrap3 8 | 9 | This project contains following apps:- 10 | 1. theatre app 11 | 2. movie app 12 | 3. booking app 13 | 4. home app 14 | 15 | In this project custom user model has been used rather than default user model. 16 | 17 | There are list and detail views of theatre, movie etc. 18 | Movie list view displays the movie. 19 | Theatre list view displays all the theatres in a city. 20 | Booking list view displays our booking. 21 | 22 | -------------------------------------------------------------------------------- /booking/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | from .views import payment_gateway, payment_confirmation, reserve_seat,BookingListView,BookingDetailView\ 3 | ,BookingDeleteView 4 | app_name = 'booking' 5 | urlpatterns = [ 6 | url(r'^seatchoice/(?P\d+)/$', reserve_seat, name='reserve_seat'), 7 | url(r'^payment/$', payment_gateway, name='payment_gateway'), 8 | url(r'^payment_confirmation/$', payment_confirmation, name='payment_confirmation'), 9 | url(r'^$', BookingListView.as_view(), name='list'), 10 | url(r'^(?P.*)/delete/$', BookingDeleteView.as_view(), name='delete') 11 | , url(r'^(?P.*)/$', BookingDetailView.as_view(), name='detail'), 12 | # url(r'^(?P.*)/delete/$', BookingDeleteView.as_view(), name='delete') 13 | ] -------------------------------------------------------------------------------- /booking/templates/booking/booking_list.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %} 4 | BoxOffice | Booking 5 | {% endblock %} 6 | 7 | {% block content %} 8 | 9 | 10 |

My Bookings

11 | 12 | 13 |
14 |

15 | {% if object_list %} 16 | 17 |
18 |
    19 | 20 | 21 | {% for book in object_list %} 22 |
  • {{ book }}
  • 23 |
    24 | {% endfor %} 25 |
    26 |
27 |
28 | 29 | {% else %} 30 |

No Bookings to Show

31 | {% endif %} 32 | {% endblock %} -------------------------------------------------------------------------------- /booking/templates/booking/booking_confirm_delete.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %} 4 | BoxOffice | Delete 5 | {% endblock %} 6 | 7 | {% block content %} 8 | 9 |
{% csrf_token %} 10 |















11 |
12 |
13 |

Are you sure you want to delete"{{ object }}"?

14 |
15 |
16 |
17 |
18 |        19 |
20 |
21 |
22 | 23 | {% endblock %} -------------------------------------------------------------------------------- /theatre/templates/theatre/theatre_list.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %} 4 | BoxOffice|Theatres 5 | {% endblock %} 6 | 7 | {% block content %} 8 | 9 | 10 | {% for category in theatres %} 11 |
12 |
13 |

Theatres in {{ category.0.city }}

14 |
15 | 24 |
25 | {% endfor %} 26 | 27 | {% endblock %} -------------------------------------------------------------------------------- /booking/templates/reserve_seat.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %} 4 | BoxOffice | Reserve Seats 5 | {% endblock %} 6 | 7 | {% block content %} 8 | 9 |

Select Seats

10 |

{{ show_info }}

11 |
12 |
13 |
14 |
15 |
16 | {% csrf_token %} 17 | {{ form.as_p }} 18 | Seats: 19 |

20 | Total number of seats: 0 21 | 22 |

23 | 24 |
25 |
26 |
27 | 28 | 29 | {% endblock %} -------------------------------------------------------------------------------- /home/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.contrib.auth.admin import UserAdmin as BaseUserAdmin 3 | from .forms import UserAdminCreationForm, UserAdminChangeForm 4 | from .models import User 5 | # Register your models here. 6 | class UserAdmin(BaseUserAdmin): 7 | form = UserAdminChangeForm 8 | add_form = UserAdminCreationForm 9 | 10 | list_display = ('email','admin') 11 | list_filter = ('admin','staff','active') 12 | fieldsets = ( 13 | (None,{'fields':('email','password')}), 14 | #('Personal Info',{'fields':('full_name',)}), 15 | ('Permissions',{'fields':('active','staff','admin')}), 16 | ) 17 | add_fieldsets = ( 18 | (None,{'classes':('wide'), 19 | 'fields':('email','password1','password2')} 20 | 21 | ), 22 | ) 23 | search_fields = ('email','full_name') 24 | ordering = ('email',) 25 | filter_horizontal = () 26 | 27 | admin.site.register(User,UserAdmin) 28 | #admin.site.unregister(Group) -------------------------------------------------------------------------------- /BoxOffice/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.contrib import admin 3 | from django.urls import path 4 | from django.conf import settings 5 | from django.contrib.auth.views import LoginView, LogoutView 6 | from django.conf.urls.static import static 7 | from django.conf.urls import url,include 8 | from home.views import ShowIndex, RegisterView, LoginView,SearchView 9 | 10 | urlpatterns = [ 11 | path('admin/', admin.site.urls), 12 | url(r'^login/$',LoginView.as_view(),name = 'login'), 13 | url(r'^logout/$',LogoutView.as_view(),name = 'logout'), 14 | url(r'^$', ShowIndex.as_view()), 15 | url(r'^search/$', SearchView.as_view(),name='search'), 16 | url(r'^movies/', include('movie.urls',namespace='movie')), 17 | url(r'^booking/', include('booking.urls',namespace='booking')), 18 | url(r'^theatres/', include('theatre.urls',namespace='theatre')), 19 | url(r'^register/$',RegisterView.as_view(),name='register'), 20 | ] 21 | 22 | 23 | if settings.DEBUG: 24 | urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) 25 | -------------------------------------------------------------------------------- /home/templates/register.html: -------------------------------------------------------------------------------- 1 | 2 | {% extends "base.html" %} 3 | {% block content %} 4 |
5 |

Register

6 |
7 | {% csrf_token %} 8 |
9 | {{ form.email.errors }} 10 | 11 | {{ form.email }} 12 |

13 |
14 | {{ form.password1.errors }} 15 | 16 | {{ form.password1 }} 17 |

18 |
19 | {{ form.password2.errors }} 20 | 21 | {{ form.password2 }} 22 |


23 | 24 | 25 |
26 |

Did you need to Login 27 |

28 | 29 | {% endblock %} -------------------------------------------------------------------------------- /booking/templates/booking/booking_detail.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %} 4 | BoxOffice | Booking 5 | {% endblock %} 6 | 7 | {% block content %} 8 |

Booking Details

9 |


10 | 11 |
12 |
13 | 14 |
15 |
16 | {{ object.id }} 17 |
18 |
19 |

20 |
21 |
22 | 23 |
24 |
25 | {{ object.timestamp }} 26 |
27 |
28 |

29 |
30 |
31 | 32 |
33 |
34 | {{ object.payment_type }} 35 |
36 |
37 |

38 |
39 |
40 | 41 |
42 |
43 | {{ object.paid_amount }} 44 |
45 |
46 |
47 |
48 |
49 | Delete 50 |
51 |
52 |
53 |
54 | {% endblock %} -------------------------------------------------------------------------------- /templates/search.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %} 4 | BoxOffice | Theatres 5 | {% endblock %} 6 | 7 | {% block content %} 8 |
9 |
10 | Results for {{ query }} 11 |
12 |
13 |
14 |
15 | 16 | {% if movie_list %} 17 | {% for movie in movie_list %} 18 |
19 |
20 |
21 | {{ movie.name }} 22 |
23 |

{{ movie.name }}

24 |

{{ movie.cast }}

25 |

{{ movie.language }} | {{ movie.certificate }}

26 |

Watch Trailer{% if user.is_authenticated %} Book Now{% endif %}

27 |
28 |
29 |
30 | {% if forloop.counter|divisibleby:3 %} 31 |
32 | {% endif %} 33 | {% endfor %} 34 | {% else %} 35 |

No Items Found!!!

36 | {% endif %} 37 |
38 | {% endblock %} -------------------------------------------------------------------------------- /theatre/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | from django.contrib.auth import get_user_model 5 | from movie.models import Movie 6 | from django.urls.base import reverse 7 | User = get_user_model() 8 | 9 | class Theatre(models.Model): 10 | city_choice=( 11 | ('DELHI','Delhi'), 12 | ('KOLKATA','Kolkata'), 13 | ('MUMBAI','Mumbai'), 14 | ('CHENNAI','Chennai'), 15 | ('BANGALORE','Bangalore'), 16 | ('HYDERABAD','Hyderabad') 17 | ) 18 | name = models.CharField(max_length=50,null=False) 19 | city = models.CharField(max_length=9,choices=city_choice,null=False) 20 | address = models.CharField(max_length=30) 21 | no_of_screen = models.IntegerField() 22 | admin_id = models.ForeignKey(User,on_delete=models.CASCADE) 23 | 24 | def __str__(self): 25 | return self.name+"-"+self.address+"-"+self.city 26 | 27 | def get_absolute_url(self): 28 | return reverse('theatre:detail',kwargs={'theatre_id':self.pk}) 29 | 30 | class Show(models.Model): 31 | movie = models.ForeignKey(Movie,on_delete=models.CASCADE) 32 | theatre = models.ForeignKey(Theatre,on_delete=models.CASCADE) 33 | screen = models.IntegerField() 34 | date = models.DateField() 35 | time = models.TimeField() 36 | 37 | def __str__(self): 38 | return str(self.movie)+"-"+str(self.theatre)+"-"+str(self.date)+"-"+str(self.time) 39 | -------------------------------------------------------------------------------- /templates/registration/login.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block content %} 3 | 4 |









5 |
6 |
7 |
8 |

LogIn

9 |
10 |
11 | {% if next %} 12 | {% if user.is_authenticated %} 13 |

Your Account doesn't have access to this page. To proceed, please 14 | login with an account that has access.

15 | {% endif %} 16 | {% endif %} 17 |
18 | {% csrf_token %} 19 |
20 |
21 |
22 | {{ form.email.label_tag }} 23 |
24 |
25 |
26 |
27 | {{ form.email }} 28 |
29 |
30 |

31 |
32 |
33 | {{ form.password.label_tag }} 34 |
35 |
36 |
37 |
38 | {{ form.password }} 39 |
40 |
41 |
42 | {% if form.non_field_errors %} 43 |

Your Username and Password didn't match. Please try again

44 | {% endif %} 45 |
46 |
47 |
48 | 49 |
50 |
51 | 52 |
53 |
54 |
55 |
56 | {% endblock %} -------------------------------------------------------------------------------- /movie/templates/movie/movie_list.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %} 4 | BoxOffice | Theatres 5 | {% endblock %} 6 | 7 | {% block content %} 8 |
9 | {% for category in movie_list %} 10 | 11 | 12 |
13 |

{{ category.0.language }} MOVIES

14 |
15 |
16 | {% for movie in category %} 17 |
18 |
19 | {{ movie.name }} 20 |
21 |

{{ movie.name }}

22 |

{{ movie.cast }}

23 |

{{ movie.language }} | {{ movie.certificate }}

24 |

Watch Trailer{% if user.is_authenticated %} Book Now{% endif %}

25 |
26 |
27 |
28 | {% if forloop.counter|divisibleby:3 or forloop.counter == category|length %} 29 |
30 | {% endif %} 31 | {% if forloop.counter != category|length %} 32 |
33 | 34 | {% endif %} 35 | {% endfor %} 36 |
37 | 38 | {% endfor %} 39 |
40 | {% endblock %} -------------------------------------------------------------------------------- /movie/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from .models import Movie 3 | from theatre.models import Show 4 | from django.views.generic import ListView 5 | # Create your views here. 6 | from django.shortcuts import Http404 7 | import datetime 8 | 9 | class MovieListView(ListView): 10 | def get_queryset(self): 11 | return Movie.objects.all().order_by('language') 12 | 13 | 14 | def get_context_data(self,*args, **kwargs): 15 | context = super(MovieListView,self).get_context_data(*args,**kwargs) 16 | movies = Movie.objects.all().order_by('language') 17 | movie_list = [] 18 | movie_by_lang = [] 19 | lang = movies[0].language 20 | for i in range(0, len(movies)): 21 | if lang != movies[i].language: 22 | lang = movies[i].language 23 | movie_list.append(movie_by_lang) 24 | movie_by_lang = [] 25 | movie_by_lang.append(movies[i]) 26 | movie_list.append(movie_by_lang) 27 | context['movie_list'] = movie_list 28 | return context 29 | 30 | 31 | def movie_details(request, movie_id): 32 | try: 33 | movie_info = Movie.objects.get(pk=movie_id) 34 | shows = Show.objects.filter(movie=movie_id, 35 | date=datetime.date.today()).order_by('theatre') 36 | show_list = [] 37 | 38 | if shows: 39 | show_by_theatre = [] 40 | theatre = shows[0].theatre 41 | for i in range(0, len(shows)): 42 | if theatre != shows[i].theatre: 43 | theatre = shows[i].theatre 44 | show_list.append(show_by_theatre) 45 | show_by_theatre = [] 46 | show_by_theatre.append(shows[i]) 47 | 48 | show_list.append(show_by_theatre) 49 | 50 | except Movie.DoesNotExist: 51 | raise Http404("Page does not exist") 52 | return render(request, 'movie/movie_detail.html', 53 | {'movie_info': movie_info, 'show_list': show_list}) 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /static/style.css: -------------------------------------------------------------------------------- 1 | div.Platinum, div.Gold, div.Silver{ 2 | width: 2.5em; 3 | border-top: 5px solid black; 4 | border-left: 2px solid black; 5 | border-right: 2px solid black; 6 | margin: 5px; 7 | text-align: center; 8 | } 9 | 10 | div.Platinum a, div.Gold a, div.Silver a{ 11 | color: black; 12 | text-decoration: none; 13 | } 14 | 15 | div.seatDiv{ 16 | width: 80%; 17 | } 18 | div.seatArray{ 19 | width: 80%; 20 | height: 50%; 21 | float: left; 22 | } 23 | div.seatForm{ 24 | width: 20%; 25 | float: right; 26 | } 27 | 28 | div.selectable{ 29 | border-top: 5px solid green!important; 30 | border-left: 2px solid green!important; 31 | border-right: 2px solid green!important; 32 | } 33 | 34 | div.selectable a{ 35 | color: green!important; 36 | cursor: pointer!important; 37 | } 38 | 39 | div.selected{ 40 | border-top: 3px solid blue!important; 41 | border-left: 1px solid blue!important; 42 | border-right: 1px solid blue!important; 43 | } 44 | 45 | div.selected a{ 46 | color: blue!important; 47 | cursor: pointer!important; 48 | } 49 | 50 | /*START: override bootsrtap styles*/ 51 | 52 | .navbar-static-top{ 53 | z-index: 99!important; 54 | } 55 | 56 | .ui-widget-overlay{ 57 | background-color: black!important; 58 | opacity:0.5!important; 59 | } 60 | 61 | .thumbnail img { 62 | min-height:250px; 63 | height:250px!important; 64 | width:350px!important; 65 | } 66 | 67 | .carousel-img { 68 | min-height:80vh; 69 | height:80vh!important; 70 | width:100vw!important; 71 | } 72 | 73 | div#myCarousel { 74 | height:70vh; 75 | width:80vw; 76 | margin-left:10vw; 77 | margin-right:10vw; 78 | margin-bottom:12vh; 79 | } 80 | 81 | ol.carousel-indicators { 82 | top:75vh!important; 83 | } 84 | 85 | div.carousel-caption { 86 | background-color: rgba(0,0,0,0.4); 87 | } 88 | 89 | .media-left img { 90 | width:120px!important; 91 | height:120px!important; 92 | } 93 | 94 | /*END: override bootsrtap styles*/ 95 | 96 | .forms{ 97 | background-color: #f2f2f2; 98 | padding:10px; 99 | margin:5px; 100 | } -------------------------------------------------------------------------------- /home/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.contrib.auth.models import AbstractBaseUser, BaseUserManager 3 | # Create your models here. 4 | class UserManager(BaseUserManager): 5 | def create_user(self, email, password=None,is_active=True,is_staff=False,is_admin=False): 6 | if not email: 7 | raise ValueError("Users must have an email address") 8 | user_obj = self.model(email=self.normalize_email(email)) 9 | user_obj.set_password(password) 10 | user_obj.active = is_active 11 | user_obj.staff = is_staff 12 | user_obj.admin = is_admin 13 | user_obj.save(using=self._db) 14 | return user_obj 15 | 16 | def create_staffuser(self,email,password=None): 17 | user = self.create_user( 18 | email=email, 19 | password=password, 20 | is_staff = True 21 | ) 22 | return user 23 | 24 | def create_superuser(self,email,password=None): 25 | user = self.create_user( 26 | email=email, 27 | password=password, 28 | is_staff=True, 29 | is_admin = True 30 | ) 31 | return user 32 | 33 | class User(AbstractBaseUser): 34 | email = models.EmailField(max_length=255,unique=True) 35 | active = models.BooleanField(default=True) 36 | staff = models.BooleanField(default=False) 37 | admin = models.BooleanField(default=False) 38 | timestamp = models.DateTimeField(auto_now_add=True) 39 | USERNAME_FIELD = 'email' 40 | REQUIRED_FIELDS= [] 41 | 42 | objects = UserManager() 43 | def __str__(self): 44 | return self.email 45 | 46 | @property 47 | def is_staff(self): 48 | return self.staff 49 | 50 | @property 51 | def is_active(self): 52 | return self.active 53 | 54 | @property 55 | def is_admin(self): 56 | return self.admin 57 | 58 | def has_perm(self,perm,obj=None): 59 | return True 60 | 61 | def has_module_perms(self,app_label): 62 | return True -------------------------------------------------------------------------------- /movie/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.db.models import Q 3 | from django.urls.base import reverse 4 | # Create your models here. 5 | class MovieQuerySet(models.query.QuerySet): 6 | def search(self,query): 7 | lookup = ( 8 | Q(name__icontains=query)| 9 | Q(director__icontains=query)| 10 | Q(language__icontains=query)| 11 | Q(cast__icontains=query) 12 | ) 13 | return self.filter(lookup).distinct() 14 | 15 | class MovieManager(models.Manager): 16 | def get_queryset(self): 17 | return MovieQuerySet(self.model,self._db) 18 | def search(self,query): 19 | return self.get_queryset().search(query) 20 | 21 | 22 | class Movie(models.Model): 23 | lang_choice=( 24 | ('ENGLISH','English'), 25 | ('BENGALI','Bengali'), 26 | ('HINDI','Hindi'), 27 | ('TAMIL','Tamil'), 28 | ('TELUGU','Telugu'), 29 | ('MALAYALAM','Malayalam'), 30 | ('MARATHI','Marathi'), 31 | ('FRENCH','French'), 32 | ) 33 | rating_choice=( 34 | ('U','U'), 35 | ('UA','U/A'), 36 | ('A','A'), 37 | ('R','R'), 38 | ) 39 | name = models.CharField(max_length=20) 40 | cast = models.CharField(max_length=100) 41 | director = models.CharField(max_length=20) 42 | language = models.CharField(max_length=10,choices=lang_choice) 43 | run_length = models.IntegerField(help_text='Enter run length in minutes') 44 | certificate = models.CharField(max_length=2,choices=rating_choice) 45 | popularity_index = models.IntegerField(unique=True,null=True,blank=True) 46 | trailer = models.URLField(blank=True) 47 | image = models.ImageField(null=True, blank=True) 48 | 49 | objects = MovieManager() 50 | 51 | def get_absolute_url(self): 52 | return reverse('movie:detail',kwargs={'movie_id':self.pk}) 53 | 54 | def __str__(self): 55 | return self.name -------------------------------------------------------------------------------- /booking/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.contrib.auth import get_user_model 3 | from theatre.models import Show 4 | from django.urls import reverse 5 | from django.db.models.signals import post_delete 6 | User = get_user_model() 7 | # Create your models here. 8 | 9 | 10 | class Booking(models.Model): 11 | payment_choice = ( 12 | ('Debit Card', 'Debit Card'), 13 | ('Credit Card', 'Credit Card'), 14 | ('Net Banking', 'Net Banking'), 15 | ('Wallet', 'Wallet'), 16 | ) 17 | id = models.CharField(primary_key=True, max_length=200) 18 | timestamp = models.DateTimeField('%Y-%m-%d %H:%M:%S') 19 | payment_type = models.CharField(max_length=11, choices=payment_choice) 20 | paid_amount = models.DecimalField(max_digits=8, decimal_places=2) 21 | paid_by = models.ForeignKey(User, on_delete=models.DO_NOTHING) 22 | 23 | def __str__(self): 24 | return str(self.id) 25 | def get_absolute_url(self): 26 | return reverse('booking:detail',kwargs={'btid':self.id}) 27 | 28 | #def get_absolute_url(self): 29 | 30 | class Seat(models.Model): 31 | seat_choice = ( 32 | ('', 'Select'), 33 | ('Silver', 'Silver'), 34 | ('Gold', 'Gold'), 35 | ('Platinum', 'Platinum'), 36 | ) 37 | no = models.CharField(max_length=3) 38 | seat_type = models.CharField(max_length=8, choices=seat_choice, blank=False) 39 | show = models.ForeignKey(Show, on_delete=models.CASCADE) 40 | 41 | class Meta: 42 | unique_together = ('no', 'show') 43 | 44 | def __str__(self): 45 | return self.no + str(self.show) 46 | 47 | 48 | class BookedSeat(models.Model): 49 | seat = models.ForeignKey(Seat, on_delete=models.CASCADE) 50 | booking = models.ForeignKey(Booking, on_delete=models.CASCADE) 51 | 52 | class Meta: 53 | unique_together = ('seat', 'booking') 54 | 55 | def __str__(self): 56 | return str(self.seat) + '|' + str(self.booking) 57 | 58 | 59 | def delete_reverse(sender,instance,*args,**kwargs): 60 | try: 61 | if instance.seat: 62 | instance.seat.delete() 63 | except: 64 | pass 65 | 66 | post_delete.connect(delete_reverse,sender=BookedSeat) -------------------------------------------------------------------------------- /theatre/templates/theatre/theatre_detail.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %} 4 | BoxOffice|Theatre Details 5 | {% endblock %} 6 | 7 | {% block content %} 8 | 9 |
10 | 11 |
12 |

{{ theatre_info.name }}

13 |
14 | 15 |
16 |

{{ theatre_info.city }}

17 |
18 |
19 |
20 | 21 |
22 |

{{ theatre_info.address }}

23 |
24 |
25 |
26 | 27 |
28 |

{{ theatre_info.no_of_screen }}

29 |
30 |
31 |
32 | 33 |
34 |

9999999999

35 |
36 |
37 |
38 |
39 | 40 |
41 |
42 |

Now Showing

43 |
44 |
45 | {% if show_list %} 46 | {% for show in show_list %} 47 |
48 |
49 | 50 | {{ show.0.movie.name }} 51 | 52 |
53 |
54 |

{{ show.0.movie.name }}

55 |
    56 | {% for showtime in show %} 57 |
  • {% if user.is_authenticated %}{{ showtime.time|time:"h:i A" }}{% else %}

    {{ showtime.time|time:"h:i A" }}

    {% endif %}
  • 58 | {% endfor %} 59 |
60 |
61 |
62 | {% endfor %} 63 | {% else %} 64 |

No Shows

65 | {% endif %} 66 |
67 |
68 | 69 | {% endblock %} -------------------------------------------------------------------------------- /static/common.js: -------------------------------------------------------------------------------- 1 | function watchTrailer(name,url){ 2 | var html1 = ''; 3 | $(document).ready(function(){ 4 | $('
').html(html1).dialog({ 5 | resizable: false, 6 | height: 600, 7 | title: name, 8 | width: 1200, 9 | modal: true, 10 | close: function(){$(this).remove();} 11 | }); 12 | }); 13 | } 14 | 15 | function createSeatArray() { 16 | var seats_per_row = 15; 17 | var seats = {'Platinum':2, 'Gold':2, 'Silver':6}; 18 | var rows = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O']; 19 | var seat_array = "
"; 20 | var count = 0; 21 | for(var key in seats) 22 | { 23 | seat_array += ""; 24 | for(var i=0; i"; 27 | for(var j=1; j<=seats_per_row; j++) 28 | { 29 | seat_array += ""; 30 | } 31 | seat_array += ""; 32 | count++; 33 | } 34 | seat_array += "
"; 35 | } 36 | seat_array += "
"; 37 | return seat_array; 38 | } 39 | 40 | $(document).ready(function(){ 41 | 42 | //create seat array 43 | $('.seatArray').append(createSeatArray()); 44 | 45 | //show available seats of particular type 46 | $('#id_seat_type').change(function(){ 47 | seat_dict = {}; 48 | $('#selected_seat').attr('value',''); 49 | $('.selectable').removeClass('selectable selected'); 50 | var selector = $(this).val(); 51 | $('table.'+selector+' td div').addClass('selectable'); 52 | }); 53 | 54 | var seat_dict = {}; 55 | 56 | //change color of selected seat 57 | $(document).on('click', 'div.selectable', function(){ 58 | var curr_seat = $(this).text(); 59 | if(curr_seat in seat_dict){ 60 | delete seat_dict[curr_seat]; 61 | } 62 | else{ 63 | seat_dict[curr_seat] = curr_seat; 64 | } 65 | $(this).toggleClass('selected'); 66 | var selected_seat = []; 67 | for(var key in seat_dict) 68 | { 69 | selected_seat.push(key); 70 | } 71 | $('input#selected_seat').attr('value',selected_seat); 72 | $('#no_of_seats').text(selected_seat.length); 73 | }); 74 | }); -------------------------------------------------------------------------------- /home/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.core.exceptions import ValidationError 3 | from django.views.generic import View, CreateView, FormView, ListView 4 | from movie.models import Movie 5 | from django.contrib import messages 6 | from django.contrib.auth import authenticate, login, get_user_model 7 | #from django.http import HttpResponse 8 | from django.shortcuts import render, redirect 9 | from django.utils.http import is_safe_url 10 | 11 | from .forms import RegisterForm, LoginForm 12 | # Create your views here. 13 | class ShowIndex(View): 14 | def get(self,request,*args,**kwargs): 15 | movie_list = Movie.objects.all().order_by('popularity_index') 16 | top_movie = Movie.objects.all().order_by('popularity_index')[:3] 17 | context = {'movie_list':movie_list,'top_movie':top_movie} 18 | return render(request,'home.html',context) 19 | 20 | class SearchView(ListView): 21 | template_name = 'search.html' 22 | 23 | def get_context_data(self,*args, **kwargs): 24 | context = super(SearchView,self).get_context_data(*args,**kwargs) 25 | query = self.request.GET.get('q') 26 | context['query'] = query 27 | return context 28 | 29 | def get_queryset(self,*args,**kwargs): 30 | request = self.request 31 | print(request.GET) 32 | query = request.GET.get('q') 33 | if query is not None: 34 | query = query.strip() 35 | return Movie.objects.search(query) 36 | else: 37 | return Movie.objects.all() 38 | 39 | class RegisterView(CreateView): 40 | form_class = RegisterForm 41 | template_name = 'register.html' 42 | success_url = '/' 43 | 44 | class LoginView(FormView): 45 | form_class = LoginForm 46 | template_name = 'registration/login.html' 47 | success_url = '/' 48 | 49 | def form_valid(self,form): 50 | request = self.request 51 | next_ = request.GET.get("next") 52 | next_post = request.POST.get("next") 53 | redirect_path = next_ or next_post or None 54 | email = form.cleaned_data.get('email') 55 | password = form.cleaned_data.get('password') 56 | user = authenticate(request,username=email,password=password) 57 | if user is not None: 58 | print(user) 59 | login(request,user) 60 | if is_safe_url(redirect_path,request.get_host()): 61 | return redirect(redirect_path) 62 | else: 63 | return redirect("/") 64 | #print(form.non_field_errors) 65 | # s = super(FormView,self).form_invalid(form) 66 | # s.add 67 | return self.form_invalid(form) 68 | def form_invalid(self,form): 69 | form.add_error(None,"Username and password dont match") 70 | return super(FormView,self).form_invalid(form) 71 | 72 | 73 | -------------------------------------------------------------------------------- /movie/templates/movie/movie_detail.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %} 4 | BoxOffice | Movie Details 5 | {% endblock %} 6 | 7 | {% block content %} 8 | 9 | 10 |
11 |
12 | 13 | {{ movie_info.name }} 14 | 15 | Watch Trailer 16 |
17 |
18 |

{{ movie_info.name }}

19 |
20 | 21 |
22 |

{{ movie_info.cast }}

23 |
24 |
25 |
26 | 27 |
28 |

{{ movie_info.director }}

29 |
30 |
31 |
32 | 33 |
34 |

{{ movie_info.language }}

35 |
36 |
37 |
38 | 39 |
40 |

{{ movie_info.run_length }} mins

41 |
42 |
43 |
44 | 45 |
46 |

{{ movie_info.certificate }}

47 |
48 |
49 |
50 |
51 | 52 |
53 |
54 |

Now Showing

55 |
56 |
57 | {% if show_list %} 58 | {% for theatre in show_list %} 59 |
60 | 61 |
62 |

{{ theatre.0.theatre.name }} | {{ theatre.0.theatre.address }}

63 |
    64 | {% for showtime in theatre %} 65 |
  • {% if user.is_authenticated %}{{ showtime.time|time:"h:i A" }}{% else %}

    {{ showtime.time|time:"h:i A" }}

    {% endif %}
  • 66 | {% endfor %} 67 |
68 |
69 |
70 | {% endfor %} 71 | {% else %} 72 |

No Shows

73 | {% endif %} 74 |
75 |
76 | 77 | {% endblock %} -------------------------------------------------------------------------------- /home/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from django.db.transaction import on_commit 3 | from django.contrib.auth import get_user_model 4 | from django.contrib.auth.forms import ReadOnlyPasswordHashField 5 | User = get_user_model() 6 | 7 | 8 | class UserAdminCreationForm(forms.ModelForm): 9 | password1 = forms.CharField(label='Password',widget=forms.PasswordInput) 10 | password2 = forms.CharField(label='Password Confirmation',widget=forms.PasswordInput) 11 | 12 | class Meta: 13 | model = User 14 | fields = ('email',)#'full_name' 15 | 16 | def clean_password2(self): 17 | password1 = self.cleaned_data.get("password1") 18 | password2 = self.cleaned_data.get("password2") 19 | if password1 and password2 and password1 != password2: 20 | raise forms.ValidationError("Passwords don't match") 21 | return password2 22 | 23 | def save(self,commit=True): 24 | user = super(UserAdminCreationForm,self).save(commit=False) 25 | user.set_password(self.cleaned_data["password1"]) 26 | if commit: 27 | user.save() 28 | return user 29 | 30 | class UserAdminChangeForm(forms.ModelForm): 31 | password = ReadOnlyPasswordHashField() 32 | 33 | class Meta: 34 | model = User 35 | fields = ('email','password','active','staff','admin')#'full_name', 36 | 37 | def clean_password(self): 38 | return self.initial['password'] 39 | 40 | class RegisterForm(forms.ModelForm): 41 | password1 = forms.CharField(label='Password',widget=forms.PasswordInput(attrs={'class':'form-control'})) 42 | password2 = forms.CharField(label='Password Confirmation',widget=forms.PasswordInput(attrs={'class':'form-control'})) 43 | 44 | 45 | class Meta: 46 | model = User 47 | fields =('email',) 48 | widgets = { 49 | 'email' : forms.EmailInput(attrs={'class':'form-control','autofocus':'autofocus'}) 50 | } 51 | 52 | 53 | def clean_password2(self): 54 | password1 = self.cleaned_data.get("password1") 55 | password2 = self.cleaned_data.get("password2") 56 | if password1 and password2 and password1 != password2: 57 | raise forms.ValidationError("Passwords don't match") 58 | return password2 59 | 60 | def save(self,commit=True): 61 | user = super(RegisterForm,self).save(commit=False) 62 | user.set_password(self.cleaned_data["password1"]) 63 | user.active =False 64 | 65 | if on_commit: 66 | print(user) 67 | user.active =True 68 | user.save() 69 | 70 | return user 71 | 72 | class LoginForm(forms.Form): 73 | email = forms.EmailField(label='Email', widget = forms.TextInput(attrs={'class':'form-control','autofocus':'autofocus'})) 74 | password = forms.CharField(label='Password' ,widget = forms.PasswordInput(attrs={'class':'form-control'})) 75 | 76 | -------------------------------------------------------------------------------- /theatre/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from .models import Theatre, Show 3 | from django.views.generic import ListView, DetailView 4 | from django.shortcuts import get_object_or_404,Http404 5 | import datetime 6 | # Create your views here. 7 | class TheatreListView(ListView): 8 | def get_queryset(self): 9 | return Theatre.objects.all() 10 | 11 | 12 | def get_context_data(self, *args, **kwargs): 13 | context = super(TheatreListView,self).get_context_data(*args,**kwargs) 14 | theatres = Theatre.objects.all().order_by('city') 15 | theatre_list = [] 16 | theatre_by_city = [] 17 | city = theatres[0].city 18 | for i in range(0,len(theatres)): 19 | if city != theatres[i].city: 20 | city = theatres[i].city 21 | theatre_list.append(theatre_by_city) 22 | theatre_by_city =[] 23 | theatre_by_city.append(theatres[i]) 24 | theatre_list.append(theatre_by_city) 25 | print(theatre_list) 26 | 27 | context['theatres'] = theatre_list 28 | return context 29 | 30 | #class TheatreDetailView(DetailView): 31 | # def get_queryset(self): 32 | # return Theatre.objects.all() 33 | # 34 | # show_list=[] 35 | # show_by_movie = [] 36 | # 37 | # 38 | # def get_context_data(self,*args, **kwargs): 39 | # context = super(TheatreDetailView,self).get_context_data(*args,**kwargs) 40 | # rest_id = self.kwargs.get("pk") 41 | # obj = get_object_or_404(Theatre,id=rest_id) 42 | # 43 | # 44 | # shows = Show.objects.filter(theatre=obj,date=datetime.date.today()).order_by('movie') 45 | # movie = shows[0].movie 46 | # for i in range(0,len(shows)): 47 | # if movie != shows[i].movie: 48 | # movie = shows[i].movie 49 | # self.show_list.append(self.show_by_movie) 50 | # self.show_by_movie = [] 51 | # self.show_by_movie.append(shows[i]) 52 | # self.show_list.append(self.show_by_movie) 53 | 54 | 55 | 56 | # context['show_list'] = self.show_list 57 | #print(context) 58 | # return context 59 | def theatre_details(request, theatre_id): 60 | try: 61 | theatre_info = Theatre.objects.get(pk=theatre_id) 62 | shows = Show.objects.filter(theatre=theatre_id, 63 | date=datetime.date.today()).order_by('movie') 64 | 65 | show_list = [] 66 | if shows: 67 | show_by_movie = [] 68 | movie = shows[0].movie 69 | for i in range(0, len(shows)): 70 | if movie != shows[i].movie: 71 | movie = shows[i].movie 72 | show_list.append(show_by_movie) 73 | show_by_movie = [] 74 | show_by_movie.append(shows[i]) 75 | 76 | show_list.append(show_by_movie) 77 | 78 | print(show_list) 79 | 80 | except Theatre.DoesNotExist: 81 | raise Http404("Page does not exist") 82 | return render(request, 'theatre/theatre_detail.html', 83 | {'theatre_info': theatre_info, 'show_list': show_list}) 84 | -------------------------------------------------------------------------------- /templates/home.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %} 3 | BoxOffice|Home 4 | {% endblock %} 5 | {% block content %} 6 |