Skip to content

Commit

Permalink
lint: lol I didn't even have flake8 installed
Browse files Browse the repository at this point in the history
  • Loading branch information
esinx committed Oct 26, 2023
1 parent 8938faf commit 05d2b5e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
10 changes: 1 addition & 9 deletions backend/announcements/admin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
from django.conf import settings
from django.contrib import admin
from django.contrib.auth.models import Permission
from django.shortcuts import redirect
from django.urls import reverse

from announcements.models import (
Audience,
Announcement
)
from announcements.models import Audience, Announcement

admin.site.register(Audience)
admin.site.register(Announcement)
10 changes: 8 additions & 2 deletions backend/announcements/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,15 @@ class Announcement(models.Model):
choices=ANNOUNCEMENT_CHOICES,
default=ANNOUNCEMENT_NOTICE,
)
audiences = models.ManyToManyField("Audience", related_name="announcements")
audiences = models.ManyToManyField("Audience",
related_name="announcements")
release_time = models.DateTimeField(auto_now_add=True)
end_time = models.DateTimeField(null=True, blank=True)

def __str__(self):
return f"[{self.get_announcement_type_display()} for {','.join([audience.name for audience in self.audiences.all()])}] starting at {self.release_time.strftime('%m-%d-%Y %H:%M:%S')} {f'''to {self.end_time.strftime('%m-%d-%Y %H:%M:%S')}''' if self.end_time else ''} | {f'{self.title}: ' if self.title else ''} {self.message}"
return f"""[{self.get_announcement_type_display()}
for {','.join([audience.name for audience in self.audiences.all()])}]
starting at {self.release_time.strftime('%m-%d-%Y %H:%M:%S')}
{f'to {self.end_time.strftime("%m-%d-%Y %H:%M:%S")}'
if self.end_time else ''}
| {f'{self.title}: ' if self.title else ''} {self.message}"""
3 changes: 2 additions & 1 deletion backend/announcements/permissions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from rest_framework import permissions


class IsSuperuser(permissions.BasePermission):
"""
Grants permission if the current user is a superuser.
Expand All @@ -9,4 +10,4 @@ def has_object_permission(self, request, view, obj):
return request.user.is_authenticated and request.user.is_superuser

def has_permission(self, request, view):
return request.user.is_authenticated and request.user.is_superuser
return request.user.is_authenticated and request.user.is_superuser
4 changes: 2 additions & 2 deletions backend/announcements/serializers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from rest_framework import serializers
from announcements.models import Announcement, Audience

class AudienceSerializer(serializers.ModelSerializer):

class AudienceSerializer(serializers.ModelSerializer):
class Meta:
model = Audience
fields = "__all__"

class AnnouncementSerializer(serializers.ModelSerializer):

class AnnouncementSerializer(serializers.ModelSerializer):
class Meta:
model = Announcement
fields = "__all__"
1 change: 0 additions & 1 deletion backend/announcements/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.urls import path
from announcements.views import AnnouncementsViewSet
from rest_framework import routers

Expand Down

0 comments on commit 05d2b5e

Please sign in to comment.