Add basic Buefy support for "Make User" button when viewing Person

this still relies on jQuery for now, but has Buefy styles at least...
This commit is contained in:
Lance Edgar 2019-05-22 10:34:03 -05:00
parent f4f435c682
commit eea3f671af
2 changed files with 10 additions and 1 deletions

View file

@ -6,10 +6,13 @@
${parent.extra_javascript()} ${parent.extra_javascript()}
% if not instance.users and request.has_perm('users.create'): % if not instance.users and request.has_perm('users.create'):
<script type="text/javascript"> <script type="text/javascript">
## TODO: should do this differently for Buefy themes
$(function() { $(function() {
$('#make-user').click(function() { $('#make-user').click(function() {
if (confirm("Really make a user account for this person?")) { if (confirm("Really make a user account for this person?")) {
% if not use_buefy:
disable_button(this); disable_button(this);
% endif
$('form[name="make-user-form"]').submit(); $('form[name="make-user-form"]').submit();
} }
}); });
@ -25,6 +28,7 @@
${parent.body()} ${parent.body()}
## TODO: should do this differently for Buefy themes
% if not instance.users and request.has_perm('users.create'): % if not instance.users and request.has_perm('users.create'):
${h.form(url('people.make_user'), name='make-user-form')} ${h.form(url('people.make_user'), name='make-user-form')}
${h.csrf_token(request)} ${h.csrf_token(request)}

View file

@ -203,6 +203,7 @@ class PeopleView(MasterView):
return HTML.tag('ul', c=items) return HTML.tag('ul', c=items)
def render_users(self, person, field): def render_users(self, person, field):
use_buefy = self.get_use_buefy()
users = person.users users = person.users
items = [] items = []
for user in users: for user in users:
@ -212,6 +213,10 @@ class PeopleView(MasterView):
if items: if items:
return HTML.tag('ul', c=items) return HTML.tag('ul', c=items)
elif self.request.has_perm('users.create'): elif self.request.has_perm('users.create'):
if use_buefy:
return HTML.tag('button', type='button', class_='button is-primary',
id='make-user', c="Make User")
else:
return HTML.tag('button', type='button', id='make-user', c="Make User") return HTML.tag('button', type='button', id='make-user', c="Make User")
else: else:
return "" return ""