diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-10-04 12:17:04 +0300 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-10-04 12:17:04 +0300 |
commit | ad2d25ed0059ae5cf94946f267703586ce413753 (patch) | |
tree | 8f8f1ea06bf530ef2195a51609bf8ce98fa10373 /core/views/logbooks.py | |
parent | f161ed3cf445768e88001e9d339e78318d16c137 (diff) | |
download | troggle-ad2d25ed0059ae5cf94946f267703586ce413753.tar.gz troggle-ad2d25ed0059ae5cf94946f267703586ce413753.tar.bz2 troggle-ad2d25ed0059ae5cf94946f267703586ce413753.zip |
remove first attempts are fixing this stuff
Diffstat (limited to 'core/views/logbooks.py')
-rw-r--r-- | core/views/logbooks.py | 47 |
1 files changed, 2 insertions, 45 deletions
diff --git a/core/views/logbooks.py b/core/views/logbooks.py index 70fd89a..308061c 100644 --- a/core/views/logbooks.py +++ b/core/views/logbooks.py @@ -155,54 +155,12 @@ class QMs_jsonListView(ListView): rx_person = re.compile(r"(?i)^(([A-Z]*[a-z\-\'&;]*)[^a-zA-Z]*)([a-z\-\']*[^a-zA-Z]*[\-]*[A-Z]*[a-zA-Z\-&;]*)$") rx_simple_person = re.compile(r"^([A-Z][a-z]*)[ ]*([A-Z][a-z]*)$") - -def better_person(request, name=""): - """Attempting to replace the name parser in urls.py with a more complex but - more understandable one in the body of the code. - Unfortuantely the get_absolute_url Django funny is making life very difficult. - This is in models/troggle.py PersonExpedition and Person - We need a defined slug for a person, however complicated their name, before we can progress further, if we - insist on using get_absolute_url(). - - Probably simpler and clearer to maintainers NOT to use ANY get_absolute_url() in the templates. - """ - names = rx_simple_person.match(name.strip(" /")) - if names: - first_name = names.group(1) - last_name = names.group(2) - else: - message = f"Name not recognised '{name}' - possibly French? (See our <a href=\"/handbook/troggle/namesredesign.html\">Proposal to fix this</a>)" - return render(request, "errors/generic.html", {"message": message}) - - try: - this_person = Person.objects.get(first_name=first_name, last_name=last_name) - except: - message = f"Person not found {name} => '{first_name} {last_name}' - possibly Scottish? (See our <a href=\"/handbook/troggle/namesredesign.html\">Proposal to fix this</a>)" - return render(request, "errors/generic.html", {"message": message}) - - return render(request, "person.html", {"person": this_person}) -def person( - request, - slug="" -): +def person(request, slug=""): """Original code as it has been for years. Trying to replace with better_person """ - this_person = Person.objects.get(slug=slug) return render(request, "person.html", {"person": this_person}) - - try: - this_person = Person.objects.get(first_name=first_name, last_name=last_name) - except: - message = f"Person not found '{first_name} {last_name}' - possibly Scottish? (See our <a href=\"/handbook/troggle/namesredesign.html\">Proposal to fix this</a>)" - peeps = Person.objects.filter(first_name=first_name, last_name=last_name) - if len(peeps) > 1: - message = f"Multiple people ({len(peeps)}) with this name '{first_name} {last_name}' - (See our <a href=\"/handbook/troggle/namesredesign.html\">Proposal to fix this</a>)" - return render(request, "errors/generic.html", {"message": message}) - - return render(request, "person.html", {"person": this_person}) - def get_person_chronology(personexpedition): """ @@ -243,8 +201,7 @@ def personexpedition(request, slug="", year=""): this_expedition = Expedition.objects.get(year=year) personexpedition = person.personexpedition_set.get(expedition=this_expedition) personchronology = get_person_chronology(personexpedition) - # for pc in personchronology: - # print(pc) + return render( request, "personexpedition.html", {"personexpedition": personexpedition, "personchronology": personchronology} ) |