Skip to content
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
1 change: 1 addition & 0 deletions alyx/alyx/environment_template.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ DJANGO_SECRET_KEY=create_a_secret_key_here_but_avoid_any_special_character_or_bo
GLOBUS_CLIENT_ID=525cc543-8ccb-4d11-8036-af332da5eafd
# DJANGO_MEDIA_ROOT=https://alyx-uploaded.s3.eu-west-2.amazonaws.com/uploaded/ # add if s3
# DJANGO_TABLES_ROOT=https://ibl-brain-wide-map-public.s3.amazonaws.com/caches/alyx # add if s3
TZ=UTC # Alyx datetime timezone. See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
8 changes: 7 additions & 1 deletion alyx/misc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,20 @@ def get_allowed_subjects(self, subjects_queryset=None):


class Lab(BaseModel):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if not self.instance.pk:
self.fields['timezone'].initial = TIME_ZONE

labname_validator = validators.RegexValidator(
f"^{ALF_SPEC['lab']}$",
"Lab name must only contain letters, numbers, and underscores.")
name = models.CharField(max_length=255, unique=True, validators=[labname_validator])
institution = models.CharField(max_length=255, blank=True)
address = models.CharField(max_length=255, blank=True)
timezone = models.CharField(
max_length=64, blank=True, default=TIME_ZONE,
max_length=64, blank=True,
help_text="Timezone of the server "
"(see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)")

Expand Down
3 changes: 2 additions & 1 deletion deploy/docker/Dockerfile_base
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ FROM ubuntu/apache2:latest

# python unbuffered allows to get real-time logs
ENV PYTHONUNBUFFERED 1
ENV TZ=Europe/London
ARG TZ=UTC
ENV TZ=${TZ}
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone


Expand Down
13 changes: 9 additions & 4 deletions deploy/docker/settings_lab-deploy.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import os
import zoneinfo
from textwrap import dedent

LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Europe/London'
TIME_ZONE = os.getenv('TZ', 'Europe/London').strip()
if TIME_ZONE not in zoneinfo.available_timezones():
raise ValueError(f'Invalid TIME_ZONE: "{TIME_ZONE}". '
'Please set a valid timezone with TZ env variable. '
'See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.')
GLOBUS_CLIENT_ID = os.getenv('GLOBUS_CLIENT_ID')
SUBJECT_REQUEST_EMAIL_FROM = 'alyx@internationalbrainlab.org'
SUBJECT_REQUEST_EMAIL_FROM = os.getenv('APACHE_SERVER_ADMIN', 'alyx@localhost')
DEFAULT_SOURCE = 'IBL'
DEFAULT_PROTOCOL = '1'
SUPERUSERS = ('root',)
Expand All @@ -13,8 +18,8 @@
DEFAULT_LAB_NAME = 'cortexlab'
WATER_RESTRICTIONS_EDITABLE = False # if set to True, all users can edit water restrictions
DEFAULT_LAB_PK = '4027da48-7be3-43ec-a222-f75dffe36872'
SESSION_REPO_URL = \
"http://ibl.flatironinstitute.org/{lab}/Subjects/{subject}/{date}/{number:03d}/"
SESSION_REPO_URL = f'https://{os.getenv("APACHE_SERVER_NAME", "localhost")}/'
SESSION_REPO_URL += "{lab}/Subjects/{subject}/{date}/{number:03d}/"
NARRATIVE_TEMPLATES = {
'Headplate implant': dedent('''
== General ==
Expand Down