mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +00:00
Prevent troggle adding the menu if there is one in the file
Add a Docker compose file to bring up a dev troggle easily Various PEP improvments
This commit is contained in:
parent
f58b1db920
commit
a1f02e575f
@ -7,3 +7,4 @@ localsettings.py
|
|||||||
*~
|
*~
|
||||||
parsing_log.txt
|
parsing_log.txt
|
||||||
troggle
|
troggle
|
||||||
|
troggle_log.txt
|
||||||
|
@ -18,41 +18,50 @@ class TroggleModelAdmin(admin.ModelAdmin):
|
|||||||
class Media:
|
class Media:
|
||||||
js = ('jquery/jquery.min.js','js/QM_helper.js')
|
js = ('jquery/jquery.min.js','js/QM_helper.js')
|
||||||
|
|
||||||
|
|
||||||
class RoleInline(admin.TabularInline):
|
class RoleInline(admin.TabularInline):
|
||||||
model = SurvexPersonRole
|
model = SurvexPersonRole
|
||||||
extra = 4
|
extra = 4
|
||||||
|
|
||||||
|
|
||||||
class SurvexBlockAdmin(TroggleModelAdmin):
|
class SurvexBlockAdmin(TroggleModelAdmin):
|
||||||
inlines = (RoleInline,)
|
inlines = (RoleInline,)
|
||||||
|
|
||||||
|
|
||||||
class ScannedImageInline(admin.TabularInline):
|
class ScannedImageInline(admin.TabularInline):
|
||||||
model = ScannedImage
|
model = ScannedImage
|
||||||
extra = 4
|
extra = 4
|
||||||
|
|
||||||
|
|
||||||
class OtherCaveInline(admin.TabularInline):
|
class OtherCaveInline(admin.TabularInline):
|
||||||
model = OtherCaveName
|
model = OtherCaveName
|
||||||
extra = 1
|
extra = 1
|
||||||
|
|
||||||
|
|
||||||
class SurveyAdmin(TroggleModelAdmin):
|
class SurveyAdmin(TroggleModelAdmin):
|
||||||
inlines = (ScannedImageInline,)
|
inlines = (ScannedImageInline,)
|
||||||
search_fields = ('expedition__year','wallet_number')
|
search_fields = ('expedition__year','wallet_number')
|
||||||
|
|
||||||
|
|
||||||
class QMsFoundInline(admin.TabularInline):
|
class QMsFoundInline(admin.TabularInline):
|
||||||
model=QM
|
model=QM
|
||||||
fk_name='found_by'
|
fk_name='found_by'
|
||||||
fields=('number','grade','location_description','comment')#need to add foreignkey to cave part
|
fields=('number','grade','location_description','comment')#need to add foreignkey to cave part
|
||||||
extra=1
|
extra=1
|
||||||
|
|
||||||
|
|
||||||
class PhotoInline(admin.TabularInline):
|
class PhotoInline(admin.TabularInline):
|
||||||
model = DPhoto
|
model = DPhoto
|
||||||
exclude = ['is_mugshot' ]
|
exclude = ['is_mugshot' ]
|
||||||
extra = 1
|
extra = 1
|
||||||
|
|
||||||
|
|
||||||
class PersonTripInline(admin.TabularInline):
|
class PersonTripInline(admin.TabularInline):
|
||||||
model = PersonTrip
|
model = PersonTrip
|
||||||
raw_id_fields = ('personexpedition',)
|
raw_id_fields = ('personexpedition',)
|
||||||
extra = 1
|
extra = 1
|
||||||
|
|
||||||
|
|
||||||
#class LogbookEntryAdmin(VersionAdmin):
|
#class LogbookEntryAdmin(VersionAdmin):
|
||||||
class LogbookEntryAdmin(TroggleModelAdmin):
|
class LogbookEntryAdmin(TroggleModelAdmin):
|
||||||
prepopulated_fields = {'slug':("title",)}
|
prepopulated_fields = {'slug':("title",)}
|
||||||
@ -72,17 +81,18 @@ class LogbookEntryAdmin(TroggleModelAdmin):
|
|||||||
def export_logbook_entries_as_txt(modeladmin, request, queryset):
|
def export_logbook_entries_as_txt(modeladmin, request, queryset):
|
||||||
response=downloadLogbook(request=request, queryset=queryset, extension='txt')
|
response=downloadLogbook(request=request, queryset=queryset, extension='txt')
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PersonExpeditionInline(admin.TabularInline):
|
class PersonExpeditionInline(admin.TabularInline):
|
||||||
model = PersonExpedition
|
model = PersonExpedition
|
||||||
extra = 1
|
extra = 1
|
||||||
|
|
||||||
|
|
||||||
class PersonAdmin(TroggleModelAdmin):
|
class PersonAdmin(TroggleModelAdmin):
|
||||||
search_fields = ('first_name','last_name')
|
search_fields = ('first_name','last_name')
|
||||||
inlines = (PersonExpeditionInline,)
|
inlines = (PersonExpeditionInline,)
|
||||||
|
|
||||||
|
|
||||||
class QMAdmin(TroggleModelAdmin):
|
class QMAdmin(TroggleModelAdmin):
|
||||||
search_fields = ('found_by__cave__kataster_number','number','found_by__date')
|
search_fields = ('found_by__cave__kataster_number','number','found_by__date')
|
||||||
list_display = ('__unicode__','grade','found_by','ticked_off_by')
|
list_display = ('__unicode__','grade','found_by','ticked_off_by')
|
||||||
@ -91,17 +101,21 @@ class QMAdmin(TroggleModelAdmin):
|
|||||||
list_per_page = 20
|
list_per_page = 20
|
||||||
raw_id_fields=('found_by','ticked_off_by')
|
raw_id_fields=('found_by','ticked_off_by')
|
||||||
|
|
||||||
|
|
||||||
class PersonExpeditionAdmin(TroggleModelAdmin):
|
class PersonExpeditionAdmin(TroggleModelAdmin):
|
||||||
search_fields = ('person__first_name','expedition__year')
|
search_fields = ('person__first_name','expedition__year')
|
||||||
|
|
||||||
|
|
||||||
class CaveAdmin(TroggleModelAdmin):
|
class CaveAdmin(TroggleModelAdmin):
|
||||||
search_fields = ('official_name','kataster_number','unofficial_number')
|
search_fields = ('official_name','kataster_number','unofficial_number')
|
||||||
inlines = (OtherCaveInline,)
|
inlines = (OtherCaveInline,)
|
||||||
extra = 4
|
extra = 4
|
||||||
|
|
||||||
|
|
||||||
class EntranceAdmin(TroggleModelAdmin):
|
class EntranceAdmin(TroggleModelAdmin):
|
||||||
search_fields = ('caveandentrance__cave__kataster_number',)
|
search_fields = ('caveandentrance__cave__kataster_number',)
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(DPhoto)
|
admin.site.register(DPhoto)
|
||||||
admin.site.register(Cave, CaveAdmin)
|
admin.site.register(Cave, CaveAdmin)
|
||||||
admin.site.register(Area)
|
admin.site.register(Area)
|
||||||
@ -125,17 +139,20 @@ admin.site.register(SurvexStation)
|
|||||||
admin.site.register(SurvexScansFolder)
|
admin.site.register(SurvexScansFolder)
|
||||||
admin.site.register(SurvexScanSingle)
|
admin.site.register(SurvexScanSingle)
|
||||||
|
|
||||||
|
|
||||||
def export_as_json(modeladmin, request, queryset):
|
def export_as_json(modeladmin, request, queryset):
|
||||||
response = HttpResponse(mimetype="text/json")
|
response = HttpResponse(mimetype="text/json")
|
||||||
response['Content-Disposition'] = 'attachment; filename=troggle_output.json'
|
response['Content-Disposition'] = 'attachment; filename=troggle_output.json'
|
||||||
serializers.serialize("json", queryset, stream=response)
|
serializers.serialize("json", queryset, stream=response)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def export_as_xml(modeladmin, request, queryset):
|
def export_as_xml(modeladmin, request, queryset):
|
||||||
response = HttpResponse(mimetype="text/xml")
|
response = HttpResponse(mimetype="text/xml")
|
||||||
response['Content-Disposition'] = 'attachment; filename=troggle_output.xml'
|
response['Content-Disposition'] = 'attachment; filename=troggle_output.xml'
|
||||||
serializers.serialize("xml", queryset, stream=response)
|
serializers.serialize("xml", queryset, stream=response)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
#admin.site.add_action(export_as_xml)
|
#admin.site.add_action(export_as_xml)
|
||||||
#admin.site.add_action(export_as_json)
|
#admin.site.add_action(export_as_json)
|
||||||
|
@ -26,7 +26,7 @@ def listdir(*path):
|
|||||||
else:
|
else:
|
||||||
c = ""
|
c = ""
|
||||||
c = c.replace("#", "%23")
|
c = c.replace("#", "%23")
|
||||||
print "FILE: ", settings.FILES + "listdir/" + c
|
print("FILE: ", settings.FILES + "listdir/" + c)
|
||||||
return urllib.urlopen(settings.FILES + "listdir/" + c).read()
|
return urllib.urlopen(settings.FILES + "listdir/" + c).read()
|
||||||
|
|
||||||
def dirsAsList(*path):
|
def dirsAsList(*path):
|
||||||
|
@ -23,4 +23,6 @@ EXPOSE 8000
|
|||||||
|
|
||||||
WORKDIR /expo/troggle
|
WORKDIR /expo/troggle
|
||||||
|
|
||||||
#CMD ["python","manage.py","runserver","0.0.0.0:8000"]
|
#CMD ["python","manage.py","migrate"]
|
||||||
|
|
||||||
|
ENTRYPOINT ["python","manage.py","runserver","0.0.0.0:8000"]
|
||||||
|
21
docker/docker-compose.yml
Normal file
21
docker/docker-compose.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
troggle:
|
||||||
|
restart: always
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
volumes:
|
||||||
|
- ../..:/expo
|
||||||
|
links:
|
||||||
|
- expo-mysql
|
||||||
|
expo-mysql:
|
||||||
|
restart: always
|
||||||
|
image: "mariadb"
|
||||||
|
env_file:
|
||||||
|
- compose/mysql.env
|
||||||
|
volumes:
|
||||||
|
- mysqldb:/var/lib/mysql
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mysqldb:
|
@ -1,7 +0,0 @@
|
|||||||
Django==1.7.11
|
|
||||||
django-registration==2.1.2
|
|
||||||
mysql
|
|
||||||
imagekit
|
|
||||||
Image
|
|
||||||
django-tinymce==2.7.0
|
|
||||||
smartencoding
|
|
1
docker/requirements.txt
Symbolic link
1
docker/requirements.txt
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
requirements.txt.dj-1.7.11
|
@ -35,7 +35,7 @@ def flatpage(request, path):
|
|||||||
|
|
||||||
|
|
||||||
if path.startswith("noinfo") and settings.PUBLIC_SITE and not request.user.is_authenticated():
|
if path.startswith("noinfo") and settings.PUBLIC_SITE and not request.user.is_authenticated():
|
||||||
print "flat path noinfo", path
|
print("flat path noinfo", path)
|
||||||
return HttpResponseRedirect(reverse("auth_login") + '?next=%s' % request.path)
|
return HttpResponseRedirect(reverse("auth_login") + '?next=%s' % request.path)
|
||||||
|
|
||||||
if path.endswith("/") or path == "":
|
if path.endswith("/") or path == "":
|
||||||
@ -67,13 +67,15 @@ def flatpage(request, path):
|
|||||||
title, = m.groups()
|
title, = m.groups()
|
||||||
else:
|
else:
|
||||||
title = ""
|
title = ""
|
||||||
linksmatch = re.match('(.*)<ul id="links">', body, re.DOTALL + re.IGNORECASE)
|
has_menu = False
|
||||||
if linksmatch:
|
menumatch = re.match('(.*)<div id="menu">', body, re.DOTALL + re.IGNORECASE)
|
||||||
body, = linksmatch.groups()
|
if menumatch:
|
||||||
|
has_menu = True
|
||||||
|
#body, = menumatch.groups()
|
||||||
if re.search(r"iso-8859-1", html):
|
if re.search(r"iso-8859-1", html):
|
||||||
body = unicode(body, "iso-8859-1")
|
body = unicode(body, "iso-8859-1")
|
||||||
body.strip
|
body.strip
|
||||||
return render_with_context(request, 'flatpage.html', {'editable': True, 'path': path, 'title': title, 'body': body, 'homepage': (path == "index.htm")})
|
return render_with_context(request, 'flatpage.html', {'editable': True, 'path': path, 'title': title, 'body': body, 'homepage': (path == "index.htm"), 'has_menu': has_menu})
|
||||||
else:
|
else:
|
||||||
return HttpResponse(o.read(), content_type=getmimetype(path))
|
return HttpResponse(o.read(), content_type=getmimetype(path))
|
||||||
|
|
||||||
|
14
templates/core/expedition_list.html
Normal file
14
templates/core/expedition_list.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% load wiki_markup %}
|
||||||
|
{% load link %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Expeditions</h1>
|
||||||
|
<ul>
|
||||||
|
{% for expedition in object_list %}
|
||||||
|
<li>{{ expedition.year }} - <a href="{{ expedition.get_absolute_url }}">{{ expedition.name }}</a></li>
|
||||||
|
{% empty %}
|
||||||
|
<li>No articles yet.</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
@ -3,5 +3,13 @@
|
|||||||
{% block bodyattrs %}{% if homepage %} id="homepage"{% endif %}{% endblock %}
|
{% block bodyattrs %}{% if homepage %} id="homepage"{% endif %}{% endblock %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{{ body|safe }}
|
{{ body|safe }}
|
||||||
{% if homepage %}{% if editable %}<a href="{% url "editflatpage" path %}">Edit</a>{% endif %}{%else %}{% include "menu.html" %}{% endif %}
|
{% if homepage %}
|
||||||
|
{% if editable %}
|
||||||
|
<a href="{% url "editflatpage" path %}">Edit</a>
|
||||||
|
{% endif %}
|
||||||
|
{%else %}
|
||||||
|
{% if not has_menu %}
|
||||||
|
{% include "menu.html" %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
2
urls.py
2
urls.py
@ -30,7 +30,7 @@ actualurlpatterns = patterns('',
|
|||||||
#url(r'^person/(\w+_\w+)$', views_logbooks.person, name="person"),
|
#url(r'^person/(\w+_\w+)$', views_logbooks.person, name="person"),
|
||||||
|
|
||||||
url(r'^expedition/(\d+)$', views_logbooks.expedition, name="expedition"),
|
url(r'^expedition/(\d+)$', views_logbooks.expedition, name="expedition"),
|
||||||
url(r'^expeditions/?$', ListView, {'queryset':Expedition.objects.all(),'template_name':'object_list.html'},name="expeditions"),
|
url(r'^expeditions/?$', views_logbooks.ExpeditionListView.as_view(), name="expeditions"),
|
||||||
url(r'^personexpedition/(?P<first_name>[A-Z]*[a-z]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-z]*)/(?P<year>\d+)/?$', views_logbooks.personexpedition, name="personexpedition"),
|
url(r'^personexpedition/(?P<first_name>[A-Z]*[a-z]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-z]*)/(?P<year>\d+)/?$', views_logbooks.personexpedition, name="personexpedition"),
|
||||||
url(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', views_logbooks.logbookentry,name="logbookentry"),
|
url(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', views_logbooks.logbookentry,name="logbookentry"),
|
||||||
url(r'^newlogbookentry/(?P<expeditionyear>.*)$', views_logbooks.newLogbookEntry, name="newLogBookEntry"),
|
url(r'^newlogbookentry/(?P<expeditionyear>.*)$', views_logbooks.newLogbookEntry, name="newLogBookEntry"),
|
||||||
|
Loading…
Reference in New Issue
Block a user