Skip to content

Commit

Permalink
[Backend] Adding a Settings panel and allowing users to hide triage c…
Browse files Browse the repository at this point in the history
…olumns that aren't theirs

#42
  • Loading branch information
keithamoss committed Mar 17, 2019
1 parent e06ed48 commit ea22b7e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions django/scremsong/app/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def has_value(cls, value):
class ProfileSettings(str, EnumBase):
QueueSortBy = "queue_sort_by"
ColumnPositions = "column_positions"
TriageOnlyShowAssignedColumns = "triage_only_show_assigned_columns"


class ProfileSettingQueueSortBy(int, EnumBase):
Expand Down
19 changes: 19 additions & 0 deletions django/scremsong/app/migrations/0036_auto_20190317_0724.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.1.7 on 2019-03-17 07:24

from django.db import migrations
import scremsong.app.models


class Migration(migrations.Migration):

dependencies = [
('app', '0035_auto_20190317_0313'),
]

operations = [
migrations.AlterField(
model_name='profile',
name='settings',
field=scremsong.app.models.ProfileJSONField(blank=True, default=scremsong.app.models.default_profile_settings),
),
]
14 changes: 12 additions & 2 deletions django/scremsong/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,26 @@ class CompilationError(Exception):

def default_profile_settings():
return {
"queue_sort_by": ProfileSettingQueueSortBy.ByCreation
"queue_sort_by": ProfileSettingQueueSortBy.ByCreation,
"triage_only_show_assigned_columns": False,
}


class ProfileJSONField(JSONField):
description = "Custom JSONField for user profiles to ensure default settings are always included"

def from_db_value(self, value, expression, connection):
if value is None:
return value
return {**default_profile_settings(), **value}


class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
profile_image_url = models.URLField(blank=False)
is_approved = models.BooleanField(default=False)
is_accepting_assignments = models.BooleanField(default=False)
settings = JSONField(default=default_profile_settings, blank=True)
settings = ProfileJSONField(default=default_profile_settings, blank=True)

tracker = FieldTracker()

Expand Down

0 comments on commit ea22b7e

Please sign in to comment.