clean up
This commit is contained in:
+15
-6
@@ -269,18 +269,27 @@ SENDGRID_API_KEY = (
|
||||
"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"
|
||||
)
|
||||
|
||||
EMAIL_HOST = "smtp.sendgrid.net"
|
||||
EMAIL_HOST_USER = "apikey" # this is exactly the value 'apikey'
|
||||
EMAIL_HOST_PASSWORD = SENDGRID_API_KEY
|
||||
EMAIL_PORT = 587
|
||||
EMAIL_USE_TLS = True
|
||||
# SENDGRID
|
||||
#EMAIL_HOST = "smtp.sendgrid.net"
|
||||
#EMAIL_HOST_USER = "apikey" # this is exactly the value 'apikey'
|
||||
#EMAIL_HOST_PASSWORD = SENDGRID_API_KEY
|
||||
#EMAIL_PORT = 587
|
||||
#EMAIL_USE_TLS = True
|
||||
|
||||
# EMAIL_HOST = "smtp.office365.com "
|
||||
# EMAIL_HOST_USER = "Penra.courses@nhs.net"
|
||||
# EMAIL_HOST_PASSWORD = '"got3<}%o"~\J",\Di3<'
|
||||
# EMAIL_PORT = 587
|
||||
# EMAIL_USE_TLS = True
|
||||
# EMAIL_USE_SSl = False
|
||||
# DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
|
||||
|
||||
DEFAULT_FROM_EMAIL = "no-reply@penracourses.org.uk"
|
||||
EMAIL_HOST = "webhosting2027.is.cc"
|
||||
EMAIL_HOST_USER = "no-reply@penracourses.org.uk"
|
||||
EMAIL_HOST_PASSWORD = "I(5E)&1w+Bh)"
|
||||
EMAIL_PORT = 465
|
||||
#EMAIL_USE_TLS = True
|
||||
EMAIL_USE_SSL = True
|
||||
|
||||
try:
|
||||
from .settings_local import *
|
||||
|
||||
@@ -53,8 +53,12 @@ urlpatterns = [
|
||||
path("sbas/", include("sbas.urls"), name="sbas"),
|
||||
path("generic/", include("generic.urls"), name="generic"),
|
||||
path("atlas/", include("atlas.urls"), name="atlas"),
|
||||
path("accounts/update/<str:slug>/", views.UpdateUserView.as_view(), name="account_update"),
|
||||
path("accounts/update_profile/<str:slug>/", views.UpdateUserProfileView.as_view(), name="account_profile_update"),
|
||||
path("accounts/", views.UserListView.as_view(), name="accounts_list"),
|
||||
path("accounts/", include("django.contrib.auth.urls")),
|
||||
path("accounts/profile", views.profile, name="profile"),
|
||||
path("accounts/profile/<str:slug>/", views.account_profile, name="account_profile"),
|
||||
path("", TemplateView.as_view(template_name="index.html"), name="home"),
|
||||
path("cid/results/<int:cid>/", views.cid_results, name="cid_results"),
|
||||
path("cid/<int:pk>/<str:passcode>", views.cid_scores, name="cid_scores"),
|
||||
|
||||
+72
-4
@@ -1,6 +1,6 @@
|
||||
from atlas.models import CaseCollection, CidReportAnswer
|
||||
from generic.decorators import user_is_cid_user_manager
|
||||
from generic.views import get_question_and_content_type
|
||||
from generic.views import CidManagerRequiredMixin, get_question_and_content_type
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
@@ -15,7 +15,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
|
||||
from django.views.generic.edit import CreateView, UpdateView, DeleteView
|
||||
from django.views.generic import ListView
|
||||
from django.views.generic import ListView, TemplateView
|
||||
|
||||
from django.db.models.functions import Lower
|
||||
|
||||
@@ -54,7 +54,7 @@ from rapids.views import GenericExamViews as RapidsExamsViews
|
||||
from longs.views import GenericExamViews as LongsExamViews
|
||||
|
||||
from generic.forms import QuestionNoteForm
|
||||
from generic.models import CidUser, QuestionNote
|
||||
from generic.models import CidUser, QuestionNote, UserProfile
|
||||
|
||||
import json
|
||||
|
||||
@@ -71,6 +71,12 @@ def profile(request):
|
||||
return render(request, "profile.html", {"user": user})
|
||||
|
||||
|
||||
@user_is_cid_user_manager
|
||||
def account_profile(request, slug):
|
||||
user = get_object_or_404(User, username=slug)
|
||||
return render(request, "profile.html", {"user": user})
|
||||
|
||||
|
||||
def cid_selector(request):
|
||||
return render(
|
||||
request,
|
||||
@@ -87,7 +93,7 @@ def cid_scores_admin(request, cid):
|
||||
|
||||
|
||||
@login_required
|
||||
#@user_passes_test(lambda u: u.is_superuser)
|
||||
# @user_passes_test(lambda u: u.is_superuser)
|
||||
@user_is_cid_user_manager
|
||||
def cid_results(request, cid):
|
||||
cid_user = CidUser.objects.filter(cid=cid).first()
|
||||
@@ -432,3 +438,65 @@ def server_error(request):
|
||||
# response.status_code = 404
|
||||
|
||||
return response
|
||||
|
||||
|
||||
class UserListView(CidManagerRequiredMixin, ListView):
|
||||
model = User
|
||||
template_name = "user_list_view.html"
|
||||
|
||||
|
||||
class UpdateUserView(CidManagerRequiredMixin, UpdateView):
|
||||
model = User
|
||||
fields = ["first_name", "last_name", "email"] # Keep listing whatever fields
|
||||
# the combined UserProfile and User exposes.
|
||||
template_name = "user_update.html"
|
||||
slug_field = "username"
|
||||
slug_url_kwarg = "slug"
|
||||
success_url = reverse_lazy("profile")
|
||||
|
||||
|
||||
class UpdateUserProfileView(CidManagerRequiredMixin, UpdateView):
|
||||
model = UserProfile
|
||||
fields = [
|
||||
"supervisor_name",
|
||||
"supervisor_email",
|
||||
"grade",
|
||||
"registration_number",
|
||||
"peninsula_trainee",
|
||||
] # Keep listing whatever fields
|
||||
template_name = "user_update.html"
|
||||
slug_field = "user__username"
|
||||
slug_url_kwarg = "slug"
|
||||
success_url = reverse_lazy("profile")
|
||||
|
||||
|
||||
# class UpdateUser(TemplateView):
|
||||
#
|
||||
# user_form_class = UserForm
|
||||
# comment_form_class = UserProfileForm
|
||||
# template_name = 'user_update.html'
|
||||
# slug_field = 'username'
|
||||
# slug_url_kwarg = 'slug'
|
||||
#
|
||||
# def post(self, request):
|
||||
# post_data = request.POST or None
|
||||
# user_form = self.user_form_class(post_data, prefix='user')
|
||||
# profile_form = self.profile_form_class(post_data, prefix='userprofile')
|
||||
#
|
||||
# context = self.get_context_data(post_form=user_form,
|
||||
# profile_form=profile_form)
|
||||
#
|
||||
# if user_form.is_valid():
|
||||
# self.form_save(user_form)
|
||||
# if profile_form.is_valid():
|
||||
# self.form_save(profile_form)
|
||||
#
|
||||
# return self.render_to_response(context)
|
||||
#
|
||||
# def form_save(self, form):
|
||||
# obj = form.save()
|
||||
# #messages.success(self.request, "{} saved successfully".format(obj))
|
||||
# return obj
|
||||
#
|
||||
# def get(self, request, *args, **kwargs):
|
||||
# return self.post(request, *args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user