From 03bc0973feacd2a87bcab7b34c3bd7a4cd902c13 Mon Sep 17 00:00:00 2001 From: Skia Date: Mon, 1 Feb 2016 17:35:55 +0100 Subject: [PATCH] WIP: Move to Jinja2 --- core/templates/core/{403.html => 403.jinja} | 2 +- core/templates/core/404.html | 2 +- core/templates/core/base.html | 53 ------------------- core/templates/core/base.jinja | 47 ++++++++++++++++ core/templates/core/edit_user.html | 2 +- core/templates/core/group_edit.html | 8 +-- core/templates/core/group_list.html | 4 +- core/templates/core/index.html | 7 --- core/templates/core/index.jinja | 7 +++ .../core/{login.html => login.jinja} | 12 ++--- core/templates/core/{page.html => page.jinja} | 6 +-- core/templates/core/page_detail.html | 26 --------- core/templates/core/page_detail.jinja | 25 +++++++++ core/templates/core/page_hist.html | 19 ------- core/templates/core/page_hist.jinja | 19 +++++++ .../core/{page_list.html => page_list.jinja} | 4 +- .../core/{page_prop.html => page_prop.jinja} | 4 +- .../{pagerev_edit.html => pagerev_edit.jinja} | 10 ++-- core/templates/core/password_change.html | 2 +- core/templates/core/password_change_done.html | 2 +- core/templates/core/password_reset.html | 2 +- .../core/password_reset_complete.html | 2 +- .../core/password_reset_confirm.html | 2 +- core/templates/core/password_reset_done.html | 2 +- core/templates/core/register.html | 2 +- core/templates/core/user_detail.html | 31 ----------- core/templates/core/user_detail.jinja | 31 +++++++++++ .../core/{user_edit.html => user_edit.jinja} | 4 +- .../core/{user_list.html => user_list.jinja} | 4 +- .../core/{user_prop.html => user_prop.jinja} | 6 +-- core/templates/core/user_tools.html | 20 ------- core/templates/core/user_tools.jinja | 20 +++++++ core/views/__init__.py | 4 +- core/views/page.py | 10 ++-- core/views/site.py | 4 +- core/views/user.py | 27 +++++----- requirements.txt | 1 + sith/settings.py | 45 ++++++++++++++++ 38 files changed, 261 insertions(+), 217 deletions(-) rename core/templates/core/{403.html => 403.jinja} (66%) delete mode 100644 core/templates/core/base.html create mode 100644 core/templates/core/base.jinja delete mode 100644 core/templates/core/index.html create mode 100644 core/templates/core/index.jinja rename core/templates/core/{login.html => login.jinja} (69%) rename core/templates/core/{page.html => page.jinja} (66%) delete mode 100644 core/templates/core/page_detail.html create mode 100644 core/templates/core/page_detail.jinja delete mode 100644 core/templates/core/page_hist.html create mode 100644 core/templates/core/page_hist.jinja rename core/templates/core/{page_list.html => page_list.jinja} (66%) rename core/templates/core/{page_prop.html => page_prop.jinja} (76%) rename core/templates/core/{pagerev_edit.html => pagerev_edit.jinja} (70%) delete mode 100644 core/templates/core/user_detail.html create mode 100644 core/templates/core/user_detail.jinja rename core/templates/core/{user_edit.html => user_edit.jinja} (77%) rename core/templates/core/{user_list.html => user_list.jinja} (53%) rename core/templates/core/{user_prop.html => user_prop.jinja} (57%) delete mode 100644 core/templates/core/user_tools.html create mode 100644 core/templates/core/user_tools.jinja diff --git a/core/templates/core/403.html b/core/templates/core/403.jinja similarity index 66% rename from core/templates/core/403.html rename to core/templates/core/403.jinja index 8e8c65a1..5e83a7b7 100644 --- a/core/templates/core/403.html +++ b/core/templates/core/403.jinja @@ -1,4 +1,4 @@ -{% extends "core/base.html" %} +{% extends "core/base.jinja" %} {% block content %} diff --git a/core/templates/core/404.html b/core/templates/core/404.html index 46d4abe2..35755bfd 100644 --- a/core/templates/core/404.html +++ b/core/templates/core/404.html @@ -1,4 +1,4 @@ -{% extends "core/base.html" %} +{% extends "core/base.jinja" %} {% block content %} diff --git a/core/templates/core/base.html b/core/templates/core/base.html deleted file mode 100644 index f6019f7d..00000000 --- a/core/templates/core/base.html +++ /dev/null @@ -1,53 +0,0 @@ -{% load staticfiles %} - - - - {% block head %} - {% block title %}Bienvenue sur le Sith de l'AE!{% endblock %} - - - - {% endblock %} - - - -
- {% block header %} - {% if user.is_authenticated %}Hello, {{ user.username }}!{% endif %} - - {% if user.is_authenticated %} - - {% endif %} - {% endblock %} -
- -
- {% if error %} - {{ error }} - {% endif %} - {% block content %}{% endblock %} -
- - - - - diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja new file mode 100644 index 00000000..d638caea --- /dev/null +++ b/core/templates/core/base.jinja @@ -0,0 +1,47 @@ + + + + {% block head %} + {% block title %}Bienvenue sur le Sith de l'AE!{% endblock %} + + + + {% endblock %} + + + +
+ {% block header %} + {% if user.is_authenticated() %}Hello, {{ user.username }}!{% endif %} + + {% if user.is_authenticated() %} + + {% endif %} + {% endblock %} +
+ +
+ {% if error %} + {{ error }} + {% endif %} + {% block content %}{% endblock %} +
+ + + + diff --git a/core/templates/core/edit_user.html b/core/templates/core/edit_user.html index 16845557..2e827339 100644 --- a/core/templates/core/edit_user.html +++ b/core/templates/core/edit_user.html @@ -1,4 +1,4 @@ -{% extends "core/base.html" %} +{% extends "core/base.jinja" %} {% block title %} {% if profile %} diff --git a/core/templates/core/group_edit.html b/core/templates/core/group_edit.html index 570bf419..1e730337 100644 --- a/core/templates/core/group_edit.html +++ b/core/templates/core/group_edit.html @@ -1,11 +1,11 @@ -{% extends "core/base.html" %} +{% extends "core/base.jinja" %} {% block content %} -

Back to list

+

Back to list

Edit group

- {% csrf_token %} - {{ form.as_p }} + {{ csrf_input }} + {{ form.as_p() }}

{% endblock %} diff --git a/core/templates/core/group_list.html b/core/templates/core/group_list.html index c0c9f67d..ff74aac9 100644 --- a/core/templates/core/group_list.html +++ b/core/templates/core/group_list.html @@ -1,4 +1,4 @@ -{% extends "core/base.html" %} +{% extends "core/base.jinja" %} {% block title %} Group list @@ -8,7 +8,7 @@ Group list

Group list

{% endblock %} diff --git a/core/templates/core/index.html b/core/templates/core/index.html deleted file mode 100644 index 639fc4a7..00000000 --- a/core/templates/core/index.html +++ /dev/null @@ -1,7 +0,0 @@ -{% extends "core/base.html" %} - -{% block title %}{{ title }}{% endblock %} - -{% block content %} -Hello, world. You're at the core index. -{% endblock %} diff --git a/core/templates/core/index.jinja b/core/templates/core/index.jinja new file mode 100644 index 00000000..aa25fa80 --- /dev/null +++ b/core/templates/core/index.jinja @@ -0,0 +1,7 @@ +{% extends "core/base.jinja" %} + +{% block title %}{{ title }}{% endblock %} + +{% block content %} +Hello, world. You're at the core index using Jinja2. +{% endblock %} diff --git a/core/templates/core/login.html b/core/templates/core/login.jinja similarity index 69% rename from core/templates/core/login.html rename to core/templates/core/login.jinja index 56c05f14..38407356 100644 --- a/core/templates/core/login.html +++ b/core/templates/core/login.jinja @@ -1,4 +1,4 @@ -{% extends "core/base.html" %} +{% extends "core/base.jinja" %} {% block content %} @@ -7,7 +7,7 @@ {% endif %} {% if next %} - {% if user.is_authenticated %} + {% if user.is_authenticated() %}

Your account doesn't have access to this page. To proceed, please login with an account that has access.

{% else %} @@ -15,15 +15,15 @@ {% endif %} {% endif %} -
+ {% csrf_token %} - + - +
{{ form.username.label_tag }}{{ form.username.label_tag() }} {{ form.username }}
{{ form.password.label_tag }}{{ form.password.label_tag() }} {{ form.password }}
@@ -33,6 +33,6 @@
{# Assumes you setup the password_reset view in your URLconf #} -

Lost password?

+

Lost password?

{% endblock %} diff --git a/core/templates/core/page.html b/core/templates/core/page.jinja similarity index 66% rename from core/templates/core/page.html rename to core/templates/core/page.jinja index dcb2932b..b421fdd8 100644 --- a/core/templates/core/page.html +++ b/core/templates/core/page.jinja @@ -1,8 +1,8 @@ -{% extends "core/base.html" %} +{% extends "core/base.jinja" %} {% block title %} {% if page %} - {{ page.get_display_name }} + {{ page.get_display_name() }} {% elif page_list %} Page list {% else %} @@ -16,6 +16,6 @@ {% endblock %} {% else %}

Page does not exist

-

Create it?

+

Create it?

{% endif %} {% endblock %} diff --git a/core/templates/core/page_detail.html b/core/templates/core/page_detail.html deleted file mode 100644 index 536fee92..00000000 --- a/core/templates/core/page_detail.html +++ /dev/null @@ -1,26 +0,0 @@ -{% extends "core/page.html" %} -{% load renderer %} - -{% block page %} -

Page

-

Back to list

- {% if can_edit %} -

Edit

- {% endif %} - {% if can_edit_prop %} -

Prop

- {% endif %} -

You're seeing the page {{ page.get_display_name }} - - History

- {% if rev %} -

This may not be the last update, you are seeing revision {{ rev.id }}!

-

{{ rev.title }}

-

{{ rev.content|markdown }}

- {% else %} -

{{ page.revisions.last.title }}

-

{{ page.revisions.last.content|markdown }}

- {% endif %} -{% endblock %} - - - diff --git a/core/templates/core/page_detail.jinja b/core/templates/core/page_detail.jinja new file mode 100644 index 00000000..6ca0e222 --- /dev/null +++ b/core/templates/core/page_detail.jinja @@ -0,0 +1,25 @@ +{% extends "core/page.jinja" %} + +{% block page %} +

Page

+

Back to list

+ {% if can_edit %} +

Edit

+ {% endif %} + {% if can_edit_prop %} +

Prop

+ {% endif %} +

You're seeing the page {{ page.get_display_name() }} - + History

+ {% if rev %} +

This may not be the last update, you are seeing revision {{ rev.id }}!

+

{{ rev.title }}

+

{{ rev.content|markdown }}

+ {% else %} +

{{ page.revisions.last().title }}

+

{{ page.revisions.last().content|markdown }}

+ {% endif %} +{% endblock %} + + + diff --git a/core/templates/core/page_hist.html b/core/templates/core/page_hist.html deleted file mode 100644 index 746d6115..00000000 --- a/core/templates/core/page_hist.html +++ /dev/null @@ -1,19 +0,0 @@ -{% extends "core/page.html" %} - -{% block page %} -

Page history

-

Back to page

-

You're seeing the history of page {{ page.get_display_name }}

- -{% endblock %} - - - - diff --git a/core/templates/core/page_hist.jinja b/core/templates/core/page_hist.jinja new file mode 100644 index 00000000..6401da6e --- /dev/null +++ b/core/templates/core/page_hist.jinja @@ -0,0 +1,19 @@ +{% extends "core/page.jinja" %} + +{% block page %} +

Page history

+

Back to page

+

You're seeing the history of page {{ page.get_display_name() }}

+ +{% endblock %} + + + + diff --git a/core/templates/core/page_list.html b/core/templates/core/page_list.jinja similarity index 66% rename from core/templates/core/page_list.html rename to core/templates/core/page_list.jinja index 9c9fdbaa..7862ffa0 100644 --- a/core/templates/core/page_list.html +++ b/core/templates/core/page_list.jinja @@ -1,4 +1,4 @@ -{% extends "core/base.html" %} +{% extends "core/base.jinja" %} {% block title %} Page list @@ -9,7 +9,7 @@

Page list

{% else %} diff --git a/core/templates/core/page_prop.html b/core/templates/core/page_prop.jinja similarity index 76% rename from core/templates/core/page_prop.html rename to core/templates/core/page_prop.jinja index 98436b94..302b1e67 100644 --- a/core/templates/core/page_prop.html +++ b/core/templates/core/page_prop.jinja @@ -1,10 +1,10 @@ -{% extends "core/page.html" %} +{% extends "core/page.jinja" %} {% block content %}

Page properties

{% csrf_token %} - {{ form.as_p }} + {{ form.as_p() }}

{% endblock %} diff --git a/core/templates/core/pagerev_edit.html b/core/templates/core/pagerev_edit.jinja similarity index 70% rename from core/templates/core/pagerev_edit.html rename to core/templates/core/pagerev_edit.jinja index 513898cd..6b7b88dc 100644 --- a/core/templates/core/pagerev_edit.html +++ b/core/templates/core/pagerev_edit.jinja @@ -1,11 +1,11 @@ -{% extends "core/page.html" %} +{% extends "core/page.jinja" %} {% block head %} -{{ block.super }} +{{ super() }}