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.models import ContentType
from django.core.mail import send_mail
class Plane(models.Model):
plane = models.CharField(max_length=200)
@@ -216,6 +218,20 @@ class CidUser(models.Model):
def check_passcode(self, passcode) -> bool:
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):
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
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",
),
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"),
]
+10
View File
@@ -988,6 +988,16 @@ class CidUserView(LoginRequiredMixin, SingleTableMixin, FilterView):
context["cid_user_groups"] = cid_user_groups
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
@user_is_cid_user_manager
+75 -68
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/
# 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()
# SECURITY WARNING: don't run with debug turned on in production!
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
INSTALLED_APPS = [
'generic',
'anatomy',
'physics',
'rapids',
'longs',
'sbas',
'wally',
'atlas',
"generic",
"anatomy",
"physics",
"rapids",
"longs",
"sbas",
"wally",
"atlas",
"reversion",
"django_tables2",
"django_filters",
@@ -48,13 +54,13 @@ INSTALLED_APPS = [
"dal",
"dal_select2",
"dal_queryset_sequence",
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'debug_toolbar',
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"debug_toolbar",
"tagulous",
"dbbackup",
"rest_framework",
@@ -71,10 +77,10 @@ MIDDLEWARE = [
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"reversion.middleware.RevisionMiddleware",
'debug_toolbar.middleware.DebugToolbarMiddleware',
"debug_toolbar.middleware.DebugToolbarMiddleware",
]
ROOT_URLCONF = 'rad.urls'
ROOT_URLCONF = "rad.urls"
TEMPLATES = [
{
@@ -93,18 +99,18 @@ TEMPLATES = [
},
]
WSGI_APPLICATION = 'rad.wsgi.application'
WSGI_APPLICATION = "rad.wsgi.application"
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "rad",
"USER": "django",
"PASSWORD": "f7bf31dc9bda1256ea827953480d1917",
#"HOST": "xkjq.uk",
# "HOST": "xkjq.uk",
"HOST": "161.35.163.87",
"PORT": "5432",
}
@@ -115,20 +121,16 @@ DATABASES = {
AUTH_PASSWORD_VALIDATORS = [
{
'NAME':
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
'NAME':
'django.contrib.auth.password_validation.MinimumLengthValidator',
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
'NAME':
'django.contrib.auth.password_validation.CommonPasswordValidator',
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
'NAME':
'django.contrib.auth.password_validation.NumericPasswordValidator',
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]
@@ -142,9 +144,9 @@ SERIALIZATION_MODULES = {
# Internationalization
# 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
@@ -156,20 +158,20 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.11/howto/static-files/
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_ROOT = 'static/'
STATIC_URL = "/static/"
STATIC_ROOT = "static/"
REMOTE_URL = "https://www.penracourses.org.uk"
#
#if DEBUG:
# if DEBUG:
# STATIC_URL = REMOTE_URL + STATIC_URL
MEDIA_URL = '/media/'
MEDIA_ROOT = '/home/django/rad/media/'
MEDIA_URL = "/media/"
MEDIA_ROOT = "/home/django/rad/media/"
#if DEBUG:
# if DEBUG:
# MEDIA_URL = REMOTE_URL + MEDIA_URL
# Redirect to home URL after login (Default redirects to /accounts/profile/)
@@ -177,10 +179,10 @@ LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/"
TAGULOUS_AUTOCOMPLETE_JS = (
"tagulous/lib/jquery.js",
"tagulous/lib/select2-3/select2.min.js",
"tagulous/tagulous.js",
"tagulous/adaptor/select2-3.js",
"tagulous/lib/jquery.js",
"tagulous/lib/select2-3/select2.min.js",
"tagulous/tagulous.js",
"tagulous/adaptor/select2-3.js",
)
TAGULOUS_AUTOCOMPLETE_CSS = {"all": ["tagulous/lib/select2-3/select2.css"]}
@@ -199,33 +201,38 @@ LOGGING = {
CORS_ORIGIN_ALLOW_ALL = True
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
'LOCATION': '127.0.0.1:11211',
"default": {
"BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
"LOCATION": "127.0.0.1:11211",
#'OPTIONS': {
# 'server_max_value_length': 1024 * 1024 * 10
#}
# }
},
"filesystem": {
"BACKEND": "django.core.cache.backends.filebased.FileBasedCache",
"LOCATION": "/var/tmp/django_cache",
},
'filesystem': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': '/var/tmp/django_cache',
}
}
THUMBNAIL_ALIASES = {
'': {
'exam-list': {'size': (50, 50), 'crop': True},
"": {
"exam-list": {"size": (50, 50), "crop": True},
},
}
DATA_UPLOAD_MAX_NUMBER_FIELDS = 50000
THUMBNAIL_SOURCE_GENERATORS = ('easy_thumbnails.source_generators.pil_image', 'helpers.images.pil_dicom_image')
DBBACKUP_STORAGE = 'django.core.files.storage.FileSystemStorage'
DBBACKUP_STORAGE_OPTIONS = {'location': os.path.join(BASE_DIR, '../backups')}
THUMBNAIL_SOURCE_GENERATORS = (
"easy_thumbnails.source_generators.pil_image",
"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 = {
"theme": "silver",
@@ -238,21 +245,21 @@ TINYMCE_DEFAULT_CONFIG = {
"bold italic backcolor | alignleft aligncenter "
"alignright alignjustify | bullist numlist outdent indent | "
"removeformat | code | help",
"skin": 'oxide-dark',
"menubar": 'tools',
"content_css": 'dark',
"skin": "oxide-dark",
"menubar": "tools",
"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_USER = 'test@xkjq.uk'
EMAIL_HOST_PASSWORD = 'b=GzK~4$oRVE'
EMAIL_PORT = 465
EMAIL_USE_TLS = True
EMAIL_USE_SSl = True
EMAIL_HOST = "mail.xkjq.uk"
EMAIL_HOST_USER = "test@xkjq.uk"
EMAIL_HOST_PASSWORD = "b=GzK~4$oRVE"
EMAIL_PORT = 587
EMAIL_USE_TLS = False
EMAIL_USE_SSl = False
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
try: