generated from brylie/django-bootstrap-quick-start
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from GeriLife/add-user-to-home-form
Add user to home form
- Loading branch information
Showing
9 changed files
with
544 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django import forms | ||
|
||
|
||
class AddCaregiverForm(forms.Form): | ||
email = forms.EmailField() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
{% extends "base.html" %} | ||
|
||
{% load i18n %} | ||
{% load crispy_forms_tags %} | ||
|
||
{% block content %} | ||
|
||
<div class="d-flex justify-content-between align-items-center"> | ||
<h1> | ||
<a | ||
href="{{ home.get_absolute_url }}" | ||
class="btn btn-outline-primary"> | ||
<i class="bi bi-house"></i> | ||
{{ home }} | ||
</a> | ||
|
||
{% translate "Manage Caregivers" %} | ||
</h1> | ||
|
||
<button class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#addCaregiverModal"> | ||
<i class="bi bi-person-plus"></i> | ||
{% translate "Add Caregiver" %} | ||
</button> | ||
</div> | ||
|
||
{% if home_user_relations %} | ||
<ul class="list-group"> | ||
{% for user_relation in home_user_relations %} | ||
<li class="list-group-item d-flex justify-content-between align-items-center"> | ||
<span> | ||
{{ user_relation.user.username }} | ||
</span> | ||
|
||
<div> | ||
{% if user_relation.user.is_superuser %} | ||
<span class="badge bg-primary rounded-pill"> | ||
{% translate "Superuser" %} | ||
</span> | ||
{% endif %} | ||
|
||
{% if user_relation.is_manager %} | ||
<span class="badge bg-primary rounded-pill"> | ||
{% translate "Manager" %} | ||
</span> | ||
{% endif %} | ||
</div> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% else %} | ||
<div class="alert alert-info"> | ||
{% translate "No caregivers found." %} | ||
</div> | ||
{% endif %} | ||
|
||
<div | ||
class="modal fade" | ||
id="addCaregiverModal" | ||
tabindex="-1" | ||
aria-labelledby="addCaregiverModalLabel" | ||
aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<form action="" method="post"> | ||
{% csrf_token %} | ||
<div class="modal-header"> | ||
<h2 class="modal-title" id="addCaregiverModalLabel"> | ||
{% translate "Add Caregiver" %} | ||
</h2> | ||
<button | ||
type="button" | ||
class="btn-close" | ||
data-bs-dismiss="modal" | ||
aria-label="{% translate 'Close' %}"> | ||
</button> | ||
</div> | ||
|
||
<div class="modal-body"> | ||
<p>{% translate "Enter the email of the caregiver you want to add." %}</p> | ||
|
||
{{ form|crispy }} | ||
</div> | ||
|
||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"> | ||
{% translate "Close" %} | ||
</button> | ||
<button type="submit" class="btn btn-primary"> | ||
{% translate "Add Caregiver" %} | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock content %} | ||
|
||
{% block extra_js %} | ||
<script> | ||
document.addEventListener('DOMContentLoaded', (event) => { | ||
{% if form.errors %} | ||
var myModal = new bootstrap.Modal(document.getElementById('addCaregiverModal')); | ||
myModal.show(); | ||
{% endif %} | ||
}); | ||
</script> | ||
{% endblock extra_js %} |
Oops, something went wrong.