Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 95 additions & 89 deletions static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -138,92 +138,98 @@ p {


.seat-map {
display: flex;
flex-direction: column;
}

.seat-row {
display: flex;
justify-content: center;
}

.seat {
display: inline-block;
padding: 5px;
margin: 2px;
border: 1px solid #ccc;
border-radius: 3px;
background-color: #fff;
}

.booked {
background-color: #ccc;
}

.empty-seat {
display: inline-block;
padding: 5px;
margin: 2px;
border: 1px solid #a81e1e;
border-radius: 3px;
background-color: #f4ad12;
}
.profile-page {
margin: 0 auto;
width: 500px;
min-height: 100vh;
background-color: #fff;
padding: 20px;
}

.profile-image {
width: 100px;
height: 100px;
border-radius: 50%;
float: left;
margin-right: 20px;
}

.image-container {
display: flex;
justify-content: center;
align-items: center;
}
.profile-info {
margin-top: 20px;
}

.profile-name {
font-size: 20px;
font-weight: bold;
}

.profile-email {
font-size: 16px;
}

.profile-bio {
font-size: 14px;
line-height: 1.5;
}

.booked-shows {
margin-top: 20px;
}

.booked-show {
margin-bottom: 10px;
}

.booked-show-title {
font-size: 18px;
font-weight: bold;
}

.booked-show-date {
font-size: 16px;
}

.booked-show-time {
font-size: 14px;
}
display: flex;
flex-direction: column;
}

.seat-row {
display: flex;
justify-content: center;
}

.seat {
display: inline-block;
padding: 5px;
margin: 2px;
border: 1px solid #ccc;
border-radius: 3px;
background-color: #fff;
}

.booked {
background-color: #ccc;
}

.empty-seat {
display: inline-block;
padding: 5px;
margin: 2px;
border: 1px solid #a81e1e;
border-radius: 3px;
background-color: #f4ad12;
}
.profile-page {
margin: 0 auto;
width: 500px;
min-height: 100vh;
background-color: #fff;
padding: 20px;
}

.profile-image {
width: 100px;
height: 100px;
border-radius: 50%;
float: left;
margin-right: 20px;
}

.image-container {
display: flex;
justify-content: center;
align-items: center;
}
.profile-info {
margin-top: 20px;
}

.profile-name {
font-size: 20px;
font-weight: bold;
}

.profile-email {
font-size: 16px;
}

.profile-bio {
font-size: 14px;
line-height: 1.5;
}

.booked-shows {
margin-top: 20px;
}

.booked-show {
margin-bottom: 10px;
}

.booked-show-title {
font-size: 18px;
font-weight: bold;
}

.booked-show-date {
font-size: 16px;
}

.booked-show-time {
font-size: 14px;
}

.stars {
color: gold;
font-size: 24px;
margin-right: 2px;
}
19 changes: 18 additions & 1 deletion user/forms.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
from django.contrib.auth.forms import UserCreationForm
from django import forms
from .models import Show
from .models import Show,UserRating

class ShowForm(forms.ModelForm):
class Meta:
model = Show
fields = ['movie', 'time', 'uuid']

class UserRatingForm(forms.ModelForm):
class Meta:
model = UserRating
fields = ['stars']


widgets = {
'stars': forms.NumberInput(attrs={
'type': 'range',
'min': '0',
'max': '5',
'step': '0.5',
'value': '2.5',
'oninput': "document.getElementById('ratingValue').innerText = this.value"
}),
}
9 changes: 9 additions & 0 deletions user/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@ class Movies(models.Model):
description = models.TextField()
poster = models.ImageField(upload_to='movie_posters/')
available = models.BooleanField(default=True)
stars = models.FloatField(null=True, blank=True)


def __str__(self):
return self.title


class UserRating(models.Model):
movie = models.ForeignKey(Movies, on_delete=models.CASCADE, related_name='user_ratings')
stars = models.FloatField()
created_at = models.DateTimeField(auto_now_add=True)


class Show(models.Model):
movie = models.ForeignKey(Movies, on_delete=models.CASCADE)
time = models.DateTimeField()
uuid = models.CharField(max_length=32, unique=True)


def __str__(self):
return f"{self.movie.title} ({self.time.strftime('%Y-%m-%d %H:%M')})"

Expand Down
46 changes: 36 additions & 10 deletions user/templates/movie_list.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,48 @@
{% extends 'base.html' %}

{% load star_rating %} {# Load the custom filter here #}

{% block content %}
<head>
<title>Movie List</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
</head>
<body>
<h1>Movie List</h1>
<ul>
{% for movie in movies %}
<div style="padding: 10px;">
<li id="textTitle">{{ movie.title }}</li>
<li>{{ movie.description }}</li>
<img src="{{ movie.poster.url }}" width="200px" height="100px" alt="{{ movie.title }} poster">

</div>
{% empty %}
<li>No movies available.</li>
{% endfor %}

{% for movie in movie_data_list %}
<div style="padding: 10px;">
<li>{{ movie.movie.title }}</li>
<li>{{ movie.movie.description }}</li>
<li><img src="{{ movie.movie.poster.url }}" width="100" alt="{{ movie.movie.title }} poster"></li>

{# Display the star rating for the movie from your model #}
<li>
<strong>IMDB rating :</strong>
<span class="stars">
{{ movie.movie.stars|fa_star_rating|safe }} {# Use the filter to render stars #}
</span>
</li>

{# Display the latest user rating if available #}
{% if movie.latest_rating or movie.latest_rating == 0 %}
<li>
<strong>Latest User Rating:</strong><br>
<span class="stars">
{{ movie.latest_rating|fa_star_rating|safe }}<br>
</span>
</li>
{% endif %}

<li>
<a href="{% url 'user:movie_review' movie.movie.id %}" class="btn">Add rating!</a>
</li>
</div>
{% empty %}
<li>No movies available.</li>
{% endfor %}

</ul>
</body>
{% endblock %}
22 changes: 22 additions & 0 deletions user/templates/review.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends 'base.html' %}

{% block content %}
<head>
<title>Review {{ movie.title }}</title>
</head>
<body>
<h1>Review {{ movie.title }}</h1>

<form method="post">
{% csrf_token %}
<label for="rating">Rate this movie:</label>
<input type="range" id="rating" name="stars" min="0" max="5" step="0.5" value="2.5" oninput="document.getElementById('ratingValue').innerText = this.value">
<span id="ratingValue">2.5</span>/5
<br>
<button type="submit">Submit Rating</button>
</form>

<br>
<a href="{% url 'user:movie_list' %}">Back to Movie List</a>
</body>
{% endblock %}
Empty file added user/templatetags/__init__.py
Empty file.
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions user/templatetags/star_rating.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from django import template

register = template.Library()

@register.filter
def fa_star_rating(value):
if not value or not isinstance(value, (int, float)):
return ''

full_stars = int(value)
half_star = 1 if (value - full_stars) >= 0.5 else 0
empty_stars = 5 - full_stars - half_star

# Full stars
stars_html = '<i class="fas fa-star"></i>' * full_stars
# Half star
if half_star:
stars_html += '<i class="fas fa-star-half-alt"></i>'
# Empty stars
stars_html += '<i class="far fa-star"></i>' * empty_stars

return stars_html
4 changes: 2 additions & 2 deletions user/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.views.generic import TemplateView
from django.contrib.auth.views import LogoutView

from .views import shows,add_movie,AddShowView,MovieAutocomplete,movie_list,book_ticket
from .views import shows,add_movie,AddShowView,MovieAutocomplete,movie_list,book_ticket,movie_review

urlpatterns = [

Expand All @@ -14,6 +14,6 @@
path('add_show/', AddShowView.as_view(), name='AddShowView'),
path('book_ticket/<int:show_id>/', book_ticket, name='book_ticket'),
path('autocomplete/', MovieAutocomplete.as_view(), name='movie_autocomplete'),

path('review/<int:movie_id>/', movie_review, name='movie_review'),

]
Loading