From 7158a79a347d99fb1f8e94e034f2d79e08ad9172 Mon Sep 17 00:00:00 2001 From: goatchurch Date: Mon, 27 Jul 2009 13:43:43 +0100 Subject: [svn] full checkin. animations disabled, sorry --- core/models_survex.py | 60 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 13 deletions(-) (limited to 'core/models_survex.py') diff --git a/core/models_survex.py b/core/models_survex.py index 7c8d27e..ba43d93 100644 --- a/core/models_survex.py +++ b/core/models_survex.py @@ -2,6 +2,20 @@ from django.db import models from django.conf import settings import os + +########################################################### +# These will allow browsing and editing of the survex data +########################################################### + + +# Needs to add: +# SurvexFile +# Equates +# reloading + +# +# Single SurvexBlock +# class SurvexBlock(models.Model): name = models.CharField(max_length=100, blank=True, null=True) parent = models.ForeignKey('SurvexBlock', blank=True, null=True) @@ -31,10 +45,10 @@ class SurvexBlock(models.Model): ordering = ('date', 'survexpath') def __unicode__(self): - if self.name: - return unicode(self.name) - else: - return 'no name' + return self.name and unicode(self.name) or 'no name' + + def filewithoutsvx(self): + return self.begin_file[:-4] def filecontents(self): f = os.path.join(settings.SURVEX_DATA, self.begin_file) @@ -50,20 +64,40 @@ class SurvexBlock(models.Model): res[-1]['roles'] += ", " + str(personrole.role) else: res.append({'person':personrole.personexpedition.person, 'expeditionyear':personrole.personexpedition.expedition.year, 'roles':str(personrole.role)}) - print res return res -class PersonRole(models.Model): - personexpedition = models.ForeignKey('PersonExpedition') - person = models.ForeignKey('Person') - survex_block = models.ForeignKey('SurvexBlock') - role = models.ForeignKey('Role') - def __unicode__(self): - return unicode(self.person) + " - " + unicode(self.survex_block) + " - " + unicode(self.role) - +# +# Replace this with a choice string in PersonRole +# class Role(models.Model): name = models.CharField(max_length=50) def __unicode__(self): return unicode(self.name) + + +# +# member of a SurvexBlock +# +class PersonRole(models.Model): + survex_block = models.ForeignKey('SurvexBlock') + role = models.ForeignKey('Role') # to go + + ROLE_CHOICES = ( + ('insts','Instruments'), + ('dog','Other'), + ('notes','Notes'), + ('pics','Pictures'), + ('tape','Tape measure'), + ) + nrole = models.CharField(choices=ROLE_CHOICES, max_length=200, blank=True, null=True) + + # increasing levels of precision + person = models.ForeignKey('Person') + personexpedition = models.ForeignKey('PersonExpedition') + persontrip = models.ForeignKey('PersonTrip', blank=True, null=True) + + def __unicode__(self): + return unicode(self.person) + " - " + unicode(self.survex_block) + " - " + unicode(self.role) + -- cgit v1.2.3