diff --git a/scipost_django/careers/views.py b/scipost_django/careers/views.py index b4712d166861aa99182a63b97f90b90bb708efe8..db41a094ae05e17fba78610b572325625998545e 100644 --- a/scipost_django/careers/views.py +++ b/scipost_django/careers/views.py @@ -4,13 +4,13 @@ __license__ = "AGPL v3" from django.contrib import messages from django.contrib.auth.mixins import UserPassesTestMixin -from django.contrib.sites.models import Site from django.urls import reverse_lazy from django.shortcuts import get_object_or_404, redirect from django.views.generic.detail import DetailView from django.views.generic.edit import CreateView, UpdateView from django.views.generic.list import ListView +from common.utils import get_current_domain from mails.utils import DirectMailUtil from .models import JobOpening, JobApplication @@ -85,7 +85,7 @@ class JobOpeningApplyView(CreateView): "careers/jobapplication_ack", delayed_processing=False, bcc=[ - "admin@{domain}".format(domain=Site.objects.get_current().domain), + "admin@{domain}".format(domain=get_current_domain()), ], jobapplication=self.object, ) diff --git a/scipost_django/commentaries/views.py b/scipost_django/commentaries/views.py index e9ac27b9fcb1494dac860ccc29389a8e31b96d25..9a72d41bf603c4d08c7f52869d2142cd6cc352b1 100644 --- a/scipost_django/commentaries/views.py +++ b/scipost_django/commentaries/views.py @@ -5,7 +5,6 @@ __license__ = "AGPL v3" from django.shortcuts import get_object_or_404, render from django.contrib import messages from django.contrib.auth.decorators import login_required, permission_required -from django.contrib.sites.models import Site from django.core.mail import EmailMessage from django.urls import reverse, reverse_lazy from django.db import transaction @@ -30,6 +29,7 @@ from .forms import ( from comments.models import Comment from comments.forms import CommentForm +from common.utils import get_current_domain from journals.models import Publication from scipost.mixins import PaginationMixin @@ -141,7 +141,7 @@ def vet_commentary_requests(request, commentary_id=None): request.POST or None, user=request.user, commentary_id=commentary_id ) if form.is_valid(): - domain = Site.objects.get_current().domain + domain = get_current_domain() # Get commentary commentary = form.get_commentary() @@ -194,7 +194,7 @@ def modify_commentary_request(request, commentary_id): ) form = RequestCommentaryForm(request.POST or None, instance=commentary) if form.is_valid(): - domain = Site.objects.get_current().domain + domain = get_current_domain() # Process commentary data commentary = form.save(commit=False) diff --git a/scipost_django/common/utils.py b/scipost_django/common/utils.py index d5253b54d8db6c29d48062e1a190f57f4f1979e2..5d3e35bd2c167aae79f70c2bad8ad110f62dfa7b 100644 --- a/scipost_django/common/utils.py +++ b/scipost_django/common/utils.py @@ -125,16 +125,23 @@ def jatsify_tags(text): return jatsified +def get_current_domain(): + try: + return Site.objects.get_current().domain + except: + return "fake.domain" + + # MARKED FOR DEPRECATION class BaseMailUtil(object): - mail_sender = "no-reply@%s" % Site.objects.get_current().domain + mail_sender = "no-reply@%s" % get_current_domain() mail_sender_title = "" @classmethod def load(cls, _dict, request=None): cls._context = _dict cls._context["request"] = request - cls._context["domain"] = Site.objects.get_current().domain + cls._context["domain"] = get_current_domain() for var_name in _dict: setattr(cls, var_name, _dict[var_name]) diff --git a/scipost_django/invitations/utils.py b/scipost_django/invitations/utils.py index 0962bf956710129b3a161953c68a28eed68d33e6..98f4d67755a70a557b03fe8fffaa81d3b4f399f0 100644 --- a/scipost_django/invitations/utils.py +++ b/scipost_django/invitations/utils.py @@ -2,13 +2,11 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" __license__ = "AGPL v3" -from django.contrib.sites.models import Site - -from common.utils import BaseMailUtil +from common.utils import get_current_domain, BaseMailUtil class Utils(BaseMailUtil): - mail_sender = "invitations@%s" % Site.objects.get_current().domain + mail_sender = "invitations@%s" % get_current_domain() mail_sender_title = "SciPost Invitation" @classmethod diff --git a/scipost_django/invitations/views.py b/scipost_django/invitations/views.py index 80bb7d189d7947638cfa703d45d6297aca992817..bcd27f899fd96aa46d3e1dce7f347ef817d73c07 100644 --- a/scipost_django/invitations/views.py +++ b/scipost_django/invitations/views.py @@ -4,7 +4,6 @@ __license__ = "AGPL v3" from django.contrib import messages from django.contrib.auth.decorators import login_required, permission_required -from django.contrib.sites.models import Site from django.db import transaction from django.shortcuts import render, redirect from django.urls import reverse_lazy, reverse @@ -29,6 +28,7 @@ from .models import RegistrationInvitation, CitationNotification from scipost.models import Contributor from scipost.mixins import PaginationMixin, PermissionsMixin +from common.utils import get_current_domain from mails.views import MailFormView @@ -223,7 +223,7 @@ class RegistrationInvitationsUpdateView( def get_mail_config(self): config = super().get_mail_config() if self.object.invitation_type == INVITATION_EDITORIAL_FELLOW: - domain = Site.objects.get_current().domain + domain = get_current_domain() config["from_email"] = f"jscaux@{domain}" config["from_name"] = "J-S Caux" return config @@ -282,7 +282,7 @@ class RegistrationInvitationsReminderView( def get_mail_config(self): config = super().get_mail_config() if self.object.invitation_type == INVITATION_EDITORIAL_FELLOW: - domain = Site.objects.get_current().domain + domain = get_current_domain() config["from_email"] = f"jscaux@{domain}" config["from_name"] = "J-S Caux" return config diff --git a/scipost_django/journals/forms.py b/scipost_django/journals/forms.py index f71d223cb735478b0e97262e6156de41b5367e1f..cbf381d3a503623d12630946ca32b8514839876d 100644 --- a/scipost_django/journals/forms.py +++ b/scipost_django/journals/forms.py @@ -12,7 +12,6 @@ from datetime import datetime from django import forms from django.conf import settings -from django.contrib.sites.models import Site from django.db.models import Q from django.forms import BaseModelFormSet, modelformset_factory from django.template import loader @@ -41,7 +40,7 @@ from .models import ( from .utils import JournalUtils -from common.utils import jatsify_tags +from common.utils import get_current_domain, jatsify_tags from funders.models import Grant, Funder from journals.models import Journal from mails.utils import DirectMailUtil @@ -271,7 +270,7 @@ class CreateMetadataXMLForm(forms.ModelForm): # Render from template template = loader.get_template("xml/publication_crossref.html") context = { - "domain": Site.objects.get_current().domain, + "domain": get_current_domain(), "publication": publication, "doi_batch_id": doi_batch_id, "deposit_email": settings.CROSSREF_DEPOSIT_EMAIL, @@ -649,7 +648,7 @@ class DraftPublicationForm(forms.ModelForm): paper_nr, issue.until_date.strftime("%Y"), doi_string, - Site.objects.get_current().domain, + get_current_domain(), doi_string, ) @@ -686,7 +685,7 @@ class DraftPublicationForm(forms.ModelForm): paper_nr, timezone.now().year, doi_string, - Site.objects.get_current().domain, + get_current_domain(), doi_string, ) self.fields["BiBTeX_entry"].initial = bibtex_entry diff --git a/scipost_django/journals/models/update.py b/scipost_django/journals/models/update.py index 128ce0e7a40bcf45198c37525a7e8c6a88abd623..554a1bd8c598fdbc386b548969667cadbd614865 100644 --- a/scipost_django/journals/models/update.py +++ b/scipost_django/journals/models/update.py @@ -7,13 +7,14 @@ import random import string from django.conf import settings -from django.contrib.sites.models import Site from django.contrib.contenttypes.fields import GenericRelation from django.contrib.postgres.fields import JSONField from django.db import models from django.template import loader from django.urls import reverse +from common.utils import get_current_domain + class PublicationUpdate(models.Model): """ @@ -119,7 +120,7 @@ class PublicationUpdate(models.Model): # Render from template template = loader.get_template("xml/publication_update_crossref.html") context = { - "domain": Site.objects.get_current().domain, + "domain": get_current_domain(), "update": self, "doi_batch_id": doi_batch_id, "deposit_email": settings.CROSSREF_DEPOSIT_EMAIL, diff --git a/scipost_django/journals/utils.py b/scipost_django/journals/utils.py index c968b11a0a06311c24a4d07e8b6f9178420bc783..ffa81b0562b99b571467ecc3f8030f70319fe4f6 100644 --- a/scipost_django/journals/utils.py +++ b/scipost_django/journals/utils.py @@ -2,20 +2,19 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" __license__ = "AGPL v3" -from django.contrib.sites.models import Site from django.core.mail import EmailMessage -from common.utils import BaseMailUtil +from common.utils import get_current_domain, BaseMailUtil class JournalUtils(BaseMailUtil): - mail_sender = "edadmin@%s" % Site.objects.get_current().domain + mail_sender = "edadmin@%s" % get_current_domain() mail_sender_title = "SciPost Editorial Admin" @classmethod def send_authors_paper_published_email(cls): """Requires loading 'publication' attribute.""" - domain = Site.objects.get_current().domain + domain = get_current_domain() email_text = ( "Dear " + cls.publication.accepted_submission.submitted_by.profile.get_title_display() diff --git a/scipost_django/journals/views.py b/scipost_django/journals/views.py index 9c83c25a4ed49dc502ffaa3926bea15010bef71c..8c0e550fb7e32531bbf34e34a9211a1d843c3ad9 100644 --- a/scipost_django/journals/views.py +++ b/scipost_django/journals/views.py @@ -18,7 +18,6 @@ import plotly.graph_objects as pgo from django.contrib.auth.decorators import login_required from django.contrib.contenttypes.models import ContentType -from django.contrib.sites.models import Site from django.core.exceptions import PermissionDenied from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.urls import reverse, reverse_lazy @@ -79,6 +78,7 @@ from .services import update_citedby from .utils import JournalUtils from comments.models import Comment +from common.utils import get_current_domain from funders.forms import FunderSelectForm, GrantSelectForm from funders.models import Grant from mails.views import MailEditorSubview @@ -1452,7 +1452,7 @@ def generic_metadata_xml_deposit(request, **kwargs): For PublicationUpdates, the deposit type is `journal_article` and the journal is used as container. """ - domain = Site.objects.get_current().domain + domain = get_current_domain() type_of_object = kwargs["type_of_object"] object_id = int(kwargs["object_id"]) diff --git a/scipost_django/mails/core.py b/scipost_django/mails/core.py index f66ece12e8d5b40ee4f4f776adadf03c5804d3e0..bbc2d05dbb0b2a85ff201c147092de90897117ef 100644 --- a/scipost_django/mails/core.py +++ b/scipost_django/mails/core.py @@ -7,11 +7,12 @@ import re import inspect from django.conf import settings -from django.contrib.sites.models import Site from django.core.mail import EmailMultiAlternatives from django.db import models from django.template.loader import get_template +from common.utils import get_current_domain + from .exceptions import ConfigurationError @@ -68,7 +69,7 @@ class MailEngine: } self.template_variables = kwargs # Add the 'domain' template variable to all templates using the Sites framework: - self.template_variables["domain"] = Site.objects.get_current().domain + self.template_variables["domain"] = get_current_domain() def __repr__(self): return '<%(cls)s code="%(code)s", validated=%(validated)s sent=%(sent)s>' % { @@ -130,14 +131,14 @@ class MailEngine: % ( self.mail_data.get("from_name", "SciPost"), self.mail_data.get( - "from_email", "noreply@%s" % Site.objects.get_current().domain + "from_email", "noreply@%s" % get_current_domain() ), ), self.mail_data["recipient_list"], bcc=self.mail_data["bcc"], reply_to=[ self.mail_data.get( - "from_email", "noreply@%s" % Site.objects.get_current().domain + "from_email", "noreply@%s" % get_current_domain() ) ], headers={ @@ -280,7 +281,7 @@ class MailEngine: return entry # if the email address is given as a prefix of the form `[recipient]@`, add domain name: elif re.match("[^@]+@$", entry): - return "%s%s" % (entry, Site.objects.get_current().domain) + return "%s%s" % (entry, get_current_domain()) elif self.template_variables["object"]: mail_to = self.template_variables["object"] for attr in entry.split("."): diff --git a/scipost_django/mails/mixins.py b/scipost_django/mails/mixins.py index 59e1cee96856234f01cb25b633bc65c4f8f5086c..ae3060d6400546cd40a8f5593ce4b1b9ad54e362 100644 --- a/scipost_django/mails/mixins.py +++ b/scipost_django/mails/mixins.py @@ -10,11 +10,11 @@ from html2text import HTML2Text from django.core.mail import EmailMultiAlternatives from django.contrib.auth import get_user_model -from django.contrib.sites.models import Site from django.conf import settings from django.template import loader from scipost.models import Contributor +from common.utils import get_current_domain class MailUtilsMixin: @@ -59,7 +59,7 @@ class MailUtilsMixin: "bcc_to": kwargs.pop("bcc", ""), "from_address_name": kwargs.pop("from_name", "SciPost"), "from_address": kwargs.pop( - "from", "no-reply@%s" % Site.objects.get_current().domain + "from", "no-reply@%s" % get_current_domain() ), } diff --git a/scipost_django/ontology/forms.py b/scipost_django/ontology/forms.py index 20f806c49c98b495e3f3fcc965d0eb4180212259..02b6146fbdc9037dc35c9f398779ed6616c6cc76 100644 --- a/scipost_django/ontology/forms.py +++ b/scipost_django/ontology/forms.py @@ -3,6 +3,7 @@ __license__ = "AGPL v3" from django import forms +from django.db.utils import ProgrammingError from crispy_forms.helper import FormHelper from crispy_forms.layout import Layout, Div @@ -15,13 +16,16 @@ from .models import Branch, AcademicField, Specialty, Tag, Topic def academic_field_slug_choices(): choices = (("All", (("all", "All"),)),) - for branch in Branch.objects.all(): - if branch.name != "Multidisciplinary" and branch.journals.active().exists(): - subchoices = () - for acad_field in branch.academic_fields.all(): - if acad_field.journals.active().exists(): - subchoices += ((acad_field.slug, acad_field.name),) - choices += ((branch.name, subchoices),) + try: + for branch in Branch.objects.all(): + if branch.name != "Multidisciplinary" and branch.journals.active().exists(): + subchoices = () + for acad_field in branch.academic_fields.all(): + if acad_field.journals.active().exists(): + subchoices += ((acad_field.slug, acad_field.name),) + choices += ((branch.name, subchoices),) + except ProgrammingError: # when running on new, empty database + pass return choices diff --git a/scipost_django/petitions/views.py b/scipost_django/petitions/views.py index f6b1d86c9e2af73c959c4f0f0d41f25b3f25ffee..da8541769ac1660c78713cc97859b52a46e734ff 100644 --- a/scipost_django/petitions/views.py +++ b/scipost_django/petitions/views.py @@ -7,11 +7,11 @@ import random import string from django.contrib import messages -from django.contrib.sites.models import Site from django.core.mail import EmailMultiAlternatives from django.shortcuts import get_object_or_404, render, redirect from django.template import Context, Template +from common.utils import get_current_domain from mails.utils import DirectMailUtil from .models import Petition, PetitionSignatory @@ -49,7 +49,7 @@ def petition(request, slug): current_user=request.user, ) if form.is_valid(): - domain = Site.objects.get_current().domain + domain = get_current_domain() signature = form.save(commit=False) signature.petition = petition message = ( diff --git a/scipost_django/preprints/models.py b/scipost_django/preprints/models.py index 5e27bf3dcc51edfab8cca13a0e30d6396452862f..4d7d911dc00f5319f8c17f86b1ab35003ac114ae 100644 --- a/scipost_django/preprints/models.py +++ b/scipost_django/preprints/models.py @@ -4,11 +4,11 @@ __license__ = "AGPL v3" import requests -from django.contrib.sites.models import Site from django.urls import reverse from django.db import models from django.http import Http404 +from common.utils import get_current_domain from submissions.exceptions import PreprintDocumentNotFoundError @@ -68,7 +68,7 @@ class Preprint(models.Model): """Return the absolute URL of the pdf for the meta tag for Google Scholar.""" if self._file: # means this is a SciPost-hosted preprint return "https://%s%s" % ( - Site.objects.get_current().domain, + get_current_domain(), self.get_absolute_url(), ) elif self.is_arXiv: diff --git a/scipost_django/production/utils.py b/scipost_django/production/utils.py index 1e202e22acb8c2b796bc550ce341f146737536d1..994670e10bac7974c5513cbcaeb846283b48fa2f 100644 --- a/scipost_django/production/utils.py +++ b/scipost_django/production/utils.py @@ -5,7 +5,7 @@ from django.contrib.auth.models import Group from django.contrib.sites.models import Site from guardian.shortcuts import assign_perm -from common.utils import BaseMailUtil +from common.utils import get_current_domain, BaseMailUtil def proofs_id_to_slug(id): @@ -29,7 +29,7 @@ def get_or_create_production_stream(submission): class ProductionUtils(BaseMailUtil): - mail_sender = "proofs@%s" % Site.objects.get_current().domain + mail_sender = "proofs@%s" % get_current_domain() mail_sender_title = "SciPost Production" @classmethod diff --git a/scipost_django/scipost/forms.py b/scipost_django/scipost/forms.py index 58556ebc0e3579dda69ad2452b7928b4aeaabd43..2af2ae31b3a1203e76094a5cac56a2a59236192d 100644 --- a/scipost_django/scipost/forms.py +++ b/scipost_django/scipost/forms.py @@ -12,7 +12,6 @@ from django.contrib.auth.models import User, Group from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.password_validation import validate_password from django.contrib.auth.validators import UnicodeUsernameValidator -from django.contrib.sites.models import Site from django.core.exceptions import ValidationError from django.http import Http404 from django.utils import timezone @@ -45,6 +44,7 @@ from common.forms import ModelChoiceFieldwithid from colleges.models import Fellowship, PotentialFellowshipEvent from commentaries.models import Commentary from comments.models import Comment +from common.utils import get_current_domain from funders.models import Grant from invitations.models import CitationNotification from journals.models import PublicationAuthorsTable, Publication @@ -62,7 +62,7 @@ from submissions.models import ( ) from theses.models import ThesisLink -domain = Site.objects.get_current().domain +domain = get_current_domain() REGISTRATION_REFUSAL_CHOICES = ( (None, "-"), diff --git a/scipost_django/scipost/tasks.py b/scipost_django/scipost/tasks.py index d84fab4fc12621f287d7242b3f710f712b222601..f4c69eb006953928cb6481cffff40c3c362633dc 100644 --- a/scipost_django/scipost/tasks.py +++ b/scipost_django/scipost/tasks.py @@ -2,12 +2,12 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" __license__ = "AGPL v3" -from django.contrib.sites.models import Site from django.core.mail import send_mail from SciPost_v1.celery import app +from common.utils import get_current_domain -domain = Site.objects.get_current().domain +domain = get_current_domain() @app.task(bind=True) diff --git a/scipost_django/scipost/utils.py b/scipost_django/scipost/utils.py index ea97efa8077fbb3eec36b256106894a46baa2c90..daaaf89ca7e3fe5bbe9f00552ceaab1de959ca0e 100644 --- a/scipost_django/scipost/utils.py +++ b/scipost_django/scipost/utils.py @@ -2,9 +2,9 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" __license__ = "AGPL v3" -from django.contrib.sites.models import Site +from common.utils import get_current_domain -domain = Site.objects.get_current().domain +domain = get_current_domain() from common.utils import BaseMailUtil diff --git a/scipost_django/scipost/views.py b/scipost_django/scipost/views.py index 8990cf725b522eab33833da6f4ae45ae1012095c..6f1c457b729e292c0acb98c5122ff37dc261d846 100644 --- a/scipost_django/scipost/views.py +++ b/scipost_django/scipost/views.py @@ -21,7 +21,6 @@ from django.contrib.auth.views import ( PasswordResetConfirmView, ) from django.contrib.messages.views import SuccessMessageMixin -from django.contrib.sites.models import Site from django.core import mail from django.core.exceptions import PermissionDenied from django.core.mail import EmailMessage, EmailMultiAlternatives @@ -71,6 +70,7 @@ from commentaries.models import Commentary from commentaries.forms import CommentarySearchForm from comments.models import Comment from comments.forms import CommentSearchForm +from common.utils import get_current_domain from invitations.constants import STATUS_REGISTERED from invitations.models import RegistrationInvitation from journals.models import Journal, Publication, PublicationAuthorsTable @@ -666,7 +666,7 @@ def vet_registration_request_ack(request, contributor_id): form = VetRegistrationForm(request.POST or None) contributor = Contributor.objects.get(pk=contributor_id) if form.is_valid(): - domain = Site.objects.get_current().domain + domain = get_current_domain() if form.promote_to_registered_contributor(): contributor.status = NORMAL_CONTRIBUTOR contributor.vetted_by = request.user.contributor @@ -1619,7 +1619,7 @@ def email_group_members(request): """ form = EmailGroupMembersForm(request.POST or None) if form.is_valid(): - domain = Site.objects.get_current().domain + domain = get_current_domain() group_members = ( form.cleaned_data["group"] .user_set.filter(contributor__isnull=False) @@ -1700,7 +1700,7 @@ def email_particular(request): if request.method == "POST": form = EmailParticularForm(request.POST) if form.is_valid(): - domain = Site.objects.get_current().domain + domain = get_current_domain() email_text = form.cleaned_data["email_text"] email_text_html = "{{ email_text|linebreaks }}" email_context = {"email_text": form.cleaned_data["email_text"]} @@ -1739,7 +1739,7 @@ def send_precooked_email(request): """ form = SendPrecookedEmailForm(request.POST or None) if form.is_valid(): - domain = Site.objects.get_current().domain + domain = get_current_domain() precookedEmail = form.cleaned_data["email_option"] if form.cleaned_data["email_address"] in precookedEmail.emailed_to: errormessage = "This message has already been sent to this address" diff --git a/scipost_django/submissions/utils.py b/scipost_django/submissions/utils.py index d08280ec0c98a4de57c0b01054f223d6e1657783..65fc7e3e8de0b7a7d9060acf644f6af6c225a86e 100644 --- a/scipost_django/submissions/utils.py +++ b/scipost_django/submissions/utils.py @@ -4,7 +4,6 @@ __license__ = "AGPL v3" import datetime -from django.contrib.sites.models import Site from django.core.mail import EmailMessage, EmailMultiAlternatives from django.template import Context, Template @@ -17,9 +16,9 @@ from .constants import ( ) from scipost.utils import EMAIL_FOOTER -from common.utils import BaseMailUtil +from common.utils import get_current_domain, BaseMailUtil -domain = Site.objects.get_current().domain +domain = get_current_domain() class SubmissionUtils(BaseMailUtil): diff --git a/scipost_django/submissions/views.py b/scipost_django/submissions/views.py index d252e1d0d18067b917384a0a7c41f25c38d11e0d..236b71332f1efe1ef0c398e23f520bc7be34bbe2 100644 --- a/scipost_django/submissions/views.py +++ b/scipost_django/submissions/views.py @@ -20,7 +20,6 @@ from django.contrib.auth.mixins import ( UserPassesTestMixin, ) from django.contrib.messages.views import SuccessMessageMixin -from django.contrib.sites.models import Site from django.core.exceptions import PermissionDenied from django.core.paginator import Paginator from django.db import transaction, IntegrityError @@ -115,7 +114,7 @@ from colleges.permissions import ( ) from comments.forms import CommentForm from common.helpers import get_new_secrets_key -from common.utils import workdays_between +from common.utils import get_current_domain, workdays_between from invitations.constants import STATUS_SENT from invitations.models import RegistrationInvitation from journals.models import Journal, Publication @@ -792,7 +791,7 @@ def report_pdf_compile(request, report_id): messages.success(request, "Upload complete.") return redirect(reverse("submissions:reports_accepted_list")) context = { - "domain": Site.objects.get_current().domain, + "domain": get_current_domain(), "report": report, "form": form, } @@ -828,7 +827,7 @@ def treated_submission_pdf_compile(request, identifier_w_vn_nr): messages.success(request, "Upload complete.") return redirect(reverse("submissions:treated_submissions_list")) context = { - "domain": Site.objects.get_current().domain, + "domain": get_current_domain(), "submission": submission, "form": form, } diff --git a/scipost_django/theses/forms.py b/scipost_django/theses/forms.py index 70ef57f20d4928cf63532100015210b1bfa44062..83a48f36fad00053989114cf3df310aaec59a49f 100644 --- a/scipost_django/theses/forms.py +++ b/scipost_django/theses/forms.py @@ -3,7 +3,6 @@ __license__ = "AGPL v3" from django import forms -from django.contrib.sites.models import Site from django.core.mail import EmailMessage from django.template.loader import render_to_string @@ -13,6 +12,7 @@ from crispy_bootstrap5.bootstrap5 import FloatingField from scipost.models import Contributor from scipost.utils import build_absolute_uri_using_site +from common.utils import get_current_domain from .models import ThesisLink from .helpers import past_years @@ -124,7 +124,7 @@ class VetThesisLinkForm(BaseRequestThesisLinkForm): thesislink.delete() - domain = Site.objects.get_current().domain + domain = get_current_domain() email = EmailMessage( subject_line, message_plain, diff --git a/scipost_django/webinars/views.py b/scipost_django/webinars/views.py index 7b4b0dbf2ae00129451ac682b60483d7e1c060eb..0e8fc8e9bcca12c846db9f8be05f77615b5bd584 100644 --- a/scipost_django/webinars/views.py +++ b/scipost_django/webinars/views.py @@ -3,13 +3,13 @@ __license__ = "AGPL v3" from django.contrib import messages -from django.contrib.sites.models import Site from django.shortcuts import get_object_or_404, redirect, render from django.urls import reverse from .models import Webinar from .forms import WebinarRegistrationForm +from common.utils import get_current_domain from mails.utils import DirectMailUtil @@ -44,7 +44,7 @@ def webinar_register(request, slug): "webinars/webinar_registration_ack", delayed_processing=False, bcc=[ - "admin@{domain}".format(domain=Site.objects.get_current().domain), + "admin@{domain}".format(domain=get_current_domain()), ], registration=registration, )