-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add user model, views and templates - Add organization model, views and templates - Create, edit and delete superusers and staff (fixes #44) - Create, edit and delete region users (fixes #59) - Show region switcher based on user's permissions (fixes #56) - Show link to network management if user is superuser or staff (fixes #66)
- Loading branch information
1 parent
3115a29
commit dcdc24f
Showing
35 changed files
with
1,346 additions
and
28 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
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,15 @@ | ||
from django.db import models | ||
from django.utils import timezone | ||
|
||
|
||
class Organization(models.Model): | ||
|
||
name = models.CharField(max_length=200) | ||
slug = models.SlugField(max_length=200, unique=True) | ||
thumbnail = models.CharField(max_length=250, blank=True) | ||
|
||
created_date = models.DateTimeField(default=timezone.now) | ||
last_updated = models.DateTimeField(auto_now=True) | ||
|
||
def __str__(self): | ||
return self.name |
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,22 @@ | ||
from django.db import models | ||
from django.conf import settings | ||
|
||
from .site import Site | ||
from .organization import Organization | ||
|
||
|
||
class UserProfile(models.Model): | ||
|
||
user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name='profile', on_delete=models.CASCADE) | ||
regions = models.ManyToManyField(Site, blank=True) | ||
organization = models.ForeignKey(Organization, null=True, blank=True, on_delete=models.SET_NULL) | ||
|
||
@property | ||
def roles(self): | ||
return self.user.groups.all() | ||
|
||
def __str__(self): | ||
return self.user.username | ||
|
||
class Meta(): | ||
default_permissions = () |
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
15 changes: 15 additions & 0 deletions
15
backend/cms/templates/general/confirmation_popups/delete_region_user.html
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,15 @@ | ||
{% load i18n %} | ||
<div id="confirm_delete_user" class="confirmation-popup flex-col justify-center max-w-sm fixed pin-t pin-b pin-r pin-l hidden"> | ||
<div class="content bg-grey-light w-full p-4 shadow-md rounded"> | ||
<h2>{% trans 'Please confirm that you really want to delete this user' %}</h2> | ||
<p class="mt-4 mb-6"> | ||
{% trans 'This cannot be reversed.' %} | ||
</p> | ||
<a href="{% url 'delete_region_user' site_slug=site.slug user_id=user_form.instance.id %}" class="bg-red hover:bg-red-dark text-white font-bold py-3 px-4 mr-2 rounded focus:outline-none focus:shadow-outline"> | ||
{% trans 'Yes, delete this user now' %} | ||
</a> | ||
<button class="cursor-pointer bg-blue hover:bg-blue-dark text-white font-bold py-3 px-4 rounded" onclick="close_confirmation_popup(event)"> | ||
{% trans 'Cancel' %} | ||
</button> | ||
</div> | ||
</div> |
15 changes: 15 additions & 0 deletions
15
backend/cms/templates/general/confirmation_popups/delete_user.html
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,15 @@ | ||
{% load i18n %} | ||
<div id="confirm_delete_user" class="confirmation-popup flex-col justify-center max-w-sm fixed pin-t pin-b pin-r pin-l hidden"> | ||
<div class="content bg-grey-light w-full p-4 shadow-md rounded"> | ||
<h2>{% trans 'Please confirm that you really want to delete this user' %}</h2> | ||
<p class="mt-4 mb-6"> | ||
{% trans 'This cannot be reversed.' %} | ||
</p> | ||
<a href="{% url 'delete_user' user_id=user_form.instance.id %}" class="bg-red hover:bg-red-dark text-white font-bold py-3 px-4 mr-2 rounded focus:outline-none focus:shadow-outline"> | ||
{% trans 'Yes, delete this user now' %} | ||
</a> | ||
<button class="cursor-pointer bg-blue hover:bg-blue-dark text-white font-bold py-3 px-4 rounded" onclick="close_confirmation_popup(event)"> | ||
{% trans 'Cancel' %} | ||
</button> | ||
</div> | ||
</div> |
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,41 @@ | ||
{% extends "_base.html" %} | ||
{% load i18n %} | ||
{% block content %} | ||
{% load static %} | ||
<div class="table-header"> | ||
<div class="flex flex-wrap"> | ||
<form class="table-search relative w-1/2"> | ||
<i data-feather="search" class="absolute"></i> | ||
<input type="search" placeholder="{% trans 'Search' %}" class="h-full pl-10 pr-4 rounded shadow"> | ||
</form> | ||
<div class="w-1/2 flex flex-wrap justify-end"> | ||
<a href="{% url 'new_organization' %}" class="bg-grey-dark hover:bg-integreat hover:text-grey-darkest text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"> | ||
{% trans 'Create organization' %} | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="table-listing"> | ||
<table class="w-full mt-4 rounded border border-solid border-grey-light shadow bg-white"> | ||
<thead> | ||
<tr class="border-b border-solid border-grey-light"> | ||
<th class="text-sm text-left uppercase py-3 pl-4 pr-2">{% trans 'Name' %}</th> | ||
<th class="text-sm text-left uppercase py-3 px-2">{% trans 'Slug' %}</th> | ||
<th class="text-sm text-left uppercase py-3 px-2">{% trans 'Thumbnail' %}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for organization in organizations %} | ||
{% include "organizations/list_row.html" %} | ||
{% empty %} | ||
<tr> | ||
<td colspan="6" class="px-2 py-3"> | ||
{% trans 'No organizations available yet.' %} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
{% endblock %} |
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,13 @@ | ||
<tr class="border-t border-solid border-grey-lighter hover:bg-grey-lightest"> | ||
<td> | ||
<a href="{% url 'edit_organization' organization_id=organization.id %}" class="block py-3 px-2 text-grey-darkest"> | ||
{{ organization.name }} | ||
</a> | ||
</td> | ||
<td> | ||
{{ organization.slug }} | ||
</td> | ||
<td> | ||
{{ organization.thumbnail }} | ||
</td> | ||
</tr> |
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,77 @@ | ||
{% extends "_base.html" %} | ||
{% load i18n %} | ||
{% block content %} | ||
{% load static %} | ||
{% load widget_tweaks %} | ||
<form method="post"> | ||
{% csrf_token %} | ||
<div class="flex flex-wrap mb-4"> | ||
<div class="w-2/5 flex flex-wrap flex-col justify-center"> | ||
<h2 class="heading font-normal"> | ||
{% if form.initial %} | ||
{% with form.name.value as organization_name %} | ||
{% blocktrans %}Edit organization "{{ organization_name }}"{% endblocktrans %} | ||
{% endwith %} | ||
{% else %} | ||
{% trans 'Create new organization' %} | ||
{% endif %} | ||
</h2> | ||
</div> | ||
<div class="w-3/5 flex justify-end"> | ||
<input type="submit" name="submit_save" class="cursor-pointer bg-grey hover:bg-grey-dark text-white font-bold py-3 px-4 rounded mr-2" value="{% trans 'Save' %}" /> | ||
<input type="submit" name="submit_publish" class="cursor-pointer bg-blue hover:bg-blue-dark text-white font-bold py-3 px-4 rounded" value="{% trans 'Publish' %}" /> | ||
</div> | ||
</div> | ||
|
||
<div class="flex flex-wrap"> | ||
<div class="w-1/2 pr-4"> | ||
{{form.errors}} | ||
<div class="w-full mb-4 rounded border border-solid border-grey-light shadow bg-white"> | ||
<div class="w-full p-4 rounded bg-blue-dark"> | ||
<h3 class="heading font-bold text-white">{% trans 'General Settings' %}</h3> | ||
</div> | ||
<div class="w-full p-4"> | ||
|
||
<!-- General Options for organization management --> | ||
<label for="name" class="font-bold block p-2 mb-2">{% trans "Organizationname" %}</label> | ||
{% trans "Enter the organization's name here" as name_placeholder%} | ||
{% render_field form.name placeholder=name_placeholder class="appearance-none block w-full bg-grey-lighter text-xl text-grey-darkest border border-grey-lighter rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-grey" %} | ||
|
||
<label for="slug" class="font-bold block p-2 mb-2">{% trans "Slug of the organization" %}</label> | ||
{% trans "Enter the organization's slug here" as slug_placeholder%} | ||
{% render_field form.slug placeholder=slug_placeholder class="appearance-none block w-full bg-grey-lighter text-xl text-grey-darkest border border-grey-lighter rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-grey" %} | ||
|
||
<label for="thumbnail" class="font-bold block p-2 mb-2">{% trans "Thumbnail of the organization" %}</label> | ||
{% trans "Enter the organization's thumbnail here" as thumbnail_placeholder%} | ||
{% render_field form.thumbnail placeholder=thumbnail_placeholder class="appearance-none block w-full bg-grey-lighter text-xl text-grey-darkest border border-grey-lighter rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-grey" %} | ||
|
||
</div> | ||
</div> | ||
</div> | ||
<div class="w-1/2 pr-4"> | ||
<div class="w-full mb-4 rounded border border-solid border-grey-light shadow bg-white"> | ||
<div class="w-full p-4 rounded bg-blue-dark"> | ||
<h3 class="heading font-bold text-white">{% trans 'Extended Settings' %}</h3> | ||
</div> | ||
<div class="w-full p-4"> | ||
<div class="flex w-full bg-grey-lighter"> | ||
<img class="flex w-2/3 p-2 h-40 pt-4 pb-4 justify-start" src="https://tailwindcss.com/img/card-top.jpg"> | ||
</img> | ||
<div class="flex h-48 w-1/3 pt-4 p-2 pb-4 justify-end"> | ||
{% render_field form.icon id="icon" class="image-field" %} | ||
<label class="w-64 flex flex-col items-center px-4 py-6 bg-white text-blue rounded-lg shadow-lg tracking-wide uppercase border border-blue cursor-pointer hover:bg-blue hover:text-white"> | ||
<svg class="w-1/4 h-1/4" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"> | ||
<path d="M16.88 9.1A4 4 0 0 1 16 17H5a5 5 0 0 1-1-9.9V7a3 3 0 0 1 4.52-2.59A4.98 4.98 0 0 1 17 8c0 .38-.04.74-.12 1.1zM11 11h3l-4-4-4 4h3v3h2v-3z" /> | ||
</svg> | ||
<span class="mt-2 text-base leading-normal">{% trans 'Set icon' %}</span> | ||
<input type='filename' class="hidden" /> | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
{% endblock %} |
Oops, something went wrong.