From 8ba4cc5c0cbfa358717f1d640ad81f04242ca62d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 29 Nov 2017 13:58:47 +0100 Subject: [PATCH] Allow extension of users/edit_embed.pug This is done by moving users/edit_embed.pug to users/edit_embed_base.pug, and having a new users/edit_embed.pug extend that. Projects like Blender Cloud can then provide their own users/edit_embed.pug and override certain blocks. --- src/templates/users/edit_embed.pug | 116 +----------------------- src/templates/users/edit_embed_base.pug | 110 ++++++++++++++++++++++ 2 files changed, 111 insertions(+), 115 deletions(-) create mode 100644 src/templates/users/edit_embed_base.pug diff --git a/src/templates/users/edit_embed.pug b/src/templates/users/edit_embed.pug index 0c76e544..52b38881 100644 --- a/src/templates/users/edit_embed.pug +++ b/src/templates/users/edit_embed.pug @@ -1,115 +1 @@ -| {% block body %} - -#user-edit-container - - #user-edit-header - .user-edit-name(title="Full Name") {{user.full_name}} - .user-edit-username(title="Username") - i.pi-users - | {{user.username}} - .user-edit-email(title="E-mail") - i.pi-email - | {{user.email}} - .user-edit-id(title="User ID") - i.pi-vcard - | {{user.user_id}}   - - a.copy-to-clipboard( - style="margin-left: auto", - name="Copy to Clipboard", - type="button", - href="javascript:void(0)", - data-clipboard-text="{{ user.user_id }}", - title="Copy ID to clipboard") - | (copy to clipboard) - p This user on: - =' ' - a(href="https://store.blender.org/wp-admin/users.php?s={{ user.email | urlencode }}") Blender Store - =' | ' - a(href="https://www.blender.org/id/admin/users/?flt1_4={{ user.email | urlencode }}") Blender ID - - form( - id="user-edit-form", - method="POST", - enctype="multipart/form-data", - action="{{url_for('users.users_edit', user_id=user.user_id)}}") - - | {% for field in form %} - - | {% if field.name == 'csrf_token' %} - | {{ field }} - - | {% else %} - - | {% if field.type == 'HiddenField' %} - | {{ field }} - - | {% else %} - - .form-group(class="{{field.name}}{% if field.errors %} error{% endif %}") - | {{ field.label }} - | {{ field(class='form-control') }} - - | {% if field.errors %} - ul.error - | {% for error in field.errors %} - li {{ error }} - | {% endfor %} - | {% endif %} - span.field-description {{ field.description }} - - | {% endif %} - - | {% endif %} - - | {% endfor %} - - .form-group.capabilities - label Capabilities - | {% if user.capabilities %} - ul - | {% for cap in user.capabilities|sort %} - li {{ cap }} - | {% endfor %} - | {% else %} - p - i.pi-cancel - | none - | {% endif %} - - a#button-cancel.btn.btn-default(href="#", data-user-id='{{user.user_id}}') Cancel - - input#submit_edit_user.btn.btn-default( - data-user-id="{{user.user_id}}", - type="submit" value="Submit") - - #user-edit-notification - -script(src="{{ url_for('static_pillar', filename='assets/js/vendor/clipboard.min.js')}}") -script(type="text/javascript"). - $('#roles').select2(); - - $('#user-edit-form').submit(function(e){ - e.preventDefault(); - //- console.log($(this).serialize()); - $.post($(this).attr('action'), $(this).serialize()) - .done(function(data){ - // This function is defined in index.pug. - displayUser('{{ user.user_id }}') - .done(function() { - $('#user-edit-notification').addClass('success').html('Success!'); - }); - }) - .fail(function(data){ - $('#user-edit-notification').addClass('fail').html('Houston!'); - }); - //- $("#user-edit-form").submit(); - }); - - $('#button-cancel').click(function(e){ - $('#user-container').html('') - }); - - new Clipboard('.copy-to-clipboard'); - -| {% endblock %} +| {% extends "users/edit_embed_base.html" %} diff --git a/src/templates/users/edit_embed_base.pug b/src/templates/users/edit_embed_base.pug new file mode 100644 index 00000000..db6344c0 --- /dev/null +++ b/src/templates/users/edit_embed_base.pug @@ -0,0 +1,110 @@ +| {% block body %} + +#user-edit-container + + #user-edit-header + .user-edit-name(title="Full Name") {{user.full_name}} + .user-edit-username(title="Username") + i.pi-users + | {{user.username}} + .user-edit-email(title="E-mail") + i.pi-email + | {{user.email}} + .user-edit-id(title="User ID") + i.pi-vcard + | {{user.user_id}}   + + a.copy-to-clipboard( + style="margin-left: auto", + name="Copy to Clipboard", + type="button", + href="javascript:void(0)", + data-clipboard-text="{{ user.user_id }}", + title="Copy ID to clipboard") + | (copy to clipboard) + | {% block user_links %}{% endblock %} + form( + id="user-edit-form", + method="POST", + enctype="multipart/form-data", + action="{{url_for('users.users_edit', user_id=user.user_id)}}") + + | {% for field in form %} + + | {% if field.name == 'csrf_token' %} + | {{ field }} + + | {% else %} + + | {% if field.type == 'HiddenField' %} + | {{ field }} + + | {% else %} + + .form-group(class="{{field.name}}{% if field.errors %} error{% endif %}") + | {{ field.label }} + | {{ field(class='form-control') }} + + | {% if field.errors %} + ul.error + | {% for error in field.errors %} + li {{ error }} + | {% endfor %} + | {% endif %} + span.field-description {{ field.description }} + + | {% endif %} + + | {% endif %} + + | {% endfor %} + + .form-group.capabilities + label Capabilities + | {% if user.capabilities %} + ul + | {% for cap in user.capabilities|sort %} + li {{ cap }} + | {% endfor %} + | {% else %} + p + i.pi-cancel + | none + | {% endif %} + + a#button-cancel.btn.btn-default(href="#", data-user-id='{{user.user_id}}') Cancel + + input#submit_edit_user.btn.btn-default( + data-user-id="{{user.user_id}}", + type="submit" value="Submit") + + #user-edit-notification + +script(src="{{ url_for('static_pillar', filename='assets/js/vendor/clipboard.min.js')}}") +script(type="text/javascript"). + $('#roles').select2(); + + $('#user-edit-form').submit(function(e){ + e.preventDefault(); + //- console.log($(this).serialize()); + $.post($(this).attr('action'), $(this).serialize()) + .done(function(data){ + // This function is defined in index.pug. + displayUser('{{ user.user_id }}') + .done(function() { + $('#user-edit-notification').addClass('success').html('Success!'); + }); + }) + .fail(function(data){ + $('#user-edit-notification').addClass('fail').html('Houston!'); + }); + //- $("#user-edit-form").submit(); + }); + + $('#button-cancel').click(function(e){ + $('#user-container').html('') + }); + + new Clipboard('.copy-to-clipboard'); + +| {% endblock %}