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

Timezone #270

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
18 changes: 18 additions & 0 deletions ap_src/ap_app/migrations/0004_userprofile_timezone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.6 on 2024-02-22 14:39

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('ap_app', '0003_recurringexception'),
]

operations = [
migrations.AddField(
model_name='userprofile',
name='timezone',
field=models.CharField(default='UTC', max_length=100),
),
]
19 changes: 17 additions & 2 deletions ap_src/ap_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,26 @@ class UserProfile(models.Model):

external_teams = models.BooleanField(default=False)

class UserProfile(models.Model):
"""Extension of fields for User class"""

user = models.OneToOneField(User, on_delete=models.CASCADE)

def __str__(self):
return f"{self.user.username}"
edit_whitelist = models.ManyToManyField(
User,
related_name="permissions",
)
# Extra Fields
accepted_policy = models.BooleanField()
privacy = models.BooleanField(default=False)
region = models.CharField(max_length=200, default="GB")
external_teams = models.BooleanField(default=False)

# New field for storing the timezone
timezone = models.CharField(max_length=100, default='UTC')

def __str__(self):
return self.user.username

class RecurringException(models.Model):
ID = models.AutoField(primary_key=True)
Expand Down
11 changes: 6 additions & 5 deletions ap_src/ap_app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from . import views, teams, absences, calendarview

js_info_dict = {
'packages' : ('recurrence', ),
'packages': ('recurrence', ),
}

from django.conf.urls import handler404, handler500
Expand Down Expand Up @@ -49,12 +49,13 @@
path("profile/settings/add-user", views.add_user, name="add-user"),
path("profile/settings/set-region", views.set_region, name="set-region"),
path("profile/settings/update-colour", views.update_colour, name="update-colour"),
path("calendar/set_month",views.set_calendar_month, name="set_month"),
path("calendar/set_month", views.set_calendar_month, name="set_month"),
path("calendar/1/", views.api_calendar_view, name="api_calendar"),
path("calendar/1/<str:month>/<int:year>", views.api_calendar_view, name="api_calendar"),
path("main_calendar", views.main_calendar, name="main_calendar"),
path("main_calendar/<str:month>/<int:year>", views.main_calendar, name="main_calendar"),
re_path(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT}) #This lets Django find the CSS files when debug is set to false

]
re_path(r'^static/(?P<path>.*)$', serve, {'document_root': settings.STATIC_ROOT}) # This lets Django find the CSS files when debug is set to false
]

handler404 = 'ap_app.errors.handler404'
handler500 = 'ap_app.errors.handler500'
Expand Down
Loading