forked from expo/troggle
compatible with Dj2.1.5
This commit is contained in:
parent
e3a341eb22
commit
bf74913486
@ -241,7 +241,7 @@ def rendercave(request, cave, slug, cave_id=''):
|
||||
'''
|
||||
#print(" ! rendercave:'{}' slug:'{}' cave_id:'{}'".format(cave, slug, cave_id))
|
||||
|
||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
|
||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated:
|
||||
return render(request, 'nonpublic.html', {'instance': cave, 'cavepage': True, 'cave_id': cave_id})
|
||||
else:
|
||||
svxstem = Path(cave.survex_file).parent / Path(cave.survex_file).stem
|
||||
@ -295,28 +295,28 @@ def cave(request, cave_id='', offical_name=''):
|
||||
|
||||
def caveEntrance(request, slug):
|
||||
cave = Cave.objects.get(caveslug__slug = slug)
|
||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
|
||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated:
|
||||
return render(request,'nonpublic.html', {'instance': cave})
|
||||
else:
|
||||
return render(request,'cave_entrances.html', {'cave': cave})
|
||||
|
||||
def caveDescription(request, slug):
|
||||
cave = Cave.objects.get(caveslug__slug = slug)
|
||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
|
||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated:
|
||||
return render(request,'nonpublic.html', {'instance': cave})
|
||||
else:
|
||||
return render(request,'cave_uground_description.html', {'cave': cave})
|
||||
|
||||
def caveQMs(request, slug):
|
||||
cave = Cave.objects.get(caveslug__slug = slug)
|
||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
|
||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated:
|
||||
return render(request,'nonpublic.html', {'instance': cave})
|
||||
else:
|
||||
return render(request,'cave_qms.html', {'cave': cave})
|
||||
|
||||
def caveLogbook(request, slug):
|
||||
cave = Cave.objects.get(caveslug__slug = slug)
|
||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
|
||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated:
|
||||
return render(request,'nonpublic.html', {'instance': cave})
|
||||
else:
|
||||
return render(request,'cave_logbook.html', {'cave': cave})
|
||||
@ -438,7 +438,7 @@ def ent(request, cave_id, ent_letter):
|
||||
|
||||
def entranceSlug(request, slug):
|
||||
entrance = Entrance.objects.get(entranceslug__slug = slug)
|
||||
if entrance.non_public and not request.user.is_authenticated():
|
||||
if entrance.non_public and not request.user.is_authenticated:
|
||||
return render(request,'nonpublic.html', {'instance': entrance})
|
||||
else:
|
||||
return render(request,'entranceslug.html', {'entrance': entrance})
|
||||
@ -597,7 +597,7 @@ def plot(surveypoint, number, point_type, label, mapcode, draw, img):
|
||||
def prospecting_image(request, name):
|
||||
# We should replace all this with something that exports an overlay for Google Maps and OpenStreetView
|
||||
mainImage = Image.open(os.path.join(settings.SURVEY_SCANS, "location_maps", "pguidemap.jpg"))
|
||||
if settings.PUBLIC_SITE and not request.user.is_authenticated():
|
||||
if settings.PUBLIC_SITE and not request.user.is_authenticated:
|
||||
mainImage = Image.new("RGB", mainImage.size, '#ffffff')
|
||||
m = maps[name]
|
||||
#imgmaps = []
|
||||
|
@ -140,7 +140,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():
|
||||
if path.startswith("noinfo") and settings.PUBLIC_SITE and not request.user.is_authenticated:
|
||||
return HttpResponseRedirect(urljoin(reverse("auth_login"),'?next={}'.format(request.path)))
|
||||
|
||||
if path.startswith("admin/"):
|
||||
|
@ -14,8 +14,6 @@ from troggle.core.models_caves import LogbookEntry, QM, Cave, PersonTrip
|
||||
from .login import login_required_if_public
|
||||
from troggle.core.forms import UploadFileForm
|
||||
|
||||
print("** importing troggle/core/views/other.py")
|
||||
|
||||
"""Utility functions and code to serve the control panel and individual user's
|
||||
progress and task list (deprecated as we do not have individual user login).
|
||||
|
||||
@ -31,15 +29,12 @@ def troggle404(request): # cannot get this to work. Handler404 in urls.py not ri
|
||||
#context['caves'] = Cave.objects.all()
|
||||
return render(request, ('404.html', context.flatten()))
|
||||
|
||||
def showrequest(request):
|
||||
return HttpResponse(request.GET)
|
||||
|
||||
def frontpage(request):
|
||||
'''never seen in common practice. Logon should redirect here when this is more useful'''
|
||||
# the messages system does a popup on this page if there is a recent message, e.g. from the admin site actions.
|
||||
# via django.contrib.messages.middleware.MessageMiddleware
|
||||
# this is set in the templates.
|
||||
if request.user.is_authenticated():
|
||||
if request.user.is_authenticated:
|
||||
return render(request,'tasks.html')
|
||||
|
||||
expeditions = Expedition.objects.order_by("-year")
|
||||
@ -52,7 +47,7 @@ def frontpage(request):
|
||||
def controlPanel(request):
|
||||
jobs_completed=[]
|
||||
if request.method=='POST':
|
||||
if request.user.is_superuser:
|
||||
if request.user.is_superuser: # expoadmin is both .is_staff and ._is_superuser
|
||||
# NONE of this works now that databaseReset (now parsers.imports) has been so extensively rewritten
|
||||
reinit_db()
|
||||
import_caves()
|
||||
@ -64,7 +59,7 @@ def controlPanel(request):
|
||||
import_survexblks()
|
||||
import_survexpos()
|
||||
else:
|
||||
if request.user.is_authenticated(): #The user is logged in, but is not a superuser.
|
||||
if request.user.is_authenticated: #The user is logged in, but is not a superuser.
|
||||
return render(request,'controlPanel.html', {'caves':Cave.objects.all(),'error':'You must be a superuser to use that feature.'})
|
||||
else:
|
||||
return HttpResponseRedirect(reverse('auth_login'))
|
||||
@ -193,5 +188,3 @@ def delFile(f):
|
||||
pt.delete()
|
||||
lbe.delete()
|
||||
os.remove(lbe.filename)
|
||||
|
||||
print("** Finished importing troggle/core/views/other.py")
|
@ -194,7 +194,7 @@ def svx(request, survex_file):
|
||||
message = "SAVE FILE FIRST"
|
||||
form.data['code'] = rcode
|
||||
if "save" in rform.data:
|
||||
if request.user.is_authenticated():
|
||||
if request.user.is_authenticated:
|
||||
message = form.SaveCode(rcode)
|
||||
else:
|
||||
message = "You do not have authority to save this file. Please log in."
|
||||
|
Loading…
Reference in New Issue
Block a user