Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zachHarpaz committed Nov 10, 2024
1 parent 5ec9cf9 commit cad94c5
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 514 deletions.
12 changes: 6 additions & 6 deletions backend/wrapped/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib import admin
from django.core.exceptions import ValidationError

from wrapped.models import GlobalStatKey, GlobalStat,IndividualStat, IndividualStatKey, Page, IndividualStatThrough, GlobalStatThrough, Semester
from wrapped.models import GlobalStatKey, GlobalStat,IndividualStat, IndividualStatKey, Page, IndividualStatPageField, GlobalStatPageField, Semester


class WrappedIndividualAdmin(admin.ModelAdmin):
Expand All @@ -14,17 +14,17 @@ class WrappedGlobalAdmin(admin.ModelAdmin):
list_display = ["key", "value", "semester"]
search_fields = ["key__icontains"]

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

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


class PageAdmin(admin.ModelAdmin):
inlines = [IndividualStatThroughAdmin, GlobalStatThroughAdmin]
inlines = [IndividualStatPageFieldAdmin, GlobalStatPageFieldAdmin]



Expand Down
74 changes: 54 additions & 20 deletions backend/wrapped/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by Django 5.0.2 on 2024-10-11 19:50
# 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 @@ -15,50 +16,83 @@ class Migration(migrations.Migration):

operations = [
migrations.CreateModel(
name='Template',
name='GlobalStatKey',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('background', models.CharField(max_length=50)),
('template', models.CharField(max_length=50)),
('key', models.CharField(max_length=50, primary_key=True, serialize=False)),
],
),
migrations.CreateModel(
name='UserStatKey',
name='IndividualStatKey',
fields=[
('key', models.CharField(max_length=50, primary_key=True, serialize=False)),
],
),
migrations.CreateModel(
name='GlobalStatPageField',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('stat_key', models.CharField(max_length=50)),
('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='GlobalStat',
name='IndividualStatPageField',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('stat_key', models.CharField(max_length=50)),
('stat_value', models.CharField(max_length=50)),
('semester', models.CharField(max_length=5)),
('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')),
],
options={
'unique_together': {('stat_key', 'semester')},
},
),
migrations.CreateModel(
name='Page',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('temp', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wrapped.template')),
('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'),
),
migrations.AddField(
model_name='globalstatpagefield',
name='Page',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wrapped.page'),
),
migrations.CreateModel(
name='Semester',
fields=[
('semester', models.CharField(max_length=5, primary_key=True, serialize=False)),
('pages', models.ManyToManyField(blank=True, to='wrapped.page')),
],
),
migrations.CreateModel(
name='IndividualStat',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('stat_value', models.CharField(max_length=50)),
('semester', models.CharField(max_length=5)),
('value', models.CharField(max_length=50)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('stat_key', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wrapped.userstatkey')),
('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')},
},
),
migrations.CreateModel(
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')),
],
options={
'unique_together': {('stat_key', 'semester', 'user')},
'unique_together': {('key', 'semester')},
},
),
]

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions backend/wrapped/migrations/0007_page_name.py

This file was deleted.

19 changes: 0 additions & 19 deletions backend/wrapped/migrations/0008_page_semester.py

This file was deleted.

Loading

0 comments on commit cad94c5

Please sign in to comment.