diff options
author | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-13 05:31:21 +0100 |
---|---|---|
committer | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-13 05:31:21 +0100 |
commit | f02c91901c517680a31d383e55977f8fe1ab3918 (patch) | |
tree | 5831d71c03c7edc26c97dd572fa0885b89143d7f | |
parent | 67f24d76ae9f251407cf4ee0185b6c9b2655b9e8 (diff) | |
download | troggle-f02c91901c517680a31d383e55977f8fe1ab3918.tar.gz troggle-f02c91901c517680a31d383e55977f8fe1ab3918.tar.bz2 troggle-f02c91901c517680a31d383e55977f8fe1ab3918.zip |
[svn] More work on survey images parser and virtual survey binder. Renamed expedition_year field of Survey model to expedition because this makes more sense.
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8163 by aaron @ 1/16/2009 7:50 PM
-rw-r--r-- | expo/models.py | 18 | ||||
-rw-r--r-- | expo/views_caves.py | 22 | ||||
-rw-r--r-- | parsers/surveys.py | 15 | ||||
-rw-r--r-- | templates/survey.html | 120 | ||||
-rw-r--r-- | urls.py | 2 |
5 files changed, 146 insertions, 31 deletions
diff --git a/expo/models.py b/expo/models.py index e58489c..4bbf421 100644 --- a/expo/models.py +++ b/expo/models.py @@ -303,8 +303,8 @@ class Photo(models.Model): scansFileStorage = FileSystemStorage(location=settings.SURVEYS, base_url=settings.SURVEYS_URL)
def get_scan_path(instance, filename):
- year=instance.survey.expedition_year.year
- number="%02d" % instance.survey.wallet_number + instance.survey.wallet_letter #using %02d string formatting because convention was 2009#01
+ year=instance.survey.expedition.year
+ number="%02d" % instance.survey.wallet_number + str(instance.survey.wallet_letter) #using %02d string formatting because convention was 2009#01
return os.path.join('./',year,year+r'#'+number,instance.contents+str(instance.number_in_wallet)+r'.jpg')
class ScannedImage(models.Model):
@@ -328,7 +328,7 @@ class ScannedImage(models.Model): return get_scan_path(self,'')
class Survey(models.Model):
- expedition_year = models.ForeignKey('Expedition')
+ expedition = models.ForeignKey('Expedition')
wallet_number = models.IntegerField(blank=True,null=True)
wallet_letter = models.CharField(max_length=1,blank=True,null=True)
comments = models.TextField(blank=True,null=True)
@@ -344,5 +344,13 @@ class Survey(models.Model): integrated_into_main_sketch_by = models.ForeignKey('Person' ,related_name='integrated_into_main_sketch_by', blank=True,null=True)
rendered_image = models.ImageField(upload_to='renderedSurveys',blank=True,null=True)
def __str__(self):
- return self.expedition_year.year+"#"+"%02d" % self.wallet_number
-
\ No newline at end of file + return self.expedition.year+"#"+"%02d" % self.wallet_number
+
+ def notes(self):
+ return self.scannedimage_set.filter(contents='notes')
+
+ def plans(self):
+ return self.scannedimage_set.filter(contents='plan')
+
+ def elevations(self):
+ return self.scannedimage_set.filter(contents='elevation')
\ No newline at end of file diff --git a/expo/views_caves.py b/expo/views_caves.py index 8d0a4f4..045dbcf 100644 --- a/expo/views_caves.py +++ b/expo/views_caves.py @@ -1,5 +1,5 @@ from django.shortcuts import render_to_response
-from troggle.expo.models import Cave, CaveAndEntrance, Survey
+from troggle.expo.models import Cave, CaveAndEntrance, Survey, Expedition
import troggle.settings as settings
from troggle.expo.forms import CaveForm
import search
@@ -35,14 +35,22 @@ def caveSearch(request): def surveyindex(request):
surveys=Survey.objects.all()
- return render_to_response('survey.html',{'settings':settings,'surveys':surveys})
+ expeditions=Expedition.objects.all()
+ dictToPass=locals()
+ dictToPass.update({'settings':settings})
+ return render_to_response('survey.html',dictToPass)
-def survey(request,survey_id):
+def survey(request,year,wallet_number):
surveys=Survey.objects.all()
- current_survey=Survey.objects.get(pk=survey_id)
- notes=current_survey.scannedimage_set.filter(contents='notes')
- planSketches=current_survey.scannedimage_set.filter(contents='plan')
- elevationSketches=current_survey.scannedimage_set.filter(contents='elevation')
+ expeditions=Expedition.objects.all()
+ current_expedition=Expedition.objects.filter(year=year)[0]
+
+ if wallet_number!='':
+ current_survey=Survey.objects.filter(expedition=current_expedition,wallet_number=wallet_number)[0]
+ notes=current_survey.scannedimage_set.filter(contents='notes')
+ planSketches=current_survey.scannedimage_set.filter(contents='plan')
+ elevationSketches=current_survey.scannedimage_set.filter(contents='elevation')
+
dictToPass=locals()
dictToPass.update({'settings':settings})
diff --git a/parsers/surveys.py b/parsers/surveys.py index 22b1767..cd9781b 100644 --- a/parsers/surveys.py +++ b/parsers/surveys.py @@ -31,7 +31,7 @@ for survey in surveyreader: # print walletNumberLetter.groups()
surveyobj = models.Survey(
- expedition_year = models.Expedition.objects.filter(year=survey[header['Year']])[0],
+ expedition = models.Expedition.objects.filter(year=survey[header['Year']])[0],
wallet_number = walletNumberLetter.group('number'),
comments = survey[header['Comments']],
@@ -58,20 +58,23 @@ def parseSurveyScans(year): for scan in scanList:
try:
- scanChopped=re.match(r'([a-zA-Z]*)(\d*)\.(png|jpg|JPG|PNG)',scan).groups()
+ scanChopped=re.match(r'(?i).*(notes|elev|plan|elevation|extend)(\d*)\.(png|jpg|jpeg)',scan).groups()
scanType,scanNumber,scanFormat=scanChopped
except AttributeError:
- print scan + " ignored"
+ print "Adding scans: " + scan + " ignored"
continue
+ if scanType == 'elev' or scanType == 'extend':
+ scanType = 'elevation'
+
if scanNumber=='':
scanNumber=1
if type(surveyNumber)==types.TupleType:
surveyNumber=surveyNumber[0]
try:
- survey=models.Survey.objects.get_or_create(wallet_number=surveyNumber, expedition_year=year)[0]
+ survey=models.Survey.objects.get_or_create(wallet_number=surveyNumber, expedition=year)[0]
except models.Survey.MultipleObjectsReturned:
- survey=models.Survey.objects.filter(wallet_number=surveyNumber, expedition_year=year)[0]
+ survey=models.Survey.objects.filter(wallet_number=surveyNumber, expedition=year)[0]
scanObj = models.ScannedImage(
file=os.path.join(year.year, surveyFolder, scan),
@@ -79,7 +82,7 @@ def parseSurveyScans(year): number_in_wallet=scanNumber,
survey=survey
)
- print "Added scanned image at " + str(scanObj)
+ #print "Added scanned image at " + str(scanObj)
scanObj.save()
for year in models.Expedition.objects.filter(year__gte=2000): #expos since 2000, because paths and filenames were nonstandard before then
diff --git a/templates/survey.html b/templates/survey.html index e4998f3..b611d78 100644 --- a/templates/survey.html +++ b/templates/survey.html @@ -27,6 +27,14 @@ body { background: #DDDDDD;
padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */
}
+table {
+ border: thin solid silver;
+ border-collapse: collapse;
+}
+td {
+ padding:0px;
+ border: thin solid silver;
+}
.twoColHybLtHdr #header h1 {
margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */
padding: 10px 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */
@@ -117,7 +125,7 @@ img.thumbnail { /* the above proprietary zoom property gives IE the hasLayout it may need to avoid several bugs */
</style>
<![endif]-->
-</head>
+
<script language="javascript">
mnuItmLst=document.getElementsByClassName("menuBarItem")
function highlight(div){
@@ -148,11 +156,18 @@ img.thumbnail { div.style.backgroundColor="#666666";
}
- function redirect(surveyPK){
- window.location = "{{ settings.URL_ROOT }}/survey/" + surveyPK
+ function redirect(){
+ window.location = "{{ settings.URL_ROOT }}/survey/" + document.getElementById("expeditionChooser").value + "%23" + document.getElementById("surveyChooser").value;
+ document.getElementById("progressTableContent").style.display='hidden'
+ }
+
+ function redirectYear(){
+ window.location = "{{ settings.URL_ROOT }}/survey/" + document.getElementById("expeditionChooser").value + "%23"
}
+
</script>
+</head>
<body class="twoColHybLtHdr">
<div id="header">
<h1>CUCC Expo virtual survey binder</h1>
@@ -162,18 +177,31 @@ img.thumbnail { <h3>Survey Stages for {{ current_survey }}</h3>
<br />
- <select id="surveyChooser" onchange="redirect(this.value)">
- {% for survey in surveys %}
- <option label="{{ survey }}" value="{{ survey.pk }}"
- {% ifequal survey current_survey %}
+ <select id="expeditionChooser" onchange="redirectYear()">
+ {% for expedition in expeditions %}
+ <option label="{{ expedition }}" value="{{ expedition }}"
+ {% ifequal expedition current_expedition %}
selected
{% endifequal %} >
+ {{ expedition }}
+ </option>
+ {% endfor %}
+
+ </select>
+
+ <select id="surveyChooser" onchange="redirectSurvey()">
+ <option label="show all" value="">
+ {% for survey in current_expedition.survey_set.all %}
+ <option label="{{ survey }}" value="{{ survey.wallet_number }}"
+ {% ifequal survey current_survey %}
+ selected
+ {% endifequal %} >
{{ survey }}
</option>
{% endfor %}
-
+ <option label="add" value="add">
</select>
<div id="status">
@@ -192,8 +220,76 @@ img.thumbnail { <!-- end #sidebar1 -->
</div>
<div id="mainContent">
- <div id="notesContent" class="behind">
- <h2>Scanned notes for {{ current_survey }}.</h2>
+<div id="progressTableContent" class="behind" style="display:block;">
+ <h3>
+ Status of surveys from {{ current_expedition }}
+ </h3>
+ <table>
+ <tr>
+ <th>
+ </th>
+ {% for survey in current_expedition.survey_set.all %}
+ <th>
+ {{ survey.wallet_number }}
+ </th>
+ {% endfor %}
+ </tr>
+ <tr>
+ <td>
+ Notes
+ </td>
+ {% for survey in current_expedition.survey_set.all %}
+ <td>
+ {% if survey.notes %}
+ ✓
+ {% endif %}
+ </td>
+ {% endfor %}
+ </tr>
+ <tr>
+ <td>
+ Survex file
+ </td>
+ {% for survey in current_expedition.survey_set.all %}
+ <td>
+ {% if survey.survex_file %}
+ ✓
+ {% endif %}
+ </td>
+ {% endfor %}
+ </tr>
+ <tr>
+ <td>
+ Plans
+ </td>
+ {% for survey in current_expedition.survey_set.all %}
+ <td>
+ {% if survey.plans %}
+ ✓
+ {% endif %}
+ </td>
+ {% endfor %}
+ </tr>
+ <tr>
+ <td>
+ Elevations
+ </td>
+ {% for survey in current_expedition.survey_set.all %}
+ <td>
+ {% if survey.elevations %}
+ ✓
+ {% endif %}
+ </td>
+ {% endfor %}
+ </tr>
+ </table>
+
+
+
+ </div>
+
+<div id="notesContent" class="behind">
+ <h3>Scanned notes for {{ current_survey }}.</h3>
{% for noteItem in notes %}
<div class="figure">
@@ -222,12 +318,12 @@ img.thumbnail { who entered by </div>
<div id="printedCentrelineContent" class="behind"> centreline </div>
<div id="scannedPassageSketchContent" class="behind">
- <h2>Scanned plan sketch files for {{ current_survey }}.</h2>
+ <h3>Scanned plan sketch files for {{ current_survey }}.</h3>
{% for sketchItem in planSketches %}
<div class="figure">
<p>
- <img src="{{ sketchItem.correctURL }}" class="thumbnail">
+ <img src="{{ sketchItem.correctURL }}" class="thumbnail" />
<p>
File at:
<a href="{{ sketchItem.correctUrl }}">
@@ -28,7 +28,7 @@ urlpatterns = patterns('', (r'^statistics/?$', stats),
(r'^survey/?$', surveyindex),
- (r'^survey/(?P<survey_id>.*)$', survey),
+ (r'^survey/(?P<year>\d\d\d\d)\#(?P<wallet_number>\d*)$', survey),
(r'^admin/doc/?', include('django.contrib.admindocs.urls')),
(r'^admin/(.*)', admin.site.root),
|