Skip to content

Commit

Permalink
Remove unnecessary django imports
Browse files Browse the repository at this point in the history
  • Loading branch information
dkwncho committed Dec 11, 2024
1 parent c67ed2b commit e765e92
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
15 changes: 5 additions & 10 deletions backend/ohq/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
from email_tools.emails import send_email
from phonenumber_field.modelfields import PhoneNumberField
from schedule.models import Event, Occurrence
from django.utils.translation import gettext, gettext_lazy as _
from django.template.defaultfilters import date
from django.conf import settings as django_settings
from django.urls import reverse

User = settings.AUTH_USER_MODEL

Expand Down Expand Up @@ -459,8 +455,8 @@ class Booking(models.Model):

occurrence = models.ForeignKey(Occurrence, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
start = models.DateTimeField(_("start"), db_index=True, blank=True)
end = models.DateTimeField(_("end"), db_index=True, blank=True)
start = models.DateTimeField(_("start"), db_index=True)
end = models.DateTimeField(_("end"), db_index=True)

class Meta:
verbose_name = _("booking")
Expand All @@ -469,7 +465,6 @@ class Meta:
index_together = (("start", "end"),)

def __str__(self):
return gettext("%(start)s to %(end)s") % {
"start": date(self.start, django_settings.DATE_FORMAT),
"end": date(self.end, django_settings.DATE_FORMAT),
}
start_str = self.start.strftime("%Y-%m-%d %H:%M:%S")
end_str = self.end.strftime("%Y-%m-%d %H:%M:%S")
return f"{start_str} to {end_str}"
5 changes: 1 addition & 4 deletions backend/ohq/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,7 @@ def has_object_permission(self, request, view, obj):
if field in restricted_student_fields:
return False
if "user" in updated_fields:
if booking.user is not None: # Doesn’t allow a student to update user if someone already booked the slot
return False
else:
return True
return booking.user is None # Doesn’t allow a student to update user if someone already booked the slot
else:
return False

Expand Down
2 changes: 0 additions & 2 deletions backend/ohq/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
from django.http import HttpResponseBadRequest, JsonResponse
from django.utils import timezone
from django.utils.crypto import get_random_string
from django.utils.translation import gettext_lazy as _
from django.conf import settings as django_settings
from django_auto_prefetching import prefetch
from django_filters.rest_framework import DjangoFilterBackend
from drf_excel.mixins import XLSXFileMixin
Expand Down

0 comments on commit e765e92

Please sign in to comment.