-
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
17380d7
commit 98a28e7
Showing
37 changed files
with
1,356 additions
and
38 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> |
Oops, something went wrong.