From 51d803c23f12d4877547f4ca35a00f7d4e26d45f Mon Sep 17 00:00:00 2001 From: Rikuoja Date: Mon, 12 Sep 2016 13:15:36 +0300 Subject: [PATCH] Move the helsinki specific templates to helevents and sensiblificate template copying to prevent old templates overriding new ones --- README.md | 4 ++-- events/management/commands/install_templates.py | 8 ++++---- events/templates/rest_framework/README.md | 0 {templates => events/templates}/rest_framework/api.html | 0 .../templates}/rest_framework/description.html | 0 .../templates/rest_framework/api.html | 0 templates/rest_framework/README.md | 2 ++ 7 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 events/templates/rest_framework/README.md rename {templates => events/templates}/rest_framework/api.html (100%) rename {templates => events/templates}/rest_framework/description.html (100%) rename templates/rest_framework/api.html.helsinki => helevents/templates/rest_framework/api.html (100%) create mode 100644 templates/rest_framework/README.md diff --git a/README.md b/README.md index 321fa5c8a..90d8e8b48 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,9 @@ Finally, you may install city-specific HTML page templates for the browsable API ``` python manage.py install_templates helsinki ``` -This will install the templates/rest_framework/api.html.helsinki template, +This will install the `helevents/templates/rest_framework/api.html` template, which contains Helsinki event data summary and license. Customize the template -for your favorite city by creating api.html.your_favorite_city. +for your favorite city by creating `your_favorite_city/templates/rest_framework/api.html`. [Customizing the browsable API](http://www.django-rest-framework.org/topics/browsable-api/#customizing) Running tests diff --git a/events/management/commands/install_templates.py b/events/management/commands/install_templates.py index d0f43ec16..5bb69d657 100644 --- a/events/management/commands/install_templates.py +++ b/events/management/commands/install_templates.py @@ -6,9 +6,9 @@ class Command(BaseCommand): help = "Install a city specific HTML template" def add_arguments(self, parser): - parser.add_argument('city_name', nargs=1, type=str) + parser.add_argument('city_directory', nargs=1, type=str) def handle(self, *args, **options): - shutil.copyfile('templates/rest_framework/api.html.'+options['city_name'][0], - 'events/templates/rest_framework/api.html') - self.stdout.write(self.style.SUCCESS('Successfully installed the template for '+options['city_name'][0])) + shutil.copyfile(options['city_directory'][0]+'/templates/rest_framework/api.html', + 'templates/rest_framework/api.html') + self.stdout.write(self.style.SUCCESS('Successfully installed the template from '+options['city_directory'][0])) diff --git a/events/templates/rest_framework/README.md b/events/templates/rest_framework/README.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/templates/rest_framework/api.html b/events/templates/rest_framework/api.html similarity index 100% rename from templates/rest_framework/api.html rename to events/templates/rest_framework/api.html diff --git a/templates/rest_framework/description.html b/events/templates/rest_framework/description.html similarity index 100% rename from templates/rest_framework/description.html rename to events/templates/rest_framework/description.html diff --git a/templates/rest_framework/api.html.helsinki b/helevents/templates/rest_framework/api.html similarity index 100% rename from templates/rest_framework/api.html.helsinki rename to helevents/templates/rest_framework/api.html diff --git a/templates/rest_framework/README.md b/templates/rest_framework/README.md new file mode 100644 index 000000000..ecc4adf0d --- /dev/null +++ b/templates/rest_framework/README.md @@ -0,0 +1,2 @@ +Any templates in this directory will override the generic Linked Events page templates. You may install the Helsinki specific template from the helevents directory by +`python manage.py install_templates helevents`