#101 Team data view
* adds overview of shared teams on object detail view * adds team data view if button is clicked
This commit is contained in:
@@ -315,3 +315,46 @@ class EditTeamModalForm(NewTeamModalForm):
|
||||
|
||||
class RemoveTeamModalForm(RemoveModalForm):
|
||||
pass
|
||||
|
||||
|
||||
class TeamDataForm(BaseModalForm):
|
||||
name = forms.CharField(
|
||||
label_suffix="",
|
||||
label=_("Team name"),
|
||||
max_length=500,
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"placeholder": _("Team name"),
|
||||
"class": "form-control",
|
||||
}
|
||||
)
|
||||
)
|
||||
description = forms.CharField(
|
||||
label_suffix="",
|
||||
required=False,
|
||||
label=_("Description"),
|
||||
widget=forms.Textarea(
|
||||
attrs={
|
||||
"rows": 5,
|
||||
"class": "form-control"
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.form_title = _("Team")
|
||||
self.form_caption = ""
|
||||
self.render_submit = False
|
||||
form_data = {
|
||||
"name": self.instance.name,
|
||||
"description": self.instance.description,
|
||||
}
|
||||
self.load_initial_data(
|
||||
form_data,
|
||||
[
|
||||
"name",
|
||||
"description"
|
||||
]
|
||||
)
|
||||
@@ -1,6 +1,6 @@
|
||||
{% load fontawesome_5 i18n %}
|
||||
|
||||
<button class="btn btn-default btn-modal" data-form-url="{% url 'user:contact' user.id %}" title="{% trans 'Show contact data' %}">
|
||||
{% fa5_icon 'id-card' %}
|
||||
{% fa5_icon 'user' %}
|
||||
<span>{{user.username}}</span>
|
||||
</button>
|
||||
6
user/templates/user/includes/team_data_modal_button.html
Normal file
6
user/templates/user/includes/team_data_modal_button.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{% load fontawesome_5 i18n %}
|
||||
|
||||
<button class="btn btn-default btn-modal" data-form-url="{% url 'user:team-data' team.id %}" title="{% trans 'Show team data' %}">
|
||||
{% fa5_icon 'users' %}
|
||||
<span>{{team.name}}</span>
|
||||
</button>
|
||||
@@ -16,6 +16,7 @@ urlpatterns = [
|
||||
path("token/api", api_token_view, name="api-token"),
|
||||
path("contact/<id>", contact_view, name="contact"),
|
||||
path("team/", index_team_view, name="team-index"),
|
||||
path("team/<id>", data_team_view, name="team-data"),
|
||||
path("team/new", new_team_view, name="team-new"),
|
||||
path("team/<id>/edit", edit_team_view, name="team-edit"),
|
||||
path("team/<id>/remove", remove_team_view, name="team-remove"),
|
||||
|
||||
@@ -13,7 +13,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
from konova.contexts import BaseContext
|
||||
from konova.decorators import any_group_check, default_group_required
|
||||
from user.forms import UserNotificationForm, UserContactForm, UserAPITokenForm, NewTeamModalForm, EditTeamModalForm, \
|
||||
RemoveTeamModalForm
|
||||
RemoveTeamModalForm, TeamDataForm
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -133,6 +133,31 @@ def contact_view(request: HttpRequest, id: str):
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
def data_team_view(request: HttpRequest, id: str):
|
||||
""" Renders team data
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
id (str): The team's id
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
team = get_object_or_404(Team, id=id)
|
||||
form = TeamDataForm(request.POST or None, instance=team, request=request)
|
||||
template = "modal/modal_form.html"
|
||||
context = {
|
||||
"form": form,
|
||||
}
|
||||
context = BaseContext(request, context).context
|
||||
return render(
|
||||
request,
|
||||
template,
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
def index_team_view(request: HttpRequest):
|
||||
template = "user/team/index.html"
|
||||
|
||||
Reference in New Issue
Block a user