diff options
Diffstat (limited to 'core/views')
-rw-r--r-- | core/views/caves.py | 20 | ||||
-rw-r--r-- | core/views/editor_helpers.py | 10 | ||||
-rw-r--r-- | core/views/expo.py | 4 | ||||
-rw-r--r-- | core/views/logbooks.py | 2 | ||||
-rw-r--r-- | core/views/statistics.py | 12 |
5 files changed, 24 insertions, 24 deletions
diff --git a/core/views/caves.py b/core/views/caves.py index fe85949..7706315 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -155,7 +155,7 @@ def file3d(request, cave, cave_id): #print(" - - Regeneration ABORT\n - - from '{}'".format(survexpath)) pass try: - completed_process = subprocess.run([settings.CAVERN, "--log", "--output={}".format(settings.SURVEX_DATA), "{}".format(survexpath)]) + completed_process = subprocess.run([settings.CAVERN, "--log", f"--output={settings.SURVEX_DATA}", f"{survexpath}"]) except OSError as ex: # propagate this to caller. raise OSError(completed_process.stdout) from ex @@ -164,7 +164,7 @@ def file3d(request, cave, cave_id): op3dlog = Path(op3d.with_suffix('.log')) if not op3d.is_file(): - print(" - - Regeneration FAILED\n - - from '{}'\n - - to '{}'".format(survexpath, op3d)) + print(f" - - Regeneration FAILED\n - - from '{survexpath}'\n - - to '{op3d}'") print(" - - Regeneration stdout: ", completed_process.stdout) print(" - - Regeneration cavern log output: ", op3dlog.read_text()) @@ -172,10 +172,10 @@ def file3d(request, cave, cave_id): def return3d(threedpath): if threedpath.is_file(): response = HttpResponse(content=open(threedpath, 'rb'), content_type='application/3d') - response['Content-Disposition'] = 'attachment; filename={}'.format(threedpath.name) + response['Content-Disposition'] = f'attachment; filename={threedpath.name}' return response else: - message = '<h1>Path provided does not correspond to any actual 3d file.</h1><p>path: "{}"'.format(threedpath) + message = f'<h1>Path provided does not correspond to any actual 3d file.</h1><p>path: "{threedpath}"' #print(message) return HttpResponseNotFound(message) @@ -205,10 +205,10 @@ def file3d(request, cave, cave_id): # Get here if cave.survex_file was set but did not correspond to a valid svx file if survexpath.is_file(): # a file, but invalid format - message='<h1>File is not valid .svx format.</h1><p>Could not generate 3d file from "{}"'.format(survexpath) + message=f'<h1>File is not valid .svx format.</h1><p>Could not generate 3d file from "{survexpath}"' else: # we could try to guess that 'caves-1623/' is missing,... nah. - message = '<h1>Path provided does not correspond to any actual file.</h1><p>path: "{}"'.format(survexpath) + message = f'<h1>Path provided does not correspond to any actual file.</h1><p>path: "{survexpath}"' return HttpResponseNotFound(message) @@ -325,9 +325,9 @@ def edit_cave(request, path = "", slug=None): if a.kat_area(): myArea = a.kat_area() if form.cleaned_data["kataster_number"]: - myslug = "%s-%s" % (myArea, form.cleaned_data["kataster_number"]) + myslug = f"{myArea}-{form.cleaned_data['kataster_number']}" else: - myslug = "%s-%s" % (myArea, form.cleaned_data["unofficial_number"]) + myslug = f"{myArea}-{form.cleaned_data['unofficial_number']}" else: myslug = slug # Converting a PENDING cave to a real cave by saving this form @@ -345,7 +345,7 @@ def edit_cave(request, path = "", slug=None): try: cave_file = cave.file_output() print(cave_file) - write_and_commit([cave_file], "Online edit of %s" % cave) + write_and_commit([cave_file], f"Online edit of {cave}") # leave other exceptions unhandled so that they bubble up to user interface except PermissionError: message = f'CANNOT save this file.\nPERMISSIONS incorrectly set on server for this file {cave.filename}. Ask a nerd to fix this.' @@ -414,7 +414,7 @@ def edit_entrance(request, path = "", caveslug=None, slug=None): es.save() entrance_file = entrance.file_output() cave_file = cave.file_output() - write_and_commit([entrance_file, cave_file], "Online edit of %s%s" % (cave, entletter)) + write_and_commit([entrance_file, cave_file], f"Online edit of {cave}{entletter}") entrance.save() if slug is None: entrance_letter.save() diff --git a/core/views/editor_helpers.py b/core/views/editor_helpers.py index 1988351..d7fd05f 100644 --- a/core/views/editor_helpers.py +++ b/core/views/editor_helpers.py @@ -39,13 +39,13 @@ def image_selector(request, path): base = f"{directory}/" else: base = "" - thumbnail_url = reverse('expopage', args=["%st/%s" % (base, f.name)]) + thumbnail_url = reverse('expopage', args=[f"{base}t/{f.name}"]) name_base = f.name.rsplit('.', 1)[0] page_path_base = Path(settings.EXPOWEB) / directory / "l" - if ((page_path_base / ("%s.htm" % name_base)).is_file()): - page_url = reverse('expopage', args=["%sl/%s.htm" % (base, name_base)]) + if ((page_path_base / (f"{name_base}.htm")).is_file()): + page_url = reverse('expopage', args=[f"{base}l/{name_base}.htm"]) else: - page_url = reverse('expopage', args=["%s/l/%s.html" % (base, name_base)]) + page_url = reverse('expopage', args=[f"{base}/l/{name_base}.html"]) thumbnails.append({"thumbnail_url": thumbnail_url, "page_url": page_url}) @@ -128,7 +128,7 @@ class NewWebImageForm(forms.Form): def clean_file_(self): for rel_path, full_path in zip(self.get_rel_paths(), self.get_full_paths()): if full_path.exists(): - raise forms.ValidationError("File already exists in %s" % rel_path) + raise forms.ValidationError(f"File already exists in {rel_path}") return self.cleaned_data['file_'] class HTMLarea(forms.Textarea): diff --git a/core/views/expo.py b/core/views/expo.py index 021415f..c443c38 100644 --- a/core/views/expo.py +++ b/core/views/expo.py @@ -219,7 +219,7 @@ def expopage(request, path): #print(" - EXPOPAGES delivering the file: '{}':{} as MIME type: {}".format(request.path, path,getmimetype(path)),flush=True) if path.startswith("noinfo") and settings.PUBLIC_SITE and not request.user.is_authenticated: - return HttpResponseRedirect(urljoin(reverse("auth_login"),'?next={}'.format(request.path))) + return HttpResponseRedirect(urljoin(reverse("auth_login"),f'?next={request.path}')) if path.startswith("admin/"): # don't even attempt to handle these sorts of mistakes @@ -354,7 +354,7 @@ def editexpopage(request, path): postbody = "</html>\n" body = pageform.cleaned_data["html"] body = body.replace("\r", "") - result = "%s<head%s>%s</head>%s<body%s>\n%s</body>%s" % (preheader, headerargs, head, postheader, bodyargs, body, postbody) + result = f"{preheader}<head{headerargs}>{head}</head>{postheader}<body{bodyargs}>\n{body}</body>{postbody}" if not filefound or result != html: # Check if content changed at all try: diff --git a/core/views/logbooks.py b/core/views/logbooks.py index 9c3d8c5..517a48b 100644 --- a/core/views/logbooks.py +++ b/core/views/logbooks.py @@ -238,4 +238,4 @@ def get_people(request, expeditionslug): def get_logbook_entries(request, expeditionslug): exp = Expedition.objects.get(year = expeditionslug) - return render(request,'options.html', {"items": [(le.slug, "%s - %s" % (le.date, le.title)) for le in exp.logbookentry_set.all()]}) + return render(request,'options.html', {"items": [(le.slug, f"{le.date} - {le.title}") for le in exp.logbookentry_set.all()]}) diff --git a/core/views/statistics.py b/core/views/statistics.py index c22d1a4..34fe66c 100644 --- a/core/views/statistics.py +++ b/core/views/statistics.py @@ -125,10 +125,10 @@ def pathsreport(request): def stats(request): statsDict={} - statsDict['expoCount'] = "{:,}".format(Expedition.objects.count()) - statsDict['caveCount'] = "{:,}".format(Cave.objects.count()) - statsDict['personCount'] = "{:,}".format(Person.objects.count()) - statsDict['logbookEntryCount'] = "{:,}".format(LogbookEntry.objects.count()) + statsDict['expoCount'] = f"{Expedition.objects.count():,}" + statsDict['caveCount'] = f"{Cave.objects.count():,}" + statsDict['personCount'] = f"{Person.objects.count():,}" + statsDict['logbookEntryCount'] = f"{LogbookEntry.objects.count():,}" legsbyexpo = [ ] addupsurvexlength = 0 @@ -142,8 +142,8 @@ def stats(request): legsyear += int(survexblock.legsall) addupsurvexlength += survexleglength addupsurvexlegs += legsyear - legsbyexpo.append((expedition, {"nsurvexlegs": "{:,}".format(legsyear), - "survexleglength":"{:,.0f}".format(survexleglength)})) + legsbyexpo.append((expedition, {"nsurvexlegs": f"{legsyear:,}", + "survexleglength":f"{survexleglength:,.0f}"})) legsbyexpo.reverse() renderDict = {**statsDict, **{ "addupsurvexlength":addupsurvexlength/1000, "legsbyexpo":legsbyexpo, "nsurvexlegs":addupsurvexlegs }} # new syntax |