[chronojump-server] Created group page with creation and update options and all functionalities implemented
- From: Max Ros i Morejon <maxros src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump-server] Created group page with creation and update options and all functionalities implemented
- Date: Wed, 26 Jun 2019 10:43:25 +0000 (UTC)
commit a3396e34ed9967c009988b0511df34da81ca53cf
Author: Max Ros i Morejon <mros33 gmail com>
Date: Wed Jun 26 12:43:04 2019 +0200
Created group page with creation and update options and all functionalities implemented
.../organizations/api/serializers.py | 14 +-
.../chronojump_networks/organizations/api/urls.py | 10 +
.../chronojump_networks/organizations/api/views.py | 65 +++-
.../chronojump_networks/organizations/urls.py | 10 +
.../chronojump_networks/organizations/views.py | 10 +-
.../chronojump_networks/templates/layout.html | 8 +-
.../organizations/groups/add_edit_group_form.html | 50 ++++
.../organizations/groups/groups_list.html | 330 +++++++++++++++++++++
.../chronojump_networks/templates/pages/index.html | 16 +-
9 files changed, 495 insertions(+), 18 deletions(-)
---
diff --git a/chronojumpserver-django/chronojump_networks/organizations/api/serializers.py
b/chronojumpserver-django/chronojump_networks/organizations/api/serializers.py
index 7b10180..4faaa2d 100644
--- a/chronojumpserver-django/chronojump_networks/organizations/api/serializers.py
+++ b/chronojumpserver-django/chronojump_networks/organizations/api/serializers.py
@@ -1,6 +1,6 @@
from rest_framework import serializers
-from ..models import Player, Station, Exercise, Gym
+from ..models import Player, Station, Exercise, Gym, Group, User
from chronojump_networks.tasks.api.serializers import PlayerTaskSerializer
@@ -9,13 +9,16 @@ class PlayerSerializer(serializers.ModelSerializer):
class Meta:
model = Player
fields = [ 'id', 'name', 'number', 'height', 'weight', 'imageName', 'player_tasks', 'rfid']
-
-
+
class GymSerializer(serializers.ModelSerializer):
class Meta:
model = Gym
field = [ 'id', 'name', 'responsible']
+class GroupSerializer(serializers.ModelSerializer):
+ class Meta:
+ model = Group
+ fields = [ 'id', 'name', 'gym', 'responsible' ]
class StationSerializer(serializers.ModelSerializer):
class Meta:
@@ -33,3 +36,8 @@ class GymStationsSerializer(serializers.ModelSerializer):
class Meta:
model = Station
fields = [ 'id', 'name', 'type', 'exercises']
+
+class UserSerializer(serializers.ModelSerializer):
+ class Meta:
+ model = User
+ fields = [ 'id', 'name']
diff --git a/chronojumpserver-django/chronojump_networks/organizations/api/urls.py
b/chronojumpserver-django/chronojump_networks/organizations/api/urls.py
index 1a89c3b..b1cd9dc 100644
--- a/chronojumpserver-django/chronojump_networks/organizations/api/urls.py
+++ b/chronojumpserver-django/chronojump_networks/organizations/api/urls.py
@@ -26,11 +26,21 @@ urlpatterns = [
view=views.PlayerListView.as_view(),
name='players_list'
),
+ url(
+ regex=r'^(?P<organization_id>\d+)/groups/$',
+ view=views.GroupListView.as_view(),
+ name='groups_list'
+ ),
url(
regex=r'^(?P<organization_id>\d+)/gym_stations/$',
view=views.GymStationsListView.as_view(),
name='gym_stations'
),
+ url(
+ regex=r'^(?P<organization_id>\d+)/responsibles/$',
+ view=views.UsersListView.as_view(),
+ name='responsibles'
+ ),
url(
regex=r'^(?P<organization_id>\d+)/(?P<gym_id>\d+)/stations/$',
view=views.StationsListView.as_view(),
diff --git a/chronojumpserver-django/chronojump_networks/organizations/api/views.py
b/chronojumpserver-django/chronojump_networks/organizations/api/views.py
index aa4c327..efe7544 100644
--- a/chronojumpserver-django/chronojump_networks/organizations/api/views.py
+++ b/chronojumpserver-django/chronojump_networks/organizations/api/views.py
@@ -1,8 +1,8 @@
import os
import subprocess
-from ..models import Player, GroupPlayer, Group, Station, Gym, Exercise, RFIDHistory
+from ..models import Player, GroupPlayer, Group, Station, Gym, Exercise, RFIDHistory, OrganizationStaff, User
from ..decorators import check_user_organization
-from .serializers import PlayerSerializer, StationSerializer, ExerciseSerializer, GymStationsSerializer
+from .serializers import PlayerSerializer, StationSerializer, ExerciseSerializer, GymStationsSerializer,
GroupSerializer, UserSerializer
from django.core.files.storage import default_storage
from django.core.files.base import ContentFile
@@ -94,6 +94,23 @@ class StationsListView(ListAPIView):
gym = get_object_or_404(Gym, pk=gym_id)
return gym.stations.all()
+class UsersListView(ListAPIView):
+ """List users from organization """
+ permission_classes = (IsAuthenticated, )
+ serializer_class = UserSerializer
+
+ def list(self, request, *args, **kwargs):
+ # Get as dictionary the data given from ajax
+ organization_id = int(self.kwargs['organization_id'])
+ print(organization_id)
+ staff = OrganizationStaff.objects.filter(organization_id=organization_id)
+ staff = [s.user_id for s in staff]
+ print("id: ")
+ print(staff)
+ queryset = User.objects.filter(id__in = staff)
+ serializer = UserSerializer(queryset, many=True)
+ return Response(serializer.data)
+
class StationExercisesListView(ListCreateAPIView):
"""List exercises from station """
permission_classes = (IsAuthenticated, )
@@ -214,6 +231,50 @@ class PlayerListView(ListCreateAPIView):
print("Removed player %d" % (int(player_id)))
return JsonResponse({}, status=204, safe=False)
+class GroupListView(ListCreateAPIView):
+ """Groups of the organization"""
+ permission_classes = (IsAuthenticated, )
+ serializer_class = GroupSerializer
+
+ def get_queryset(self):
+ organization_id = int(self.kwargs['organization_id'])
+ return Group.objects.filter(organization_id=organization_id)
+
+ def create(self, request, *args, **kwargs):
+ print("crea group")
+ data = dict(request.data)
+ # TODO: Sure there is a better way to do this
+ o = Group.objects.create(
+ name = str(data['name'][0]),
+ gym_id = int(data['gym'][0]),
+ responsible_id = int(data['responsible'][0]),
+ organization_id = int(self.kwargs['organization_id'])
+ )
+ s = GroupSerializer(o)
+ return Response(s.data)
+
+ def put(self, request, *args, **kwars):
+ print("update group view")
+ #PROBLEMES AMB ACCENTS AL NOM DEL GRUP
+ data = dict(request.data)
+ o = Group.objects.get(id=int(data['id'][0]))
+ o.name = str(data['name'][0])
+ o.gym_id = int(data['gym'][0])
+ o.responsible_id = int(data['responsible'][0])
+ o.organization_id = int(self.kwargs['organization_id'])
+ o.save()
+ return JsonResponse({}, status=200, safe=False)
+
+ def delete(self, request, *args, **kwargs):
+ print("delete group")
+ data = dict(request.data)
+ group_ids = data['group_ids[]']
+ for group_id in group_ids:
+ o = Group.objects.get(id=int(group_id))
+ o.delete()
+ print("Removed group %d" % (int(group_id)))
+ return JsonResponse({}, status=204, safe=False)
+
def register_rfid(request):
"""Call an external program to read rfid and return the value read."""
diff --git a/chronojumpserver-django/chronojump_networks/organizations/urls.py
b/chronojumpserver-django/chronojump_networks/organizations/urls.py
index 367c517..be97359 100644
--- a/chronojumpserver-django/chronojump_networks/organizations/urls.py
+++ b/chronojumpserver-django/chronojump_networks/organizations/urls.py
@@ -38,6 +38,16 @@ urlpatterns = [
view=views.PlayerListTemplateView.as_view(),
name='players_list'
),
+ url(
+ regex=r'^(?P<organization_id>\d+)/groups$',
+ view=views.GroupListTemplateView.as_view(),
+ name='groups_list'
+ ),
+ url(
+ regex=r'^(?P<organization_id>\d+)/gyms$',
+ view=views.GymListTemplateView.as_view(),
+ name='gyms_list'
+ ),
url(
regex=r'^(?P<organization_id>\d+)/gyms/(?P<gym_id>\d+)$',
view=views.GymDetailTemplateView.as_view(),
diff --git a/chronojumpserver-django/chronojump_networks/organizations/views.py
b/chronojumpserver-django/chronojump_networks/organizations/views.py
index f123dd5..088e1cf 100644
--- a/chronojumpserver-django/chronojump_networks/organizations/views.py
+++ b/chronojumpserver-django/chronojump_networks/organizations/views.py
@@ -63,7 +63,15 @@ class PlayerListTemplateView(LoginRequiredMixin, TemplateView):
"""
template_name = 'organizations/players/players_list.html'
-
+class GroupListTemplateView(LoginRequiredMixin, TemplateView):
+ """ Show the Player List
+ """
+ template_name = 'organizations/groups/groups_list.html'
+
+class GymListTemplateView(LoginRequiredMixin, TemplateView):
+ """ Show the Player List
+ """
+ template_name = 'organizations/gyms/gyms_list.html'
#
# Login methods and views
diff --git a/chronojumpserver-django/chronojump_networks/templates/layout.html
b/chronojumpserver-django/chronojump_networks/templates/layout.html
index 78fcd91..701a753 100644
--- a/chronojumpserver-django/chronojump_networks/templates/layout.html
+++ b/chronojumpserver-django/chronojump_networks/templates/layout.html
@@ -35,8 +35,8 @@
{% for group in request.user.groups_by_coach.all %}
<a class="dropdown-item" href="{% url 'organizations:group_players_list'
organization_id=user.organization.id group_id=group.group.id %}">{{ group.group.name}}</a>
{% endfor %}
- <div class="dropdown-divider"></div>
- <a class="dropdown-item" href="#">{% trans 'Create a group' %}</a>
+<!-- <div class="dropdown-divider"></div>
+ <a class="dropdown-item" href="#">{% trans 'Create a group' %}</a>-->
</div>
</li>
{% endif %}
@@ -50,8 +50,8 @@
{% for gym in request.user.organization.gyms.all %}
<a class="dropdown-item" href="{% url 'organizations:gym_detail'
organization_id=user.organization.id gym_id=gym.id %}">{{ gym.name}}</a>
{% endfor %}
- <div class="dropdown-divider"></div>
- <a class="dropdown-item" href="#">{% trans 'Create a gym' %}</a>
+<!-- <div class="dropdown-divider"></div>
+ <a class="dropdown-item" href="#">{% trans 'Create a gym' %}</a>-->
</div>
</li>
{% endif %}
diff --git
a/chronojumpserver-django/chronojump_networks/templates/organizations/groups/add_edit_group_form.html
b/chronojumpserver-django/chronojump_networks/templates/organizations/groups/add_edit_group_form.html
new file mode 100644
index 0000000..7c12a4b
--- /dev/null
+++ b/chronojumpserver-django/chronojump_networks/templates/organizations/groups/add_edit_group_form.html
@@ -0,0 +1,50 @@
+{% load static i18n %}
+
+<!-- Modal Form to add a new task -->
+<div id="addGroupModalForm" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="{% trans 'Add
Group' %}" aria-hidden="true">
+ <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h5 class="modal-title" id="groupModalTitle">{% trans 'Add new group' %}</h5>
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+ <span aria-hidden="true">×</span>
+ </button>
+ </div>
+ <div class="modal-body">
+
+ <input type="hidden" id="groupId" />
+
+ <form>
+ <div class="form-row">
+ <div class="form-group col-sm-4">
+ <label for="name">{% trans 'Name' %}</label>
+ <input name="name" class="form-control" id="name"
type="text">
+ </div>
+ <div class="form-group col-sm-4">
+ <label for="gymSelect">{% trans 'Gym' %}</label>
+ <select name="gymSelect" class="form-control" id="gymSelect">
+ {% for gym in user.organization.gyms.all %}
+ <option value={{gym.id}}>{{gym.name}}</option>
+ {% endfor %}
+ </select>
+ </div>
+ <div class="form-group col-sm-4">
+ <label for="respSelect">{% trans 'Responsible' %}</label>
+ <select name="respSelect" class="form-control" id="respSelect">
+ <!-- Load dinamically -->
+ </select>
+ </div>
+ </div>
+ </form>
+
+ </div> <!-- .modal-body -->
+ <div class="modal-footer">
+ <button type="button" class="btn btn-outline-secondary"
data-dismiss="modal">{% trans 'Cancel' %}</button>
+ <button id="btnAddModifyGroup" type="button" class="btn btn-outline-primary" >{% trans 'Add
group' %}</button>
+ </div>
+ </div>
+ <!-- /.modal-content -->
+ </div>
+ <!-- /.modal-dialog -->
+</div>
+
diff --git a/chronojumpserver-django/chronojump_networks/templates/organizations/groups/groups_list.html
b/chronojumpserver-django/chronojump_networks/templates/organizations/groups/groups_list.html
new file mode 100644
index 0000000..cbcd89d
--- /dev/null
+++ b/chronojumpserver-django/chronojump_networks/templates/organizations/groups/groups_list.html
@@ -0,0 +1,330 @@
+{% extends 'layout.html' %}
+{% load static i18n %}
+
+{% block title %}Chronojump Networks | {{user.organization.name}} | {{group.name}}{% endblock %}
+
+{% block css %}
+{{ block.super }}
+<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap4.min.css">
+<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.5.1/css/buttons.bootstrap4.min.css">
+<!--<link rel="stylesheet"
href="https://cdn.datatables.net/fixedcolumns/3.2.4/css/fixedColumns.bootstrap4.min.css">-->
+
+{% endblock %}
+
+{% block content %}
+{% csrf_token %}
+
+<div class="page-header row">
+ <div class="col-sm-9">
+ {% if user.organization.image %}
+ <img src="{{MEDIA_URL}}{{ user.organization.image }}" class="img-fluid float-left" width="48px"
height="48px" style="margin-top:12px;margin-right:10px;" />
+ {% else %}
+ <img src="{% static 'images/logo_club.png' %}" class="img-fluid float-left" width="48px"
height="48px" style="margin-top:12px;margin-right:10px;" />
+ {% endif %}
+ <h1 class="display-4">{% trans 'Groups list' %}</h1>
+ </div>
+
+</div>
+
+<div class="row datatables_wrapped">
+ <div class="col">
+ <table id="groups" cellspacing="0" cellpadding="0" class="table table-sm" style="width:100%">
+ </table>
+ </div>
+</div>
+
+<!-- Include Modal Task Form -->
+{% include 'organizations/groups/add_edit_group_form.html' %}
+
+{% endblock %}
+
+{% block javascript %}
+{{ block.super }}
+<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
+<script src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap4.min.js"></script>
+<script src="https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script>
+<script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.bootstrap4.min.js"></script>
+<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
+<script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.print.min.js"></script>-->
+<script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js"></script>
+<!--<script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.colVis.min.js"></script>
+<script src="https://cdn.datatables.net/fixedcolumns/3.2.4/js/dataTables.fixedColumns.min.js"></script>-->
+<script>
+ var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
+
+ $(document).ready(function() {
+ /* Datatable for groups */
+ var table_groups = $('#groups').DataTable({
+ lengthChange: false,
+ "ajax": {
+ "processing": true,
+ "url" : "{% url 'api_organizations:groups_list' organization_id=user.organization.id %}",
+ "dataSrc": ""
+ },
+ "order": [
+ [2, 'asc'],
+ [3, 'asc']
+ ],
+ "columns": [
+ {
+ type: "html",
+ orderable:false,
+ render: function(value, type, row) {
+ {% if user.is_staff %}
+ return '<input class="selectGroupCheckbox" type="checkbox" data-group-id="' + row.id + '"/>';
+ {% else %}
+ return '<input class="selectGroupCheckbox" type="checkbox" data-group-id="' + row.id + '"
style=" visibility: hidden"/>';
+ {% endif %}
+ }
+ },
+ {
+ "data": "name",
+ title: "{% trans 'Group name' %}",
+ },
+ {
+ "data": "responsible",
+ title: "{% trans 'Responsible' %}"
+ },
+ {
+ "data": "gym",
+ title: "{% trans 'Gym' %}"
+ },
+ {% if user.is_staff %}
+ {
+ "type": "html",
+ orderable: false,
+ render: function(value, type, row) {
+ var html = "";
+ // Edit Group Button
+ html += '<button type="button" class="editGroupBtn btn btn-outline-info btn-sm" ';
+ html += 'data-group-id="' + row.id + '" ';
+ html += 'data-group-name="' + row.name + '" ';
+ html += 'data-toggle="tooltip" data-placement="right" ';
+ html += 'title="' + "{% trans 'Edit group ' %}" + row.name + '">';
+ html += '<i class="material-icons" style="margin-top:3px;font-size:16px;">edit</i></button>';
+ return html;
+ }
+ }
+ {% endif %}
+ ],
+ "dom": "<'row'<'col-sm-6'B><'col-sm-6'f>>rtip",
+ buttons: [
+ {% if user.is_staff %}
+ { /* Create Group button */
+ text: "{% trans 'Create group' %}",
+ className: "btn btn-primary",
+ action: function( e, dt, node, config ) {
+ newGroupInitialOperations();
+ // Set the title for new group task
+ var title = "{% trans 'Create new group '%}";
+ $('#groupModalTitle').text(title);
+ $('#btnAddModifyGroup').text("{% trans 'Create group' %}");
+ $('#addGroupModalForm').modal('show');
+
+ }
+ },
+ { /* Remove Groups Button */
+ text: "{% trans 'Remove groups' %}",
+ className: "btn btn-danger disabled removeGroupBtn",
+ action: function( e, dt, node, config ) {
+ var group_ids = [];
+ $.each($('.selectGroupCheckbox:checked'), function(index, value) {
+ var v = $(value);
+ group_ids.push(v.attr('data-group-id'));
+
+ });
+ removeGroups(group_ids);
+ }
+ }
+ {% endif %}
+ ],
+ initComplete: function() {
+ // Enable the remove group selection the first time data is loaded
+ enableGroupsTableFunctionality(); //TODO: CHECK if this is needed and implemented
+ },
+ "language": {
+ "lengthMenu": "{% trans 'Showing _MENU_ groups per page' %}",
+ "zeroRecords": "{% trans 'There are no groups in this group' %}",
+ "info": "{% trans 'Showing the groups _START_ to _END_ of a total of _TOTAL_ groups' %}",
+ "infoEmpty": "{% trans 'The search returns no results' %}",
+ "infoFiltered": "{% trans '(from a total of _MAX_ groups)' %}",
+ "decimal": ",",
+ "thousands": ".",
+ "paginate": {
+ "first": '<i class="fa fa-fast-backward"></i>',
+ "last": '<i class="fa fa-fast-forward"></i>',
+ "next": '<i class="fa fa-forward"></i>',
+ "previous": '<i class="fa fa-backward"></i>'
+ },
+ "search": "{% trans 'Search:' %}"
+ }
+ });
+
+ /* Buttons operation */
+ function removeGroups(group_ids) {
+ console.log("gonna remova group");
+ $.ajax({
+ 'url': "{% url 'api_organizations:groups_list' organization_id=user.organization.id %}",
+ 'method': 'DELETE',
+ 'data': {
+ 'group_ids': group_ids
+ },
+ success:function(data) {
+ console.log("groups removed");
+ // Hide AddGroupModel dialog
+ var totalChecked = $('.selectGroupCheckbox:checked').length;
+ if (totalChecked == 1) {
+ alert("{% trans 'The group has been removed' %}");
+ } else {
+ alert("{% trans 'The groups have been removed' %}");
+ }
+ table_groups.ajax.reload(enableGroupsTableFunctionality, false);
+ }
+ });
+ }
+
+ function enableGroupsTableFunctionality() {
+ // Enanble checkboxes
+ loadUsers();
+ $('.removeGroupBtn').removeClass('disabled').addClass('disabled');
+ enableCheckboxSelection('selectGroupCheckbox', 'removeGroupBtn');
+
+ $('.editGroupBtn').on('click', function(){
+ var group = table_groups.row($(this).parents('tr')).data();
+
+ // Set the title for new group task
+ var title = "{% trans 'Edit group '%}" + group.name;
+ $('#groupModalTitle').text(title);
+
+ deserializeGroup(group);
+ $('#btnAddModifyGroup').text("{% trans 'Update group' %}");
+ $('#addGroupModalForm').modal('show');
+ });
+ }
+
+ /* initials operations for group */
+ function newGroupInitialOperations() {
+ // Set the group attributes
+ $('#name').val('');
+ $('#groupId').val('');
+ var group_gym = $('#gymSelect option:first').val();
+ $('#gymSelect').val(group_gym);
+ var resp_id = $('#respSelect option:first').val();
+ $('#respSelect').val(resp_id);
+ }
+
+ /* Load users into responsible control */
+ function loadUsers() {
+ $('#respSelect').find('option').remove().end();
+ $.ajax({
+ 'url': "{% url 'api_organizations:responsibles' organization_id=user.organization.id %}",
+ success: function(data) {
+ var count = 0;
+ $.each(data, function(i, item) {
+ count ++;
+ $('#respSelect').append($('<option>', {
+ value: item.id,
+ text: item.name
+ }));
+ })
+ if (count > 0) {
+ $('#respSelect').removeAttr('disabled');
+ // Load exercises from first station loaded
+ var resp_id = $('#respSelect option:first').val();
+ $('#respSelect').val(resp_id);
+ } else {
+ // Disable group creation
+ }
+ }
+ });
+ }
+
+ $('#btnAddModifyGroup').on('click', function(e) {
+ e.preventDefault();
+ if($('#name').val()=="") alert("{% trans 'All fields must be filled' %}");
+ else {
+ var group = serializeGroup();
+ if($('#groupId').val()) {
+ console.log("update");
+ //update group
+ updateGroup(group);
+ } else {
+ console.log("create");
+ //create group
+ putGroup(group);
+ }
+ }
+ })
+
+ // Get all the values in the form into json object
+ function serializeGroup() {
+ console.log("id = " + $('#groupId').val());
+ let group_id = $('#groupId').val();
+ let group_name = $('#name').val();
+ let group_gym = $('#gymSelect').val();
+ let group_responsible = $('#respSelect').val();
+ console.log("resp: " + $('#respSelect').val());
+ var group = {
+ 'id': group_id,
+ 'name': group_name,
+ 'gym': group_gym,
+ 'responsible': group_responsible
+ }
+ console.log(group);
+ return group;
+ }
+
+ // Dump values from group into Modal Form
+ function deserializeGroup(group) {
+ console.log(group);
+ $('#groupId').val(group.id);
+ $('#name').val(group.name);
+ $('#gymSelect').val(group.gym);
+ $('#respSelect').val(group.responsible);
+ }
+
+ function putGroup(group) {
+ // TODO: Add validation
+ console.log("botó add group");
+ $.ajax({
+ 'url': "{% url 'api_organizations:groups_list' organization_id=user.organization.id %}",
+ 'method': 'POST',
+ 'data': group,
+ success: function(data) {
+ alert("{% trans 'The group has been created' %}");
+ table_groups.ajax.reload(enableGroupsTableFunctionality,false);
+ $('#addGroupModalForm').modal('hide');
+ },
+ error: function(request, status, error) {
+// var parts = request.responseText.split('\n');
+// alert(parts[1]);
+ alert(request.responseText);
+ }
+ });
+ }
+
+ function updateGroup(group) {
+ /* TODO: Add validation */
+ console.log("botó update group");
+ $.ajax({
+ 'url': "{% url 'api_organizations:groups_list' organization_id=user.organization.id %}",
+ 'method': 'PUT',
+ 'data': group,
+ success: function(data) {
+ alert("{% trans 'The group has been updated' %}");
+ table_groups.ajax.reload(enableGroupsTableFunctionality, false);
+ $('#addGroupModalForm').modal('hide');
+ },
+ error: function(request, status, error) {
+ var parts = request.responseText.split('\n');
+ alert(parts[1]);
+ }
+
+ });
+ }
+
+ });
+</script>
+{% endblock %}
diff --git a/chronojumpserver-django/chronojump_networks/templates/pages/index.html
b/chronojumpserver-django/chronojump_networks/templates/pages/index.html
index 98f3ca1..0e63f30 100644
--- a/chronojumpserver-django/chronojump_networks/templates/pages/index.html
+++ b/chronojumpserver-django/chronojump_networks/templates/pages/index.html
@@ -30,7 +30,7 @@
<div class="col-md-6">
<div class="float-right">
<ul class="nav">
- <li class="nav-item active"><a class="nav-link text-white" href="#">{% trans 'Welcome,
'%}{{user.name}}</a></li>
+ <li class="nav-item active"><a class="nav-link text-white">{% trans 'Welcome,
'%}{{user.name}}</a></li>
<li class="nav-item active"><a href="{% url 'logout' %}" class="nav-link text-white">{% trans
'Close session' %}</a></li>
</ul>
</div>
@@ -91,17 +91,17 @@
{% if user.id == user.organization.responsible.id %}
<h2 class="text-center">{% trans 'Organization options' %}</h2>
<div class="row buttons" >
- <div class="col-sm-6 col-md-3">
+ <!--<div class="col-sm-6 col-md-3">
<a class="btn btn-outline-primary btn-block font-weight-bold text-uppercase" href="">{% trans
'Staff' %}</a>
- </div>
- <div class="col-sm-6 col-md-3">
+ </div>-->
+ <div class="col-sm-6 col-md-4">
<a class="btn btn-outline-primary btn-block font-weight-bold text-uppercase" href="{% url
'organizations:players_list' organization_id=user.organization.id %}">{% trans 'Players' %}</a>
</div>
- <div class="col-sm-6 col-md-3">
- <a class="btn btn-outline-primary btn-block font-weight-bold text-uppercase" href="">{% trans
'Groups' %}</a>
+ <div class="col-sm-6 col-md-4">
+ <a class="btn btn-outline-primary btn-block font-weight-bold text-uppercase" href="{% url
'organizations:groups_list' organization_id=user.organization.id %}">{% trans 'Groups' %}</a>
</div>
- <div class="col-sm-6 col-md-3">
- <a class="btn btn-outline-primary btn-block font-weight-bold text-uppercase" href="">{% trans
'Gyms' %}</a>
+ <div class="col-sm-6 col-md-4">
+ <a class="btn btn-outline-primary btn-block font-weight-bold text-uppercase" href="{% url
'organizations:gyms_list' organization_id=user.organization.id %}">{% trans 'Gyms' %}</a>
</div>
</div>
{% endif %}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]