mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +00:00
Started removing foreignkeys to caves, to achieve greater flexability. Some log book entries stuff may be broken. Add ability to make new caves and entrances via website.
This commit is contained in:
parent
6d5babd331
commit
ecd5bbcb1d
@ -55,8 +55,7 @@ class PersonTripInline(admin.TabularInline):
|
|||||||
|
|
||||||
#class LogbookEntryAdmin(VersionAdmin):
|
#class LogbookEntryAdmin(VersionAdmin):
|
||||||
class LogbookEntryAdmin(TroggleModelAdmin):
|
class LogbookEntryAdmin(TroggleModelAdmin):
|
||||||
prepopulated_fields = {'slug':("title",)}
|
prepopulated_fields = {'slug':("title",)}
|
||||||
raw_id_fields = ('cave',)
|
|
||||||
search_fields = ('title','expedition__year')
|
search_fields = ('title','expedition__year')
|
||||||
date_heirarchy = ('date')
|
date_heirarchy = ('date')
|
||||||
inlines = (PersonTripInline, PhotoInline, QMsFoundInline)
|
inlines = (PersonTripInline, PhotoInline, QMsFoundInline)
|
||||||
|
@ -16,8 +16,11 @@ class CaveForm(ModelForm):
|
|||||||
underground_centre_line = forms.CharField(required = False, widget=forms.Textarea())
|
underground_centre_line = forms.CharField(required = False, widget=forms.Textarea())
|
||||||
notes = forms.CharField(required = False, widget=forms.Textarea())
|
notes = forms.CharField(required = False, widget=forms.Textarea())
|
||||||
references = forms.CharField(required = False, widget=forms.Textarea())
|
references = forms.CharField(required = False, widget=forms.Textarea())
|
||||||
|
slug = forms.CharField(required = True)
|
||||||
|
url = forms.CharField(required = True)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Cave
|
model = Cave
|
||||||
|
exclude = ("filename",)
|
||||||
|
|
||||||
class VersionControlCommentForm(forms.Form):
|
class VersionControlCommentForm(forms.Form):
|
||||||
description_of_change = forms.CharField(required = True, widget=forms.Textarea())
|
description_of_change = forms.CharField(required = True, widget=forms.Textarea())
|
||||||
@ -32,15 +35,21 @@ class EntranceForm(ModelForm):
|
|||||||
#underground_centre_line = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
#underground_centre_line = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||||
#notes = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
#notes = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||||
#references = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
#references = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||||
|
other_station = forms.CharField(required=False) # Trying to change this to a singl;e line entry
|
||||||
|
tag_station = forms.CharField(required=False) # Trying to change this to a singl;e line entry
|
||||||
|
exact_station = forms.CharField(required=False) # Trying to change this to a singl;e line entry
|
||||||
|
northing = forms.CharField(required=False) # Trying to change this to a singl;e line entry
|
||||||
|
easting = forms.CharField(required=False) # Trying to change this to a singl;e line entry
|
||||||
|
alt = forms.CharField(required=False) # Trying to change this to a singl;e line entry
|
||||||
|
slug = forms.CharField()
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Entrance
|
model = Entrance
|
||||||
|
exclude = ("cached_primary_slug", "filename",)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CaveAndEntranceFormSet = modelformset_factory(CaveAndEntrance, exclude=('cave'))
|
CaveAndEntranceFormSet = modelformset_factory(CaveAndEntrance, exclude=('cave'))
|
||||||
|
|
||||||
class EntranceForm(ModelForm):
|
|
||||||
class Meta:
|
|
||||||
model = Entrance
|
|
||||||
|
|
||||||
#class PersonForm(ModelForm):
|
#class PersonForm(ModelForm):
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# model = Person
|
# model = Person
|
||||||
|
@ -23,7 +23,8 @@ def get_related_by_wikilinks(wiki_text):
|
|||||||
for wikilink in found:
|
for wikilink in found:
|
||||||
qmdict={'urlroot':settings.URL_ROOT,'cave':wikilink[2],'year':wikilink[1],'number':wikilink[3]}
|
qmdict={'urlroot':settings.URL_ROOT,'cave':wikilink[2],'year':wikilink[1],'number':wikilink[3]}
|
||||||
try:
|
try:
|
||||||
qm=QM.objects.get(found_by__cave__kataster_number = qmdict['cave'],
|
cave_slugs = CaveSlug.objects.filter(cave__kataster_number = qmdict['cave'])
|
||||||
|
qm=QM.objects.get(found_by__cave_slug__in = cave_slugs,
|
||||||
found_by__date__year = qmdict['year'],
|
found_by__date__year = qmdict['year'],
|
||||||
number = qmdict['number'])
|
number = qmdict['number'])
|
||||||
res.append(qm)
|
res.append(qm)
|
||||||
@ -240,17 +241,29 @@ class LogbookEntry(TroggleModel):
|
|||||||
#author = models.ForeignKey(PersonExpedition,blank=True,null=True) # the person who writes it up doesn't have to have been on the trip.
|
#author = models.ForeignKey(PersonExpedition,blank=True,null=True) # the person who writes it up doesn't have to have been on the trip.
|
||||||
# Re: the above- so this field should be "typist" or something, not "author". - AC 15 jun 09
|
# Re: the above- so this field should be "typist" or something, not "author". - AC 15 jun 09
|
||||||
#MJG wants to KILL THIS, as it is typically redundant with PersonTrip.is_logbook_entry_author, in the rare it was not redundanty and of actually interest it could be added to the text.
|
#MJG wants to KILL THIS, as it is typically redundant with PersonTrip.is_logbook_entry_author, in the rare it was not redundanty and of actually interest it could be added to the text.
|
||||||
title = models.CharField(max_length=settings.MAX_LOGBOOK_ENTRY_TITLE_LENGTH)
|
title = models.CharField(max_length=settings.MAX_LOGBOOK_ENTRY_TITLE_LENGTH)
|
||||||
cave = models.ForeignKey('Cave',blank=True,null=True)
|
cave_slug = models.SlugField(max_length=50)
|
||||||
place = models.CharField(max_length=100,blank=True,null=True,help_text="Only use this if you haven't chosen a cave")
|
place = models.CharField(max_length=100,blank=True,null=True,help_text="Only use this if you haven't chosen a cave")
|
||||||
text = models.TextField()
|
text = models.TextField()
|
||||||
slug = models.SlugField(max_length=50)
|
slug = models.SlugField(max_length=50)
|
||||||
filename= models.CharField(max_length=200,null=True)
|
filename = models.CharField(max_length=200,null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name_plural = "Logbook Entries"
|
verbose_name_plural = "Logbook Entries"
|
||||||
# several PersonTrips point in to this object
|
# several PersonTrips point in to this object
|
||||||
ordering = ('-date',)
|
ordering = ('-date',)
|
||||||
|
|
||||||
|
def __getattribute__(self, item):
|
||||||
|
if item == "cave": #Allow a logbookentries cave to be directly accessed despite not having a proper foreignkey
|
||||||
|
return CaveSlug.objects.get(slug = self.cave_slug).cave
|
||||||
|
return super(LogbookEntry, self).__getattribute__(item)
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
if "cave" in kwargs.keys():
|
||||||
|
if kwargs["cave"] is not None:
|
||||||
|
kwargs["cave_slug"] = CaveSlug.objects.get(cave = kwargs["cave"], primary = True).slug
|
||||||
|
kwargs.pop("cave")
|
||||||
|
return super(LogbookEntry, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def isLogbookEntry(self): # Function used in templates
|
def isLogbookEntry(self): # Function used in templates
|
||||||
return True
|
return True
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from troggle.core.models import Cave, CaveAndEntrance, Survey, Expedition, QM, CaveDescription, Entrance, Area
|
from troggle.core.models import CaveSlug, Cave, CaveAndEntrance, Survey, Expedition, QM, CaveDescription, EntranceSlug, Entrance, Area
|
||||||
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm
|
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm
|
||||||
import troggle.core.models as models
|
import troggle.core.models as models
|
||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
@ -94,13 +94,22 @@ def caveSlug(request, slug):
|
|||||||
|
|
||||||
@login_required_if_public
|
@login_required_if_public
|
||||||
def edit_cave(request, slug=None):
|
def edit_cave(request, slug=None):
|
||||||
cave = Cave.objects.get(caveslug__slug = slug)
|
if slug is not None:
|
||||||
|
cave = Cave.objects.get(caveslug__slug = slug)
|
||||||
|
else:
|
||||||
|
cave = Cave()
|
||||||
if request.POST:
|
if request.POST:
|
||||||
form = CaveForm(request.POST, instance=cave)
|
form = CaveForm(request.POST, instance=cave)
|
||||||
ceFormSet = CaveAndEntranceFormSet(request.POST)
|
ceFormSet = CaveAndEntranceFormSet(request.POST)
|
||||||
versionControlForm = VersionControlCommentForm(request.POST)
|
versionControlForm = VersionControlCommentForm(request.POST)
|
||||||
if form.is_valid() and ceFormSet.is_valid() and versionControlForm.is_valid():
|
if form.is_valid() and ceFormSet.is_valid() and versionControlForm.is_valid():
|
||||||
cave = form.save()
|
cave = form.save(commit = False)
|
||||||
|
cave.filename = form.cleaned_data["slug"] + ".html"
|
||||||
|
cave.save()
|
||||||
|
form.save_m2m()
|
||||||
|
if slug is None:
|
||||||
|
cs = CaveSlug(cave = cave, slug = form.cleaned_data["slug"], primary = True)
|
||||||
|
cs.save()
|
||||||
ceinsts = ceFormSet.save(commit=False)
|
ceinsts = ceFormSet.save(commit=False)
|
||||||
for ceinst in ceinsts:
|
for ceinst in ceinsts:
|
||||||
ceinst.cave = cave
|
ceinst.cave = cave
|
||||||
@ -121,12 +130,22 @@ def edit_cave(request, slug=None):
|
|||||||
|
|
||||||
@login_required_if_public
|
@login_required_if_public
|
||||||
def editEntrance(request, slug=None):
|
def editEntrance(request, slug=None):
|
||||||
entrance = Entrance.objects.get(entranceslug__slug = slug)
|
if slug is not None:
|
||||||
|
entrance = Entrance.objects.get(entranceslug__slug = slug)
|
||||||
|
else:
|
||||||
|
entrance = Entrance()
|
||||||
if request.POST:
|
if request.POST:
|
||||||
form = EntranceForm(request.POST, instance = entrance)
|
form = EntranceForm(request.POST, instance = entrance)
|
||||||
versionControlForm = VersionControlCommentForm(request.POST)
|
versionControlForm = VersionControlCommentForm(request.POST)
|
||||||
if form.is_valid() and versionControlForm.is_valid():
|
if form.is_valid() and versionControlForm.is_valid():
|
||||||
entrance = form.save()
|
entrance = form.save(commit = False)
|
||||||
|
entrance.filename = form.cleaned_data["slug"] + ".html"
|
||||||
|
if slug is None:
|
||||||
|
entrance.cached_primary_slug = form.cleaned_data["slug"]
|
||||||
|
entrance.save()
|
||||||
|
if slug is None:
|
||||||
|
es = EntranceSlug(entrance = entrance, slug = form.cleaned_data["slug"], primary = True)
|
||||||
|
es.save()
|
||||||
entrance.writeDataFile()
|
entrance.writeDataFile()
|
||||||
return HttpResponseRedirect("/" + entrance.url)
|
return HttpResponseRedirect("/" + entrance.url)
|
||||||
else:
|
else:
|
||||||
|
@ -181,6 +181,16 @@ if __name__ == "__main__":
|
|||||||
import_tunnelfiles()
|
import_tunnelfiles()
|
||||||
elif "reset" in sys.argv:
|
elif "reset" in sys.argv:
|
||||||
reset()
|
reset()
|
||||||
|
elif "resetend" in sys.argv:
|
||||||
|
#import_logbooks()
|
||||||
|
import_QMs()
|
||||||
|
try:
|
||||||
|
import_tunnelfiles()
|
||||||
|
except:
|
||||||
|
print "Tunnel files parser broken."
|
||||||
|
import_surveys()
|
||||||
|
import_descriptions()
|
||||||
|
parse_descriptions()
|
||||||
elif "survex" in sys.argv:
|
elif "survex" in sys.argv:
|
||||||
management.call_command('syncdb', interactive=False) # this sets the path so that import settings works in import_survex
|
management.call_command('syncdb', interactive=False) # this sets the path so that import settings works in import_survex
|
||||||
import_survex()
|
import_survex()
|
||||||
|
@ -128,7 +128,6 @@ def editflatpage(request, path):
|
|||||||
if request.method == 'POST': # If the form has been submitted...
|
if request.method == 'POST': # If the form has been submitted...
|
||||||
flatpageForm = FlatPageForm(request.POST) # A form bound to the POST data
|
flatpageForm = FlatPageForm(request.POST) # A form bound to the POST data
|
||||||
if flatpageForm.is_valid():# Form valid therefore write file
|
if flatpageForm.is_valid():# Form valid therefore write file
|
||||||
f = open(filepath, "w")
|
|
||||||
if filefound:
|
if filefound:
|
||||||
headmatch = re.match(r"(.*)<title>.*</title>(.*)", head, re.DOTALL + re.IGNORECASE)
|
headmatch = re.match(r"(.*)<title>.*</title>(.*)", head, re.DOTALL + re.IGNORECASE)
|
||||||
if headmatch:
|
if headmatch:
|
||||||
@ -144,7 +143,9 @@ def editflatpage(request, path):
|
|||||||
postbody = "</html>"
|
postbody = "</html>"
|
||||||
body = flatpageForm.cleaned_data["html"]
|
body = flatpageForm.cleaned_data["html"]
|
||||||
body = body.replace("\r", "")
|
body = body.replace("\r", "")
|
||||||
f.write("%s<head%s>%s</head>%s<body%s>\n%s</body>%s" % (preheader, headerargs, head, postheader, bodyargs, body, postbody))
|
result = u"%s<head%s>%s</head>%s<body%s>\n%s</body>%s" % (preheader, headerargs, head, postheader, bodyargs, body, postbody)
|
||||||
|
f = open(filepath, "w")
|
||||||
|
f.write(result)
|
||||||
f.close()
|
f.close()
|
||||||
return HttpResponseRedirect(reverse('flatpage', args=[path])) # Redirect after POST
|
return HttpResponseRedirect(reverse('flatpage', args=[path])) # Redirect after POST
|
||||||
else:
|
else:
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<div id="header">
|
<div id="header">
|
||||||
<h1>CUCC Expeditions to Austria: 1976 - 2012</h1>
|
<h1>CUCC Expeditions to Austria: 1976 - 2012</h1>
|
||||||
<div id="editLinks"> {% block loginInfo %}
|
<div id="editLinks"> {% block loginInfo %}
|
||||||
<a href="{{ settings.EXPOWEB_URL }}">Expoweb</a> |
|
<a href="{{settings.EXPOWEB_URL}}">Expoweb</a> |
|
||||||
{% if user.username %}
|
{% if user.username %}
|
||||||
You are logged in as {{ user.username }}
|
You are logged in as {{ user.username }}
|
||||||
{% if user.person %}(<a href="{{ user.person.get_absolute_url }}">{{ user.person }}</a>)
|
{% if user.person %}(<a href="{{ user.person.get_absolute_url }}">{{ user.person }}</a>)
|
||||||
|
@ -65,5 +65,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% endif %}</p>
|
{% endif %}</p>
|
||||||
|
<a href="{% url newentrance %}">New Entrance</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -34,4 +34,6 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<a href="{% url newcave %}">New Cave</a>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
3
urls.py
3
urls.py
@ -43,6 +43,8 @@ actualurlpatterns = patterns('',
|
|||||||
url(r'^getPeople/(?P<expeditionslug>.*)', views_logbooks.get_people, name = "get_people"),
|
url(r'^getPeople/(?P<expeditionslug>.*)', views_logbooks.get_people, name = "get_people"),
|
||||||
url(r'^getLogBookEntries/(?P<expeditionslug>.*)', views_logbooks.get_logbook_entries, name = "get_logbook_entries"),
|
url(r'^getLogBookEntries/(?P<expeditionslug>.*)', views_logbooks.get_logbook_entries, name = "get_logbook_entries"),
|
||||||
|
|
||||||
|
|
||||||
|
url(r'^cave/new/$', edit_cave, name="newcave"),
|
||||||
url(r'^cave/(?P<cave_id>[^/]+)/?$', views_caves.cave, name="cave"),
|
url(r'^cave/(?P<cave_id>[^/]+)/?$', views_caves.cave, name="cave"),
|
||||||
url(r'^caveslug/([^/]+)/?$', views_caves.caveSlug, name="caveSlug"),
|
url(r'^caveslug/([^/]+)/?$', views_caves.caveSlug, name="caveSlug"),
|
||||||
url(r'^cave/entrance/([^/]+)/?$', views_caves.caveEntrance),
|
url(r'^cave/entrance/([^/]+)/?$', views_caves.caveEntrance),
|
||||||
@ -50,6 +52,7 @@ actualurlpatterns = patterns('',
|
|||||||
url(r'^cave/qms/([^/]+)/?$', views_caves.caveQMs),
|
url(r'^cave/qms/([^/]+)/?$', views_caves.caveQMs),
|
||||||
url(r'^cave/logbook/([^/]+)/?$', views_caves.caveLogbook),
|
url(r'^cave/logbook/([^/]+)/?$', views_caves.caveLogbook),
|
||||||
url(r'^entrance/(?P<slug>[^/]+)/edit/', views_caves.editEntrance, name = "editentrance"),
|
url(r'^entrance/(?P<slug>[^/]+)/edit/', views_caves.editEntrance, name = "editentrance"),
|
||||||
|
url(r'^entrance/new/', views_caves.editEntrance, name = "newentrance"),
|
||||||
#url(r'^cavedescription/(?P<cavedescription_name>[^/]+)/?$', views_caves.cave_description, name="cavedescription"),
|
#url(r'^cavedescription/(?P<cavedescription_name>[^/]+)/?$', views_caves.cave_description, name="cavedescription"),
|
||||||
#url(r'^cavedescription/?$', object_list, {'queryset':CaveDescription.objects.all(),'template_name':'object_list.html'}, name="cavedescriptions"),
|
#url(r'^cavedescription/?$', object_list, {'queryset':CaveDescription.objects.all(),'template_name':'object_list.html'}, name="cavedescriptions"),
|
||||||
#url(r'^cavehref/(.+)$', views_caves.cave, name="cave"),url(r'cave'),
|
#url(r'^cavehref/(.+)$', views_caves.cave, name="cave"),url(r'cave'),
|
||||||
|
Loading…
Reference in New Issue
Block a user