@ -1 +0,0 @@
|
||||
from .team import *
|
@ -1,17 +0,0 @@
|
||||
from django import forms
|
||||
|
||||
from django.forms import BaseInlineFormSet, BaseModelFormSet, ModelForm
|
||||
|
||||
from access.models import Organization, Team
|
||||
|
||||
from django.contrib.auth.models import Group, Permission
|
||||
from django.contrib.admin.widgets import FilteredSelectMultiple
|
||||
|
||||
|
||||
class TeamForm(BaseInlineFormSet):
|
||||
|
||||
model = Team
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.queryset = Team.objects.filter(pk=team_id)
|
@ -3,76 +3,32 @@
|
||||
{% block title %}Organization - {{ organization.name }}{% endblock %}
|
||||
|
||||
{% block body%}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
|
||||
<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>
|
||||
<input type="submit" value="Submit">
|
||||
|
||||
<input type="button" value="<< Back" onclick="window.location='{% url 'Access:Organizations' %}';">
|
||||
<input type="button" value="New Team" onclick="window.location='{% url 'Access:_team_add' organization.id %}';">
|
||||
</form>
|
||||
|
||||
{{ formset.non_form_errors.as_ul }}
|
||||
|
||||
|
||||
<form method="post">
|
||||
{{form.name.as_hidden}}
|
||||
|
||||
{% csrf_token %}
|
||||
<!-- <input type="submit" value="Submit"> -->
|
||||
{{ formset.management_form }}
|
||||
|
||||
{{ formset.non_form_errors.as_ul }}
|
||||
<table id="formset" class="form">
|
||||
|
||||
{% for form in formset.forms %}
|
||||
{% if forloop.first %}
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- {% for field in form.visible_fields %}
|
||||
<th>{{ field.label|capfirst }}</th>
|
||||
{% endfor %} -->
|
||||
<th>Team Name</th>
|
||||
<th>Created</th>
|
||||
<th>Modified</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% endif %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{% for field in form.visible_fields %}
|
||||
{% if field.name == 'team_name' and form.initial.id %}
|
||||
<td>
|
||||
{# Include the hidden fields in the form #}
|
||||
{% if forloop.first %}
|
||||
{% for hidden in form.hidden_fields %}
|
||||
{{ hidden }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{{ field.errors.as_ul }}
|
||||
|
||||
<a href="{% url 'Access:_organization' organization.id %}team/{{ form.initial.id }}">{{ form.instance.team_name }}</a>
|
||||
{{ field.as_hidden }}
|
||||
|
||||
</td>
|
||||
<td>{% if form.initial.id %}{{ form.instance.created }}{% endif %}</td>
|
||||
<td>{% if form.initial.id %}{{ form.instance.modified }}{% endif %}</td>
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
<th>Team Name</th>
|
||||
<th>Created</th>
|
||||
<th>Modified</th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<!--
|
||||
<br>
|
||||
<hr>
|
||||
<hr>
|
||||
{{ formset.forms.0.initial }}
|
||||
{% for key, value in formset.forms.items %}
|
||||
{{values}}
|
||||
<hr>
|
||||
{% endfor%} -->
|
||||
</thead>
|
||||
{% for field in teams %}
|
||||
<tr>
|
||||
<td><a href="{% url 'Access:_team' organization_id=organization.id pk=field.id %}">{{ field.team_name }}</a></td>
|
||||
<td>{{ field.created }}</td>
|
||||
<td>{{ field.modified }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
@ -24,8 +24,8 @@
|
||||
|
||||
<form method="post">
|
||||
|
||||
<input type="button" value="Organization" onclick="window.location='{% url 'Access:_organization' pk=organization.id %}';">
|
||||
<input type="button" value="delete Team" onclick="window.location='{% url 'Access:_team_delete' organization_id=organization.id pk=team.id %}';">
|
||||
<input type="button" value="<< Back" onclick="window.location='{% url 'Access:_organization' pk=organization.id %}';">
|
||||
<input type="button" value="Delete Team" onclick="window.location='{% url 'Access:_team_delete' organization_id=organization.id pk=team.id %}';">
|
||||
<input type="button" value="New User" onclick="window.location='{% url 'Access:_team_user_add' organization_id=organization.id pk=team.id %}';">
|
||||
{{ formset.management_form }}
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
from django.contrib.auth.mixins import PermissionRequiredMixin, LoginRequiredMixin
|
||||
from django.forms import inlineformset_factory
|
||||
from django.views import generic
|
||||
|
||||
from access.forms import TeamForm
|
||||
from access.mixin import *
|
||||
from access.models import *
|
||||
|
||||
@ -44,14 +42,9 @@ class View(LoginRequiredMixin, OrganizationPermission, generic.UpdateView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
organization = Organization.objects.get(pk=self.kwargs['pk'])
|
||||
context['organization'] = Organization.objects.get(pk=self.kwargs['pk'])
|
||||
|
||||
context['organization'] = organization
|
||||
|
||||
TeamsForm = inlineformset_factory(Organization, Team, fields=["team_name", 'id'], fk_name='organization', extra=1)
|
||||
formset = TeamsForm(instance=organization)
|
||||
|
||||
context['formset'] = formset
|
||||
context['teams'] = Team.objects.filter(organization=self.kwargs['pk'])
|
||||
|
||||
return context
|
||||
|
||||
|
@ -2,7 +2,6 @@ from django.contrib.auth.mixins import PermissionRequiredMixin, LoginRequiredMix
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.views import generic
|
||||
|
||||
from access.forms import TeamForm
|
||||
from access.models import Team, TeamUsers, Organization
|
||||
from access.mixin import *
|
||||
|
||||
|
Reference in New Issue
Block a user