forked from expo/troggle
Use logon not cookie when editing pages
This commit is contained in:
+16
-29
@@ -8,20 +8,18 @@ from django.shortcuts import redirect, render
|
||||
from django.urls import reverse
|
||||
|
||||
import troggle.settings as settings
|
||||
from troggle.core.utils import (
|
||||
COOKIE_MAX_AGE,
|
||||
WriteAndCommitError,
|
||||
current_expo,
|
||||
get_cookie,
|
||||
git_string,
|
||||
write_and_commit,
|
||||
)
|
||||
from troggle.core.models.troggle import DataIssue, Person
|
||||
from troggle.core.views.editor_helpers import HTMLarea
|
||||
from troggle.core.utils import (
|
||||
COOKIE_MAX_AGE,
|
||||
WriteAndCommitError,
|
||||
add_commit,
|
||||
current_expo,
|
||||
get_cookie,
|
||||
get_git_string,
|
||||
git_string,
|
||||
is_identified_user,
|
||||
write_and_commit,
|
||||
current_expo
|
||||
)
|
||||
from troggle.parsers.users import get_encryptor, ENCRYPTED_DIR, how_many_previous_expos
|
||||
|
||||
@@ -51,27 +49,17 @@ def signupok(request):
|
||||
{"year": SIGNUP_YEAR, "dates": SIGNUP_DATES, "signup_user": signup_user, "signedup_people": signedup_people},
|
||||
)
|
||||
|
||||
|
||||
def signup(request):
|
||||
"""Display and processes the applicant signup form for the forthcoming expo
|
||||
The user must be logged-on as a personal login and that is
|
||||
who is being sighned up. You can't signup someone else.
|
||||
who is being signed up. You can't signup someone else.
|
||||
"""
|
||||
signup_user = request.user
|
||||
|
||||
if signup_user.is_anonymous:
|
||||
personal_login = False
|
||||
elif signup_user.username in ["expo", "expoadmin"]:
|
||||
personal_login = False
|
||||
else:
|
||||
personal_login = True
|
||||
|
||||
if personal_login:
|
||||
people = Person.objects.filter(user=signup_user)
|
||||
if len(people) != 1:
|
||||
# someone like "fluffy-bunny" not associated with a Person
|
||||
return HttpResponseRedirect("/accounts/login/?next=/signup")
|
||||
signup_person = people[0]
|
||||
editor = f"{signup_person.fullname} <{signup_user.email}>"
|
||||
identified_login = is_identified_user(signup_user)
|
||||
|
||||
if identified_login:
|
||||
editor = get_git_string(signup_user)
|
||||
else:
|
||||
editor = f"troggle <signup_anon@austria.expo>"
|
||||
|
||||
@@ -89,7 +77,7 @@ def signup(request):
|
||||
print(f" # Signup form INVALID\n{pageform.errors} ")
|
||||
return render(
|
||||
request, "login/signup.html",
|
||||
{"form": pageform, "personal_login": personal_login,
|
||||
{"form": pageform, "identified_login": identified_login,
|
||||
"year": SIGNUP_YEAR, "dates": SIGNUP_DATES,
|
||||
}
|
||||
)
|
||||
@@ -107,16 +95,15 @@ def signup(request):
|
||||
"top_tent_cap": 2,
|
||||
"base_tent_cap": 3,
|
||||
}
|
||||
if personal_login:
|
||||
if identified_login:
|
||||
initial_context["name"] = signup_person.fullname
|
||||
initial_context["email"] = signup_user.email
|
||||
initial_context["experience"] = experience
|
||||
|
||||
|
||||
pageform = ExpoSignupForm(initial=initial_context)
|
||||
return render(
|
||||
request, "login/signup.html",
|
||||
{"form": pageform, "personal_login": personal_login,
|
||||
{"form": pageform, "identified_login": identified_login,
|
||||
"year": SIGNUP_YEAR, "dates": SIGNUP_DATES,
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user