Skip to content

Commit

Permalink
Penn-Wrapped Prod Push
Browse files Browse the repository at this point in the history
  • Loading branch information
zachHarpaz committed Nov 15, 2024
1 parent cad94c5 commit 775468f
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 209 deletions.
2 changes: 1 addition & 1 deletion backend/pennmobile/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
path("dining/", include("dining.urls")),
path("penndata/", include("penndata.urls")),
path("sublet/", include("sublet.urls")),
path("wrapped/", include("wrapped.urls"))
path("wrapped/", include("wrapped.urls")),
]

urlpatterns = [
Expand Down
29 changes: 15 additions & 14 deletions backend/wrapped/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
from django.contrib import admin
from django.core.exceptions import ValidationError

from wrapped.models import GlobalStatKey, GlobalStat,IndividualStat, IndividualStatKey, Page, IndividualStatPageField, GlobalStatPageField, Semester
from wrapped.models import (
GlobalStat,
GlobalStatKey,
GlobalStatPageField,
IndividualStat,
IndividualStatKey,
IndividualStatPageField,
Page,
Semester,
)


class WrappedIndividualAdmin(admin.ModelAdmin):
Expand All @@ -10,15 +18,17 @@ class WrappedIndividualAdmin(admin.ModelAdmin):


class WrappedGlobalAdmin(admin.ModelAdmin):

list_display = ["key", "value", "semester"]
search_fields = ["key__icontains"]

class IndividualStatPageFieldAdmin(admin.TabularInline):

class IndividualStatPageFieldAdmin(admin.TabularInline):
model = IndividualStatPageField
extra = 1

class GlobalStatPageFieldAdmin(admin.TabularInline):

class GlobalStatPageFieldAdmin(admin.TabularInline):
model = GlobalStatPageField
extra = 1

Expand All @@ -27,18 +37,9 @@ class PageAdmin(admin.ModelAdmin):
inlines = [IndividualStatPageFieldAdmin, GlobalStatPageFieldAdmin]




# admin.site.register(WrappedIndividualAdmin, WrappedGlobalAdmin)
admin.site.register(IndividualStat, WrappedIndividualAdmin)
admin.site.register(GlobalStat, WrappedGlobalAdmin)
admin.site.register(IndividualStatKey)
admin.site.register(GlobalStatKey)

admin.site.register(Page, PageAdmin)
admin.site.register(Semester)
# admin.site.register(Page)




6 changes: 2 additions & 4 deletions backend/wrapped/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@


class WrappedConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'wrapped'
def ready(self):
import wrapped.signals # Import the file where your signal is defined
default_auto_field = "django.db.models.BigAutoField"
name = "wrapped"
154 changes: 114 additions & 40 deletions backend/wrapped/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by Django 5.0.2 on 2024-11-10 16:21

import datetime

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
Expand All @@ -16,83 +17,156 @@ class Migration(migrations.Migration):

operations = [
migrations.CreateModel(
name='GlobalStatKey',
name="GlobalStatKey",
fields=[
('key', models.CharField(max_length=50, primary_key=True, serialize=False)),
("key", models.CharField(max_length=50, primary_key=True, serialize=False)),
],
),
migrations.CreateModel(
name='IndividualStatKey',
name="IndividualStatKey",
fields=[
('key', models.CharField(max_length=50, primary_key=True, serialize=False)),
("key", models.CharField(max_length=50, primary_key=True, serialize=False)),
],
),
migrations.CreateModel(
name='GlobalStatPageField',
name="GlobalStatPageField",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text_field_name', models.CharField(max_length=50)),
('global_stat_key', models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='wrapped.globalstatkey')),
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("text_field_name", models.CharField(max_length=50)),
(
"global_stat_key",
models.ForeignKey(
default=None,
on_delete=django.db.models.deletion.CASCADE,
to="wrapped.globalstatkey",
),
),
],
),
migrations.CreateModel(
name='IndividualStatPageField',
name="IndividualStatPageField",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text_field_name', models.CharField(max_length=50)),
('individual_stat_key', models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='wrapped.individualstatkey')),
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("text_field_name", models.CharField(max_length=50)),
(
"individual_stat_key",
models.ForeignKey(
default=None,
on_delete=django.db.models.deletion.CASCADE,
to="wrapped.individualstatkey",
),
),
],
),
migrations.CreateModel(
name='Page',
name="Page",
fields=[
('name', models.CharField(max_length=50, primary_key=True, serialize=False)),
('template_path', models.CharField(max_length=50)),
('duration', models.DurationField(blank=True, default=datetime.timedelta(0))),
('global_stats', models.ManyToManyField(blank=True, through='wrapped.GlobalStatPageField', to='wrapped.globalstatkey')),
('individual_stats', models.ManyToManyField(blank=True, through='wrapped.IndividualStatPageField', to='wrapped.individualstatkey')),
("name", models.CharField(max_length=50, primary_key=True, serialize=False)),
("template_path", models.CharField(max_length=50)),
("duration", models.DurationField(blank=True, default=datetime.timedelta(0))),
(
"global_stats",
models.ManyToManyField(
blank=True,
through="wrapped.GlobalStatPageField",
to="wrapped.globalstatkey",
),
),
(
"individual_stats",
models.ManyToManyField(
blank=True,
through="wrapped.IndividualStatPageField",
to="wrapped.individualstatkey",
),
),
],
),
migrations.AddField(
model_name='individualstatpagefield',
name='Page',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wrapped.page'),
model_name="individualstatpagefield",
name="Page",
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="wrapped.page"),
),
migrations.AddField(
model_name='globalstatpagefield',
name='Page',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wrapped.page'),
model_name="globalstatpagefield",
name="Page",
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="wrapped.page"),
),
migrations.CreateModel(
name='Semester',
name="Semester",
fields=[
('semester', models.CharField(max_length=5, primary_key=True, serialize=False)),
('pages', models.ManyToManyField(blank=True, to='wrapped.page')),
("semester", models.CharField(max_length=5, primary_key=True, serialize=False)),
("pages", models.ManyToManyField(blank=True, to="wrapped.page")),
],
),
migrations.CreateModel(
name='IndividualStat',
name="IndividualStat",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('value', models.CharField(max_length=50)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('key', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wrapped.individualstatkey')),
('semester', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wrapped.semester')),
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("value", models.CharField(max_length=50)),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
(
"key",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="wrapped.individualstatkey"
),
),
(
"semester",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="wrapped.semester"
),
),
],
options={
'unique_together': {('key', 'semester', 'user')},
"unique_together": {("key", "semester", "user")},
},
),
migrations.CreateModel(
name='GlobalStat',
name="GlobalStat",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('value', models.CharField(max_length=50)),
('key', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wrapped.globalstatkey')),
('semester', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wrapped.semester')),
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("value", models.CharField(max_length=50)),
(
"key",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="wrapped.globalstatkey"
),
),
(
"semester",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="wrapped.semester"
),
),
],
options={
'unique_together': {('key', 'semester')},
"unique_together": {("key", "semester")},
},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 5.0.2 on 2024-11-10 17:40

import datetime

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("wrapped", "0001_initial"),
]

operations = [
migrations.RenameField(
model_name="globalstatpagefield",
old_name="Page",
new_name="page",
),
migrations.RenameField(
model_name="individualstatpagefield",
old_name="Page",
new_name="page",
),
migrations.AlterField(
model_name="page",
name="duration",
field=models.DurationField(blank=True, default=datetime.timedelta(0), null=True),
),
]
Loading

0 comments on commit 775468f

Please sign in to comment.