Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created models for penn wrapped -- issue with pip files though #309

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/pennmobile/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"accounts.apps.AccountsConfig",
"identity.apps.IdentityConfig",
"analytics.apps.AnalyticsConfig",
"wrapped.apps.WrappedConfig",
"django_filters",
"debug_toolbar",
"gsr_booking",
Expand Down
1 change: 1 addition & 0 deletions backend/pennmobile/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
path("dining/", include("dining.urls")),
path("penndata/", include("penndata.urls")),
path("sublet/", include("sublet.urls")),
path("wrapped/", include("wrapped.urls"))
]

urlpatterns = [
Expand Down
Empty file added backend/wrapped/__init__.py
Empty file.
44 changes: 44 additions & 0 deletions backend/wrapped/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from django.contrib import admin
from django.core.exceptions import ValidationError

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


class WrappedIndividualAdmin(admin.ModelAdmin):
search_fields = ["user__username__icontains", "key__key__icontains", "semester__icontains"]
list_display = ["user", "key", "value", "semester"]


class WrappedGlobalAdmin(admin.ModelAdmin):

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

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

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


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




# 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)




8 changes: 8 additions & 0 deletions backend/wrapped/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig


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
64 changes: 64 additions & 0 deletions backend/wrapped/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Generated by Django 5.0.2 on 2024-10-11 19:50

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Template',
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)),
],
),
migrations.CreateModel(
name='UserStatKey',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('stat_key', models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name='GlobalStat',
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)),
],
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')),
],
),
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)),
('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')),
],
options={
'unique_together': {('stat_key', 'semester', 'user')},
},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Generated by Django 5.0.2 on 2024-10-11 20:38

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

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

operations = [
migrations.RemoveField(
model_name='page',
name='temp',
),
migrations.RemoveField(
model_name='template',
name='background',
),
migrations.RemoveField(
model_name='template',
name='template',
),
migrations.AddField(
model_name='page',
name='GlobalStat',
field=models.ManyToManyField(to='wrapped.globalstat'),
),
migrations.AddField(
model_name='page',
name='IndividualStat',
field=models.ManyToManyField(to='wrapped.individualstat'),
),
migrations.AddField(
model_name='page',
name='template',
field=models.ForeignKey(default=False, on_delete=django.db.models.deletion.CASCADE, to='wrapped.template'),
preserve_default=False,
),
migrations.AddField(
model_name='template',
name='name',
field=models.CharField(default='test', max_length=10),
preserve_default=False,
),
migrations.AddField(
model_name='template',
name='num_fields',
field=models.IntegerField(default=1),
preserve_default=False,
),
migrations.AddField(
model_name='template',
name='template_path',
field=models.CharField(default='hhell', max_length=50),
preserve_default=False,
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Generated by Django 5.0.2 on 2024-10-18 21:11

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('wrapped', '0002_remove_page_temp_remove_template_background_and_more'),
]

operations = [
migrations.RemoveField(
model_name='page',
name='template',
),
migrations.RemoveField(
model_name='page',
name='GlobalStat',
),
migrations.RemoveField(
model_name='page',
name='IndividualStat',
),
migrations.AddField(
model_name='page',
name='template_path',
field=models.CharField(default='nothing', max_length=50),
preserve_default=False,
),
migrations.CreateModel(
name='StatLocation',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text_field_name', models.CharField(max_length=50)),
('GlobalStatKey', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wrapped.globalstat')),
('IndividualStatKey', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wrapped.userstatkey')),
],
),
migrations.AddField(
model_name='page',
name='stat_locations',
field=models.ManyToManyField(blank=True, to='wrapped.statlocation'),
),
migrations.DeleteModel(
name='Template',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.0.2 on 2024-10-18 21:15

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('wrapped', '0003_remove_page_template_remove_page_globalstat_and_more'),
]

operations = [
migrations.AddConstraint(
model_name='statlocation',
constraint=models.CheckConstraint(check=models.Q(models.Q(('GlobalStatKey', False), ('IndividualStatKey', True)), models.Q(('GlobalStatKey', True), ('IndividualStatKey', False)), _connector='OR'), name='one_foreign_key_must_be_null'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.0.2 on 2024-10-18 21:31

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('wrapped', '0004_statlocation_one_foreign_key_must_be_null'),
]

operations = [
migrations.AlterField(
model_name='statlocation',
name='GlobalStatKey',
field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='wrapped.globalstat'),
),
migrations.AlterField(
model_name='statlocation',
name='IndividualStatKey',
field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='wrapped.userstatkey'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.0.2 on 2024-10-18 21:32

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('wrapped', '0005_alter_statlocation_globalstatkey_and_more'),
]

operations = [
migrations.RemoveConstraint(
model_name='statlocation',
name='one_foreign_key_must_be_null',
),
]
19 changes: 19 additions & 0 deletions backend/wrapped/migrations/0007_page_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.0.2 on 2024-10-18 21:42

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('wrapped', '0006_remove_statlocation_one_foreign_key_must_be_null'),
]

operations = [
migrations.AddField(
model_name='page',
name='name',
field=models.CharField(default='old', max_length=50),
preserve_default=False,
),
]
19 changes: 19 additions & 0 deletions backend/wrapped/migrations/0008_page_semester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.0.2 on 2024-10-20 17:35

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('wrapped', '0007_page_name'),
]

operations = [
migrations.AddField(
model_name='page',
name='semester',
field=models.CharField(default='2020A', max_length=5),
preserve_default=False,
),
]
Loading
Loading