Skip to content

Commit

Permalink
Relint all with new black version
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-Jess committed Mar 24, 2024
1 parent f5dab36 commit ca54667
Show file tree
Hide file tree
Showing 39 changed files with 341 additions and 97 deletions.
4 changes: 3 additions & 1 deletion backend/dining/migrations/0003_venue_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Migration(migrations.Migration):

operations = [
migrations.AddField(
model_name="venue", name="name", field=models.CharField(max_length=255, null=True),
model_name="venue",
name="name",
field=models.CharField(max_length=255, null=True),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,24 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RemoveField(model_name="diningtransaction", name="profile",),
migrations.RemoveField(
model_name="diningtransaction",
name="profile",
),
migrations.AlterField(
model_name="diningitem", name="description", field=models.CharField(max_length=1000),
model_name="diningitem",
name="description",
field=models.CharField(max_length=1000),
),
migrations.AlterField(
model_name="diningitem", name="ingredients", field=models.CharField(max_length=1000),
model_name="diningitem",
name="ingredients",
field=models.CharField(max_length=1000),
),
migrations.DeleteModel(
name="DiningBalance",
),
migrations.DeleteModel(
name="DiningTransaction",
),
migrations.DeleteModel(name="DiningBalance",),
migrations.DeleteModel(name="DiningTransaction",),
]
10 changes: 6 additions & 4 deletions backend/gsr_booking/api_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,11 @@ def book_room(self, gid, rid, room_name, start, end, user, group=None):
members = (
[(user, datetime.timedelta(days=99))]
if group is None
else self.get_wharton_members(group, gsr.id)
if gsr.kind == GSR.KIND_WHARTON
else self.get_libcal_members(group)
else (
self.get_wharton_members(group, gsr.id)
if gsr.kind == GSR.KIND_WHARTON
else self.get_libcal_members(group)
)
)

total_time_available = sum(
Expand Down Expand Up @@ -457,7 +459,7 @@ def cancel_room(self, booking_id, user):
gsr_booking := GSRBooking.objects.filter(booking_id=booking_id)
.prefetch_related(Prefetch("reservation__gsrbooking_set"), Prefetch("gsr"))
.first()
) :
):
if gsr_booking.user != user and gsr_booking.reservation.creator != user:
raise APIError("Error: Unauthorized: This reservation was booked by someone else.")

Expand Down
18 changes: 14 additions & 4 deletions backend/gsr_booking/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class Migration(migrations.Migration):
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID",
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=255)),
Expand All @@ -33,15 +36,22 @@ class Migration(migrations.Migration):
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID",
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("accepted", models.BooleanField(default=False)),
("type", models.CharField(choices=[("A", "Admin"), ("M", "M")], max_length=10),),
(
"type",
models.CharField(choices=[("A", "Admin"), ("M", "M")], max_length=10),
),
(
"group",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="gsr_booking.Group",
on_delete=django.db.models.deletion.CASCADE,
to="gsr_booking.Group",
),
),
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ class Migration(migrations.Migration):
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID",
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=255)),
Expand All @@ -49,15 +52,22 @@ class Migration(migrations.Migration):
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID",
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("accepted", models.BooleanField(default=False)),
("type", models.CharField(choices=[("A", "Admin"), ("M", "M")], max_length=10),),
(
"type",
models.CharField(choices=[("A", "Admin"), ("M", "M")], max_length=10),
),
(
"group",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="gsr_booking.Group",
on_delete=django.db.models.deletion.CASCADE,
to="gsr_booking.Group",
),
),
(
Expand Down Expand Up @@ -104,15 +114,19 @@ class Migration(migrations.Migration):
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID",
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("full_name", models.CharField(db_index=True, max_length=255)),
("pennkey", models.CharField(db_index=True, max_length=255)),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
Expand All @@ -123,7 +137,10 @@ class Migration(migrations.Migration):
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID",
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
Expand All @@ -139,13 +156,17 @@ class Migration(migrations.Migration):
(
"email",
models.CharField(
max_length=255, null=True, unique=True, verbose_name="school email",
max_length=255,
null=True,
unique=True,
verbose_name="school email",
),
),
(
"user",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
(
Expand Down
10 changes: 8 additions & 2 deletions backend/gsr_booking/migrations/0002_auto_20210129_1527.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RemoveField(model_name="gsrbookingcredentials", name="email",),
migrations.RemoveField(model_name="gsrbookingcredentials", name="id",),
migrations.RemoveField(
model_name="gsrbookingcredentials",
name="email",
),
migrations.RemoveField(
model_name="gsrbookingcredentials",
name="id",
),
migrations.AlterField(
model_name="gsrbookingcredentials",
name="date_updated",
Expand Down
4 changes: 3 additions & 1 deletion backend/gsr_booking/migrations/0004_alter_gsr_lid.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Migration(migrations.Migration):

operations = [
migrations.AlterField(
model_name="gsr", name="lid", field=models.CharField(max_length=255),
model_name="gsr",
name="lid",
field=models.CharField(max_length=255),
),
]
8 changes: 6 additions & 2 deletions backend/gsr_booking/migrations/0005_usersearchindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@ class Migration(migrations.Migration):
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID",
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("full_name", models.CharField(db_index=True, max_length=255)),
("pennkey", models.CharField(db_index=True, max_length=255)),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
Expand Down
6 changes: 5 additions & 1 deletion backend/gsr_booking/migrations/0006_auto_20211024_1231.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ def create_single_user_group(apps, schema_editor):
Group = apps.get_model("gsr_booking", "Group")
GroupMembership = apps.get_model("gsr_booking", "GroupMembership")
for user in User.objects.all():
group, created = Group.objects.get_or_create(owner=user, name="Me", color="#14f7d1",)
group, created = Group.objects.get_or_create(
owner=user,
name="Me",
color="#14f7d1",
)
if created:
GroupMembership.objects.get_or_create(group=group, user=user, type="A", accepted=True)

Expand Down
13 changes: 10 additions & 3 deletions backend/gsr_booking/migrations/0006_gsrbookingcredentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class Migration(migrations.Migration):
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID",
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
Expand All @@ -39,13 +42,17 @@ class Migration(migrations.Migration):
(
"email",
models.CharField(
max_length=255, null=True, unique=True, verbose_name="school email",
max_length=255,
null=True,
unique=True,
verbose_name="school email",
),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ class Migration(migrations.Migration):
]

operations = [
migrations.DeleteModel(name="GSRBookingCredentials",),
migrations.DeleteModel(
name="GSRBookingCredentials",
),
]
13 changes: 10 additions & 3 deletions backend/gsr_booking/migrations/0008_auto_20211112_1657.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RemoveField(model_name="reservation", name="gsr",),
migrations.RemoveField(
model_name="reservation",
name="gsr",
),
migrations.AddField(
model_name="gsrbooking",
name="reservation",
Expand All @@ -44,8 +47,12 @@ class Migration(migrations.Migration):
),
),
migrations.AddField(
model_name="reservation", name="is_cancelled", field=models.BooleanField(default=False),
model_name="reservation",
name="is_cancelled",
field=models.BooleanField(default=False),
),
migrations.DeleteModel(
name="UserSearchIndex",
),
migrations.DeleteModel(name="UserSearchIndex",),
migrations.RunPython(create_reservation_for_booking),
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RemoveField(model_name="groupmembership", name="username",),
migrations.RemoveField(
model_name="groupmembership",
name="username",
),
migrations.AddField(
model_name="groupmembership",
name="is_wharton",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RemoveField(model_name="gsrbooking", name="reminder_sent",),
migrations.RemoveField(
model_name="gsrbooking",
name="reminder_sent",
),
migrations.AddField(
model_name="reservation",
name="reminder_sent",
Expand Down
4 changes: 3 additions & 1 deletion backend/gsr_booking/migrations/0012_gsr_in_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Migration(migrations.Migration):

operations = [
migrations.AddField(
model_name="gsr", name="in_use", field=models.BooleanField(default=True),
model_name="gsr",
name="in_use",
field=models.BooleanField(default=True),
),
]
6 changes: 5 additions & 1 deletion backend/gsr_booking/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ class GroupMembership(models.Model):
# INVARIANT: either user or username should always be set. if user is not None, then the
# username should the be username of the associated user.
user = models.ForeignKey(
User, on_delete=models.CASCADE, related_name="memberships", blank=True, null=True,
User,
on_delete=models.CASCADE,
related_name="memberships",
blank=True,
null=True,
)

group = models.ForeignKey("Group", on_delete=models.CASCADE, related_name="memberships")
Expand Down
6 changes: 5 additions & 1 deletion backend/gsr_booking/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@

urlpatterns = [
path("", include(router.urls)),
path("locations/", cache_page(Cache.MONTH)(Locations.as_view()), name="locations",),
path(
"locations/",
cache_page(Cache.MONTH)(Locations.as_view()),
name="locations",
),
path("recent/", RecentGSRs.as_view(), name="recent-gsrs"),
path("wharton/", CheckWharton.as_view(), name="is-wharton"),
path("availability/<lid>/<gid>", Availability.as_view(), name="availability"),
Expand Down
4 changes: 3 additions & 1 deletion backend/gsr_booking/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def invites(self, request, username=None):
return Response(
GroupMembershipSerializer(
GroupMembership.objects.filter(
user=user, accepted=False, group__in=self.request.user.booking_groups.all(),
user=user,
accepted=False,
group__in=self.request.user.booking_groups.all(),
),
many=True,
).data
Expand Down
Loading

0 comments on commit ca54667

Please sign in to comment.