This commit is contained in:
Ross
2021-12-14 19:29:10 +00:00
parent b8928274c0
commit 0a39d37f02
7 changed files with 151 additions and 68 deletions
@@ -0,0 +1,18 @@
# Generated by Django 3.2.8 on 2021-12-14 19:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('generic', '0019_cidusergroup_archive'),
]
operations = [
migrations.AddField(
model_name='ciduser',
name='supervisor_email',
field=models.EmailField(blank=True, max_length=254),
),
]
+16
View File
@@ -11,6 +11,8 @@ from django.conf import settings
from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.core.mail import send_mail
class Plane(models.Model): class Plane(models.Model):
plane = models.CharField(max_length=200) plane = models.CharField(max_length=200)
@@ -216,6 +218,20 @@ class CidUser(models.Model):
def check_passcode(self, passcode) -> bool: def check_passcode(self, passcode) -> bool:
return self.passcode == passcode return self.passcode == passcode
def email_details(self):
msg = f"""
Candidate details for upcomming event {self.group}
---------
CID: {self.cid}
Passcode: {self.passcode}
Please note this inbox is not monitored. Direct all enquiries to ...
"""
send_mail("Candidate Details", msg, "test@xkjq.uk", [self.email])
class CidUserExam(models.Model): class CidUserExam(models.Model):
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField() object_id = models.PositiveIntegerField()
+8
View File
@@ -0,0 +1,8 @@
{% extends 'generic/base.html' %}
{% block content %}
{% for group in groups %}
<p>Group: {{author.name}} [Email candidate details]</p>
{% endfor %}
{% endblock %}
+23
View File
@@ -0,0 +1,23 @@
{% extends 'base.html' %}
{% block title %}
CIDs
{% endblock %}
{% block css %}
{% endblock %}
{% block js %}
{% endblock %}
{% block content %}
{% endblock %}
{% block navigation %}
CIDs:
{% if request.user.is_authenticated %}
<a href="{% url 'generic:manage_cids' %}">Cids</a> /
<a href="{% url 'generic:group_view' %}">Groups</a> /
{% endif %}
{% endblock %}
+1
View File
@@ -27,5 +27,6 @@ urlpatterns = [
name="examination-autocomplete", name="examination-autocomplete",
), ),
path("cids/manage/", views.CidUserView.as_view(), name="manage_cids"), path("cids/manage/", views.CidUserView.as_view(), name="manage_cids"),
path("cids/group/<int:pk>", views.group_view, name="group_view"),
path("cids/create", views.manage_cid_users, name="manage_cid_users"), path("cids/create", views.manage_cid_users, name="manage_cid_users"),
] ]
+10
View File
@@ -988,6 +988,16 @@ class CidUserView(LoginRequiredMixin, SingleTableMixin, FilterView):
context["cid_user_groups"] = cid_user_groups context["cid_user_groups"] = cid_user_groups
return context return context
@login_required
@user_is_cid_user_manager
def group_view(request):
groups = CidUserGroup.objects.filter(archive=False)
return render(
request,
"generic/group_view.html",
{"groups": groups},
)
@login_required @login_required
@user_is_cid_user_manager @user_is_cid_user_manager
+67 -60
View File
@@ -19,25 +19,31 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
with open('/etc/secret_key') as f: with open("/etc/secret_key") as f:
SECRET_KEY = f.read().strip() SECRET_KEY = f.read().strip()
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
ALLOWED_HOSTS = ["localhost", "127.0.0.1", "161.35.163.87", "penracourses.org.uk", "www.penracourses.org.uk"] ALLOWED_HOSTS = [
"localhost",
"127.0.0.1",
"161.35.163.87",
"penracourses.org.uk",
"www.penracourses.org.uk",
]
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'generic', "generic",
'anatomy', "anatomy",
'physics', "physics",
'rapids', "rapids",
'longs', "longs",
'sbas', "sbas",
'wally', "wally",
'atlas', "atlas",
"reversion", "reversion",
"django_tables2", "django_tables2",
"django_filters", "django_filters",
@@ -48,13 +54,13 @@ INSTALLED_APPS = [
"dal", "dal",
"dal_select2", "dal_select2",
"dal_queryset_sequence", "dal_queryset_sequence",
'django.contrib.admin', "django.contrib.admin",
'django.contrib.auth', "django.contrib.auth",
'django.contrib.contenttypes', "django.contrib.contenttypes",
'django.contrib.sessions', "django.contrib.sessions",
'django.contrib.messages', "django.contrib.messages",
'django.contrib.staticfiles', "django.contrib.staticfiles",
'debug_toolbar', "debug_toolbar",
"tagulous", "tagulous",
"dbbackup", "dbbackup",
"rest_framework", "rest_framework",
@@ -71,10 +77,10 @@ MIDDLEWARE = [
"django.contrib.messages.middleware.MessageMiddleware", "django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware",
"reversion.middleware.RevisionMiddleware", "reversion.middleware.RevisionMiddleware",
'debug_toolbar.middleware.DebugToolbarMiddleware', "debug_toolbar.middleware.DebugToolbarMiddleware",
] ]
ROOT_URLCONF = 'rad.urls' ROOT_URLCONF = "rad.urls"
TEMPLATES = [ TEMPLATES = [
{ {
@@ -93,13 +99,13 @@ TEMPLATES = [
}, },
] ]
WSGI_APPLICATION = 'rad.wsgi.application' WSGI_APPLICATION = "rad.wsgi.application"
# Database # Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases # https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = { DATABASES = {
'default': { "default": {
"ENGINE": "django.db.backends.postgresql", "ENGINE": "django.db.backends.postgresql",
"NAME": "rad", "NAME": "rad",
"USER": "django", "USER": "django",
@@ -115,20 +121,16 @@ DATABASES = {
AUTH_PASSWORD_VALIDATORS = [ AUTH_PASSWORD_VALIDATORS = [
{ {
'NAME': "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
}, },
{ {
'NAME': "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
'django.contrib.auth.password_validation.MinimumLengthValidator',
}, },
{ {
'NAME': "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
'django.contrib.auth.password_validation.CommonPasswordValidator',
}, },
{ {
'NAME': "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
'django.contrib.auth.password_validation.NumericPasswordValidator',
}, },
] ]
@@ -142,9 +144,9 @@ SERIALIZATION_MODULES = {
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/ # https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = "en-us"
TIME_ZONE = 'Europe/London' TIME_ZONE = "Europe/London"
USE_I18N = True USE_I18N = True
@@ -156,18 +158,18 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.11/howto/static-files/ # https://docs.djangoproject.com/en/1.11/howto/static-files/
SECURE_SSL_REDIRECT = True SECURE_SSL_REDIRECT = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
STATIC_URL = '/static/' STATIC_URL = "/static/"
STATIC_ROOT = 'static/' STATIC_ROOT = "static/"
REMOTE_URL = "https://www.penracourses.org.uk" REMOTE_URL = "https://www.penracourses.org.uk"
# #
# if DEBUG: # if DEBUG:
# STATIC_URL = REMOTE_URL + STATIC_URL # STATIC_URL = REMOTE_URL + STATIC_URL
MEDIA_URL = '/media/' MEDIA_URL = "/media/"
MEDIA_ROOT = '/home/django/rad/media/' MEDIA_ROOT = "/home/django/rad/media/"
# if DEBUG: # if DEBUG:
# MEDIA_URL = REMOTE_URL + MEDIA_URL # MEDIA_URL = REMOTE_URL + MEDIA_URL
@@ -199,33 +201,38 @@ LOGGING = {
CORS_ORIGIN_ALLOW_ALL = True CORS_ORIGIN_ALLOW_ALL = True
CACHES = { CACHES = {
'default': { "default": {
'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
'LOCATION': '127.0.0.1:11211', "LOCATION": "127.0.0.1:11211",
#'OPTIONS': { #'OPTIONS': {
# 'server_max_value_length': 1024 * 1024 * 10 # 'server_max_value_length': 1024 * 1024 * 10
# } # }
}, },
'filesystem': { "filesystem": {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', "BACKEND": "django.core.cache.backends.filebased.FileBasedCache",
'LOCATION': '/var/tmp/django_cache', "LOCATION": "/var/tmp/django_cache",
} },
} }
THUMBNAIL_ALIASES = { THUMBNAIL_ALIASES = {
'': { "": {
'exam-list': {'size': (50, 50), 'crop': True}, "exam-list": {"size": (50, 50), "crop": True},
}, },
} }
DATA_UPLOAD_MAX_NUMBER_FIELDS = 50000 DATA_UPLOAD_MAX_NUMBER_FIELDS = 50000
THUMBNAIL_SOURCE_GENERATORS = ('easy_thumbnails.source_generators.pil_image', 'helpers.images.pil_dicom_image') THUMBNAIL_SOURCE_GENERATORS = (
DBBACKUP_STORAGE = 'django.core.files.storage.FileSystemStorage' "easy_thumbnails.source_generators.pil_image",
DBBACKUP_STORAGE_OPTIONS = {'location': os.path.join(BASE_DIR, '../backups')} "helpers.images.pil_dicom_image",
)
DBBACKUP_STORAGE = "django.core.files.storage.FileSystemStorage"
DBBACKUP_STORAGE_OPTIONS = {"location": os.path.join(BASE_DIR, "../backups")}
DEFAULT_FILE_STORAGE = 'django_hashedfilenamestorage.storage.HashedFilenameFileSystemStorage' DEFAULT_FILE_STORAGE = (
"django_hashedfilenamestorage.storage.HashedFilenameFileSystemStorage"
)
TINYMCE_DEFAULT_CONFIG = { TINYMCE_DEFAULT_CONFIG = {
"theme": "silver", "theme": "silver",
@@ -238,21 +245,21 @@ TINYMCE_DEFAULT_CONFIG = {
"bold italic backcolor | alignleft aligncenter " "bold italic backcolor | alignleft aligncenter "
"alignright alignjustify | bullist numlist outdent indent | " "alignright alignjustify | bullist numlist outdent indent | "
"removeformat | code | help", "removeformat | code | help",
"skin": 'oxide-dark', "skin": "oxide-dark",
"menubar": 'tools', "menubar": "tools",
"content_css": 'dark', "content_css": "dark",
} }
DEFAULT_AUTO_FIELD='django.db.models.AutoField' DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = 'mail.xkjq.uk' EMAIL_HOST = "mail.xkjq.uk"
EMAIL_HOST_USER = 'test@xkjq.uk' EMAIL_HOST_USER = "test@xkjq.uk"
EMAIL_HOST_PASSWORD = 'b=GzK~4$oRVE' EMAIL_HOST_PASSWORD = "b=GzK~4$oRVE"
EMAIL_PORT = 465 EMAIL_PORT = 587
EMAIL_USE_TLS = True EMAIL_USE_TLS = False
EMAIL_USE_SSl = True EMAIL_USE_SSl = False
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
try: try: