Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix professor slugs to try lastname first then lastname_firstname #57

Merged
merged 2 commits into from
Dec 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions home/views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,17 +313,20 @@ def verify_professor(self, verified_status: Professor.Status, slug: Optional[str
return JsonResponse(response)

split_name = str(professor.name).strip().split(" ")
new_slug = "_".join(reversed(split_name)).lower()
new_slug = split_name[-1].lower()
modal_msg = None

if Professor.verified.filter(slug=new_slug).exists():
modal_msg = mark_safe(f"The slug <b>{new_slug}</b> already belongs to a professor. Please enter a slug below.")

if len(split_name) > 2:
modal_msg = (
f"The name '{professor.name}' is too long and "
"can't be slugged automatcially. Please enter a slug below."
)
professors = Professor.verified.all()
if professors.filter(slug=new_slug).exists():
new_slug = "_".join(reversed(split_name)).lower()
if professors.filter(slug=new_slug).exists():
modal_msg = mark_safe(f"The slug <b>{new_slug}</b> already belongs to a professor. Please enter a slug below.")

if len(split_name) > 2:
modal_msg = (
f"The name '{professor.name}' is too long and "
"can't be slugged automatcially. Please enter a slug below."
)

if modal_msg:
# Create the modal form to manualy enter a slug and add it
Expand Down