36
app/access/forms/organization.py
Normal file
36
app/access/forms/organization.py
Normal file
@ -0,0 +1,36 @@
|
||||
from django import forms
|
||||
from django.db.models import Q
|
||||
|
||||
from app import settings
|
||||
|
||||
from access.models import Organization
|
||||
|
||||
|
||||
class OrganizationForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Organization
|
||||
fields = [
|
||||
'name',
|
||||
'slug',
|
||||
]
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.fields['created'] = forms.DateTimeField(
|
||||
label="Created",
|
||||
input_formats=settings.DATETIME_FORMAT,
|
||||
initial=kwargs['instance'].created,
|
||||
disabled=True,
|
||||
required=False,
|
||||
)
|
||||
|
||||
self.fields['modified'] = forms.DateTimeField(
|
||||
label="Modified",
|
||||
input_formats=settings.DATETIME_FORMAT,
|
||||
initial=kwargs['instance'].modified,
|
||||
disabled=True,
|
||||
required=False,
|
||||
)
|
@ -4,12 +4,10 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form>
|
||||
<div>{{ form.as_p }}</div>
|
||||
</form>
|
||||
|
||||
<section class="content-header">
|
||||
<fieldset><label>Name</label><!-- <input type="text" value="{{ organization.name }}" /> -->{{form.name}}</fieldset>
|
||||
<fieldset><label>Created</label><input type="text" value="{{ organization.created }}" readonly /></fieldset>
|
||||
<fieldset><label>Modified</label><input type="text" value="{{ organization.modified }}" readonly /></fieldset>
|
||||
</section>
|
||||
{% include 'icons/issue_link.html.j2' with issue=13 %}<br>
|
||||
|
||||
<input type="button" value="<< Back" onclick="window.location='{% url 'Access:Organizations' %}';">
|
||||
|
@ -5,6 +5,8 @@ from django.views import generic
|
||||
from access.mixin import *
|
||||
from access.models import *
|
||||
|
||||
from access.forms.organization import OrganizationForm
|
||||
|
||||
|
||||
|
||||
class IndexView(OrganizationPermission, generic.ListView):
|
||||
@ -28,13 +30,19 @@ class IndexView(OrganizationPermission, generic.ListView):
|
||||
|
||||
|
||||
class View(OrganizationPermission, generic.UpdateView):
|
||||
|
||||
context_object_name = "organization"
|
||||
|
||||
form_class = OrganizationForm
|
||||
|
||||
model = Organization
|
||||
|
||||
permission_required = [
|
||||
'access.view_organization',
|
||||
'access.change_organization',
|
||||
]
|
||||
|
||||
template_name = "access/organization.html.j2"
|
||||
fields = ["name", 'id']
|
||||
|
||||
|
||||
def get_success_url(self, **kwargs):
|
||||
@ -48,8 +56,6 @@ class View(OrganizationPermission, generic.UpdateView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
context['organization'] = Organization.objects.get(pk=self.kwargs['pk'])
|
||||
|
||||
context['teams'] = Team.objects.filter(organization=self.kwargs['pk'])
|
||||
|
||||
context['model_pk'] = self.kwargs['pk']
|
||||
|
Reference in New Issue
Block a user