2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-14 17:17:07 +00:00

Remove PHOTOS_ROOT and DPhoto class

This commit is contained in:
Philip Sargent
2020-05-15 21:32:55 +01:00
parent 931aa4e3cb
commit d4ac28af18
13 changed files with 83 additions and 69 deletions

View File

@@ -50,10 +50,10 @@ class QMsFoundInline(admin.TabularInline):
extra=1
class PhotoInline(admin.TabularInline):
model = DPhoto
exclude = ['is_mugshot' ]
extra = 1
# class PhotoInline(admin.TabularInline):
# model = DPhoto
# exclude = ['is_mugshot' ]
# extra = 1
class PersonTripInline(admin.TabularInline):
@@ -67,7 +67,8 @@ class LogbookEntryAdmin(TroggleModelAdmin):
prepopulated_fields = {'slug':("title",)}
search_fields = ('title','expedition__year')
date_heirarchy = ('date')
inlines = (PersonTripInline, PhotoInline, QMsFoundInline)
# inlines = (PersonTripInline, PhotoInline, QMsFoundInline)
inlines = (PersonTripInline, QMsFoundInline)
class Media:
css = {
"all": ("css/troggleadmin.css",)
@@ -116,7 +117,7 @@ class EntranceAdmin(TroggleModelAdmin):
search_fields = ('caveandentrance__cave__kataster_number',)
admin.site.register(DPhoto)
#admin.site.register(DPhoto)
admin.site.register(Cave, CaveAdmin)
admin.site.register(Area)
#admin.site.register(OtherCaveName)

View File

@@ -11,6 +11,9 @@ from django.core.urlresolvers import reverse
from troggle.core.models import Cave, Entrance
import troggle.flatpages.models
"""Pretty much all of this is now replaced by databaseRest.py
I don't know why this still exists
"""
databasename=settings.DATABASES['default']['NAME']
expouser=settings.EXPOUSER
expouserpass=settings.EXPOUSERPASS
@@ -89,9 +92,10 @@ class Command(BaseCommand):
def make_dirs(obj):
"""Make directories that troggle requires"""
pass
# should also deal with permissions here.
if not os.path.isdir(settings.PHOTOS_ROOT):
os.mkdir(settings.PHOTOS_ROOT)
#if not os.path.isdir(settings.PHOTOS_ROOT):
#os.mkdir(settings.PHOTOS_ROOT)
def import_caves(obj):
import parsers.caves

View File

@@ -780,31 +780,32 @@ class QM(TroggleModel):
def wiki_link(self):
return u"%s%s%s" % ('[[QM:',self.code(),']]')
photoFileStorage = FileSystemStorage(location=settings.PHOTOS_ROOT, base_url=settings.PHOTOS_URL)
class DPhoto(TroggleImageModel):
caption = models.CharField(max_length=1000,blank=True,null=True)
contains_logbookentry = models.ForeignKey(LogbookEntry,blank=True,null=True)
contains_person = models.ManyToManyField(Person,blank=True,null=True)
file = models.ImageField(storage=photoFileStorage, upload_to='.',)
is_mugshot = models.BooleanField(default=False)
contains_cave = models.ForeignKey(Cave,blank=True,null=True)
contains_entrance = models.ForeignKey(Entrance, related_name="photo_file",blank=True,null=True)
#photoFileStorage = FileSystemStorage(location=settings.PHOTOS_ROOT, base_url=settings.PHOTOS_URL)
#class DPhoto(TroggleImageModel):
#caption = models.CharField(max_length=1000,blank=True,null=True)
#contains_logbookentry = models.ForeignKey(LogbookEntry,blank=True,null=True)
#contains_person = models.ManyToManyField(Person,blank=True,null=True)
# replace link to copied file with link to original file location
#file = models.ImageField(storage=photoFileStorage, upload_to='.',)
#is_mugshot = models.BooleanField(default=False)
#contains_cave = models.ForeignKey(Cave,blank=True,null=True)
#contains_entrance = models.ForeignKey(Entrance, related_name="photo_file",blank=True,null=True)
#nearest_survey_point = models.ForeignKey(SurveyStation,blank=True,null=True)
nearest_QM = models.ForeignKey(QM,blank=True,null=True)
lon_utm = models.FloatField(blank=True,null=True)
lat_utm = models.FloatField(blank=True,null=True)
#nearest_QM = models.ForeignKey(QM,blank=True,null=True)
#lon_utm = models.FloatField(blank=True,null=True)
#lat_utm = models.FloatField(blank=True,null=True)
class IKOptions:
spec_module = 'core.imagekit_specs'
cache_dir = 'thumbs'
image_field = 'file'
# class IKOptions:
# spec_module = 'core.imagekit_specs'
# cache_dir = 'thumbs'
# image_field = 'file'
#content_type = models.ForeignKey(ContentType)
#object_id = models.PositiveIntegerField()
#location = generic.GenericForeignKey('content_type', 'object_id')
def __unicode__(self):
return self.caption
# def __unicode__(self):
# return self.caption
scansFileStorage = FileSystemStorage(location=settings.SURVEY_SCANS, base_url=settings.SURVEYS_URL)
def get_scan_path(instance, filename):

View File

@@ -197,6 +197,9 @@ class SurvexScansFolder(models.Model):
def get_absolute_url(self):
return urlparse.urljoin(settings.URL_ROOT, reverse('surveyscansfolder', kwargs={"path":re.sub("#", "%23", self.walletname)}))
def __unicode__(self):
return unicode(self.walletname) + " (Survey Scans Folder)"
class SurvexScanSingle(models.Model):
ffile = models.CharField(max_length=200)
@@ -208,6 +211,9 @@ class SurvexScanSingle(models.Model):
def get_absolute_url(self):
return urlparse.urljoin(settings.URL_ROOT, reverse('surveyscansingle', kwargs={"path":re.sub("#", "%23", self.survexscansfolder.walletname), "file":self.name}))
def __unicode__(self):
return "Survey Scan Image: " + unicode(self.name) + " in " + unicode(self.survexscansfolder)
class TunnelFile(models.Model):

View File

@@ -3,7 +3,7 @@ from django.utils.html import conditional_escape
from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe
from django.conf import settings
from troggle.core.models import QM, DPhoto, LogbookEntry, Cave
from troggle.core.models import QM, LogbookEntry, Cave
import re, urlparse
register = template.Library()
@@ -120,13 +120,13 @@ def wiki_to_html_short(value, autoescape=None):
except KeyError:
linkText=None
try:
photo=DPhoto.objects.get(file=matchdict['photoName'])
if not linkText:
linkText=str(photo)
res=r'<a href=' + photo.get_admin_url() +'>' + linkText + '</a>'
except Photo.DoesNotExist:
res = r'<a class="redtext" href="">make new photo</a>'
# try:
# photo=DPhoto.objects.get(file=matchdict['photoName'])
# if not linkText:
# linkText=str(photo)
# res=r'<a href=' + photo.get_admin_url() +'>' + linkText + '</a>'
# except Photo.DoesNotExist:
# res = r'<a class="redtext" href="">make new photo</a>'
return res
def photoSrcRepl(matchobj):

View File

@@ -184,7 +184,7 @@ def pathsreport(request):
"MEDIA_ADMIN_DIR" : MEDIA_ADMIN_DIR,
"MEDIA_ROOT" : MEDIA_ROOT,
"MEDIA_URL" : MEDIA_URL,
"PHOTOS_ROOT" : PHOTOS_ROOT,
#"PHOTOS_ROOT" : PHOTOS_ROOT,
"PHOTOS_URL" : PHOTOS_URL,
"PYTHON_PATH" : PYTHON_PATH,
"REPOS_ROOT_PATH" : REPOS_ROOT_PATH,

View File

@@ -1,5 +1,5 @@
from troggle.core.models import Cave, Expedition, Person, LogbookEntry, PersonExpedition, PersonTrip, DPhoto, QM
#from troggle.core.forms import UploadFileForm
from troggle.core.models import Cave, Expedition, Person, LogbookEntry, PersonExpedition, PersonTrip, QM
#from troggle.core.forms import UploadFileForm, DPhoto
from django.conf import settings
from django import forms
from django.template import loader, Context
@@ -30,7 +30,7 @@ def frontpage(request):
expeditions = Expedition.objects.order_by("-year")
logbookentry = LogbookEntry
cave = Cave
photo = DPhoto
#photo = DPhoto
from django.contrib.admin.templatetags import log
return render(request,'frontpage.html', locals())