From a1f02e575f6c379fd1a66cbfdefe8b9f29800297 Mon Sep 17 00:00:00 2001 From: Sam Wenham Date: Sat, 23 Feb 2019 15:30:58 +0000 Subject: [PATCH] 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 --- .hgignore | 1 + core/admin.py | 21 +++++++++++++++++++-- core/fileAbstraction.py | 2 +- docker/Dockerfile | 4 +++- docker/docker-compose.yml | 21 +++++++++++++++++++++ docker/requirements.txt | 8 +------- flatpages/views.py | 12 +++++++----- templates/core/expedition_list.html | 14 ++++++++++++++ templates/flatpage.html | 10 +++++++++- urls.py | 2 +- 10 files changed, 77 insertions(+), 18 deletions(-) create mode 100644 docker/docker-compose.yml mode change 100644 => 120000 docker/requirements.txt create mode 100644 templates/core/expedition_list.html diff --git a/.hgignore b/.hgignore index cb29426..77026d3 100644 --- a/.hgignore +++ b/.hgignore @@ -7,3 +7,4 @@ localsettings.py *~ parsing_log.txt troggle +troggle_log.txt diff --git a/core/admin.py b/core/admin.py index 305613c..a8ce55f 100644 --- a/core/admin.py +++ b/core/admin.py @@ -18,41 +18,50 @@ class TroggleModelAdmin(admin.ModelAdmin): class Media: js = ('jquery/jquery.min.js','js/QM_helper.js') + class RoleInline(admin.TabularInline): model = SurvexPersonRole extra = 4 + class SurvexBlockAdmin(TroggleModelAdmin): inlines = (RoleInline,) + class ScannedImageInline(admin.TabularInline): model = ScannedImage extra = 4 + class OtherCaveInline(admin.TabularInline): model = OtherCaveName extra = 1 + class SurveyAdmin(TroggleModelAdmin): inlines = (ScannedImageInline,) search_fields = ('expedition__year','wallet_number') + class QMsFoundInline(admin.TabularInline): model=QM fk_name='found_by' fields=('number','grade','location_description','comment')#need to add foreignkey to cave part extra=1 + class PhotoInline(admin.TabularInline): model = DPhoto exclude = ['is_mugshot' ] extra = 1 + class PersonTripInline(admin.TabularInline): model = PersonTrip raw_id_fields = ('personexpedition',) extra = 1 + #class LogbookEntryAdmin(VersionAdmin): class LogbookEntryAdmin(TroggleModelAdmin): prepopulated_fields = {'slug':("title",)} @@ -72,17 +81,18 @@ class LogbookEntryAdmin(TroggleModelAdmin): def export_logbook_entries_as_txt(modeladmin, request, queryset): response=downloadLogbook(request=request, queryset=queryset, extension='txt') return response - - + class PersonExpeditionInline(admin.TabularInline): model = PersonExpedition extra = 1 + class PersonAdmin(TroggleModelAdmin): search_fields = ('first_name','last_name') inlines = (PersonExpeditionInline,) + class QMAdmin(TroggleModelAdmin): search_fields = ('found_by__cave__kataster_number','number','found_by__date') list_display = ('__unicode__','grade','found_by','ticked_off_by') @@ -91,17 +101,21 @@ class QMAdmin(TroggleModelAdmin): list_per_page = 20 raw_id_fields=('found_by','ticked_off_by') + class PersonExpeditionAdmin(TroggleModelAdmin): search_fields = ('person__first_name','expedition__year') + class CaveAdmin(TroggleModelAdmin): search_fields = ('official_name','kataster_number','unofficial_number') inlines = (OtherCaveInline,) extra = 4 + class EntranceAdmin(TroggleModelAdmin): search_fields = ('caveandentrance__cave__kataster_number',) + admin.site.register(DPhoto) admin.site.register(Cave, CaveAdmin) admin.site.register(Area) @@ -125,17 +139,20 @@ admin.site.register(SurvexStation) admin.site.register(SurvexScansFolder) admin.site.register(SurvexScanSingle) + def export_as_json(modeladmin, request, queryset): response = HttpResponse(mimetype="text/json") response['Content-Disposition'] = 'attachment; filename=troggle_output.json' serializers.serialize("json", queryset, stream=response) return response + def export_as_xml(modeladmin, request, queryset): response = HttpResponse(mimetype="text/xml") response['Content-Disposition'] = 'attachment; filename=troggle_output.xml' serializers.serialize("xml", queryset, stream=response) return response + #admin.site.add_action(export_as_xml) #admin.site.add_action(export_as_json) diff --git a/core/fileAbstraction.py b/core/fileAbstraction.py index 94b8b0c..86191b7 100644 --- a/core/fileAbstraction.py +++ b/core/fileAbstraction.py @@ -26,7 +26,7 @@ def listdir(*path): else: c = "" c = c.replace("#", "%23") - print "FILE: ", settings.FILES + "listdir/" + c + print("FILE: ", settings.FILES + "listdir/" + c) return urllib.urlopen(settings.FILES + "listdir/" + c).read() def dirsAsList(*path): diff --git a/docker/Dockerfile b/docker/Dockerfile index c11a8b0..5f45b8e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -23,4 +23,6 @@ EXPOSE 8000 WORKDIR /expo/troggle -#CMD ["python","manage.py","runserver","0.0.0.0:8000"] \ No newline at end of file +#CMD ["python","manage.py","migrate"] + +ENTRYPOINT ["python","manage.py","runserver","0.0.0.0:8000"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..08b969e --- /dev/null +++ b/docker/docker-compose.yml @@ -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: \ No newline at end of file diff --git a/docker/requirements.txt b/docker/requirements.txt deleted file mode 100644 index 15ab393..0000000 --- a/docker/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -Django==1.7.11 -django-registration==2.1.2 -mysql -imagekit -Image -django-tinymce==2.7.0 -smartencoding diff --git a/docker/requirements.txt b/docker/requirements.txt new file mode 120000 index 0000000..d561bd8 --- /dev/null +++ b/docker/requirements.txt @@ -0,0 +1 @@ +requirements.txt.dj-1.7.11 \ No newline at end of file diff --git a/flatpages/views.py b/flatpages/views.py index 6503d40..672ec0c 100644 --- a/flatpages/views.py +++ b/flatpages/views.py @@ -35,7 +35,7 @@ def flatpage(request, path): 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) if path.endswith("/") or path == "": @@ -67,13 +67,15 @@ def flatpage(request, path): title, = m.groups() else: title = "" - linksmatch = re.match('(.*)