2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

Delete SURVEYS.CSV code

This commit is contained in:
Philip Sargent 2020-05-31 21:03:40 +01:00
parent 09aedecc3b
commit 5d89cf9474
3 changed files with 17 additions and 106 deletions

View File

@ -73,12 +73,6 @@ def controlPanel(request):
return render(request,'controlPanel.html', {'caves':Cave.objects.all(),'expeditions':Expedition.objects.all(),'jobs_completed':jobs_completed}) return render(request,'controlPanel.html', {'caves':Cave.objects.all(),'expeditions':Expedition.objects.all(),'jobs_completed':jobs_completed})
def downloadSurveys(request):
from export import tosurveys
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename=Surveys.csv'
return response
def downloadLogbook(request,year=None,extension=None,queryset=None): def downloadLogbook(request,year=None,extension=None,queryset=None):
if year: if year:

View File

@ -31,59 +31,6 @@ def get_or_create_placeholder(year):
placeholder_logbook_entry, newly_created = save_carefully(LogbookEntry, lookupAttribs, nonLookupAttribs) placeholder_logbook_entry, newly_created = save_carefully(LogbookEntry, lookupAttribs, nonLookupAttribs)
return placeholder_logbook_entry return placeholder_logbook_entry
# obsolete surveys.csv does not exist.
# def readSurveysFromCSV():
# try: # could probably combine these two
# surveytab = open(os.path.join(settings.SURVEY_SCANS, "Surveys.csv"))
# except IOError:
# import io, urllib.request, urllib.parse, urllib.error
# surveytab = io.StringIO(urllib.request.urlopen(settings.SURVEY_SCANS + "/Surveys.csv").read())
# dialect=csv.Sniffer().sniff(surveytab.read())
# surveytab.seek(0,0)
# surveyreader = csv.reader(surveytab,dialect=dialect)
# headers = next(surveyreader)
# header = dict(list(zip(headers, list(range(len(headers)))))) #set up a dictionary where the indexes are header names and the values are column numbers
# # test if the expeditions have been added yet
# if Expedition.objects.count()==0:
# print("There are no expeditions in the database. Please run the logbook parser.")
# sys.exit()
# logging.info("Deleting all scanned images")
# ScannedImage.objects.all().delete()
# logging.info("Deleting all survey objects")
# Survey.objects.all().delete()
# logging.info("Beginning to import surveys from "+str(os.path.join(settings.SURVEYS, "Surveys.csv"))+"\n"+"-"*60+"\n")
# for survey in surveyreader:
# #I hate this, but some surveys have a letter eg 2000#34a. The next line deals with that.
# walletNumberLetter = re.match(r'(?P<number>\d*)(?P<letter>[a-zA-Z]*)',survey[header['Survey Number']])
# # print(walletNumberLetter.groups())
# year=survey[header['Year']]
# surveyobj = Survey(
# expedition = Expedition.objects.filter(year=year)[0],
# wallet_number = walletNumberLetter.group('number'),
# logbook_entry = get_or_create_placeholder(year),
# comments = survey[header['Comments']],
# location = survey[header['Location']]
# )
# surveyobj.wallet_letter = walletNumberLetter.group('letter')
# if survey[header['Finished']]=='Yes':
# #try and find the sketch_scan
# pass
# surveyobj.save()
# logging.info("added survey " + survey[header['Year']] + "#" + surveyobj.wallet_number + "\r")
# dead
def listdir(*directories): def listdir(*directories):
try: try:
return os.listdir(os.path.join(settings.SURVEYS, *directories)) return os.listdir(os.path.join(settings.SURVEYS, *directories))
@ -159,19 +106,6 @@ def listdir(*directories):
# yearPath=os.path.join(settings.SURVEY_SCANS, "surveyscans", expedition.year) # yearPath=os.path.join(settings.SURVEY_SCANS, "surveyscans", expedition.year)
# print((" ! No folder found for " + expedition.year + " at:- " + yearPath)) # print((" ! No folder found for " + expedition.year + " at:- " + yearPath))
# dead
# def parseSurveys(logfile=None):
# try:
# readSurveysFromCSV()
# except (IOError, OSError):
# print(" ! Survey CSV not found..")
# pass
# print(" - Loading scans by expedition year")
# for expedition in Expedition.objects.filter(year__gte=2000): #expos since 2000, because paths and filenames were nonstandard before then
# print("%s" % expedition, end=' ')
# parseSurveyScans(expedition)
# dead # dead
# def isInterlacedPNG(filePath): #We need to check for interlaced PNGs because the thumbnail engine can't handle them (uses PIL) # def isInterlacedPNG(filePath): #We need to check for interlaced PNGs because the thumbnail engine can't handle them (uses PIL)
# file=Image.open(filePath) # file=Image.open(filePath)

View File

@ -16,7 +16,7 @@
{% if error %} {% if error %}
<div class="noticeBox"> <div class="noticeBox">
{{ error }} {{ error }}
<a href="#" class="closeDiv">dismiss this message</a> <a href="#" class="closeDiv">dismiss this message</a>
</div> </div>
{% endif %} {% endif %}
@ -75,61 +75,44 @@
</th> </th>
<tr> <tr>
<td> <td>
surveys to Surveys.csv surveys to Surveys.csv
</td> </td>
<td> <td>
</td> </td>
<td> <td>
<form name="export" method="get" action={% url "downloadlogbook" %}> <form name="export" method="get" action={% url "downloadlogbook" %}>
<p>Download a logbook file which is dynamically generated by Troggle.</p> <p>Download a logbook file which is dynamically generated by Troggle.</p>
<p> <p>
Expedition year: Expedition year:
<select name="year"> <select name="year">
{% for expedition in expeditions %} {% for expedition in expeditions %}
<option value="{{expedition}}"> {{expedition}} </option> <option value="{{expedition}}"> {{expedition}} </option>
{% endfor %} {% endfor %}
</select> </select>
</p> </p>
<p> <p>
Output style: Output style:
<select name="extension"> <select name="extension">
<option value="txt">.txt file with MediaWiki markup - 2008 style</option> <option value="txt">.txt file with MediaWiki markup - 2008 style</option>
<option value="html">.html file - 2005 style</option> <option value="html">.html file - 2005 style</option>
</select> </select>
</p> </p>
<p> <p>
<input name="download_logbook" type="submit" value="Download logbook" /> <input name="download_logbook" type="submit" value="Download logbook" />
</p> </p>
</form> </form>
</td> </td>
</tr> </tr>
<tr>
<td>
surveys to Surveys.csv
</td>
<td>
<form name="export" method="post" action="">
<p>Overwrite the existing Surveys.csv file with one generated by Troggle.</p>
<input disabled name="export_surveys" type="submit" value="Update {{settings.SURVEYS}}noinfo/Surveys.csv" />
</form>
</td>
<td>
<form name="export" method="get" action={% url "downloadsurveys" %}>
<p>Download a Surveys.csv file which is dynamically generated by Troggle.</p>
<input disabled name="download_surveys" type="submit" value="Download Surveys.csv" />
</form>
</td>
</tr>
<tr> <tr>
<td>qms to qms.csv</td><td> <td>qms to qms.csv</td><td>
<form name="export_qms" method="get" action="downloadqms"> <form name="export_qms" method="get" action="downloadqms">
<!--This is for choosing caves by area (drilldown). <!--This is for choosing caves by area (drilldown).
<select id="qmcaveareachooser" class="searchable" > <select id="qmcaveareachooser" class="searchable" >
@ -137,12 +120,12 @@
--> -->
Choose a cave. Choose a cave.
<select name="cave_id" id="qmcavechooser"> <select name="cave_id" id="qmcavechooser">
{% for cave in caves %} {% for cave in caves %}
<option value="{{cave.kataster_number}}">{{cave}} <option value="{{cave.kataster_number}}">{{cave}}
</option> </option>
{% endfor %} {% endfor %}
</select> </select>
@ -153,4 +136,4 @@
</table> </table>
</form> </form>
{% endblock %} {% endblock %}