added more info to sync info page
put sync diagnose info in table, switch buttons to icons
This commit is contained in:
@@ -9,21 +9,24 @@
|
|||||||
|
|
||||||
{% include 'messages.html' %}
|
{% include 'messages.html' %}
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
{% for obj_name, obj_data in teamsnap_objects.items %}
|
{% for obj_name, obj_data in teamsnap_objects.items %}
|
||||||
<li class="list-group-item">
|
<tr class="">
|
||||||
<span class="fw-bold">{{ obj_name }}:</span> {{ obj_data.object_count }} objects
|
<th>{{ obj_name }}</th>
|
||||||
<a class="btn btn-primary btn-sm" href="{% url 'update' object_name=obj_name %}" role="button">
|
<td>{{ obj_data.object_count }}</td>
|
||||||
<i class="bi bi-arrow-clockwise"></i>
|
<th>{{ obj_data.counterpart.name }} </th>
|
||||||
TeamSnap.com
|
<td>{{ obj_data.counterpart.object_count }}</td>
|
||||||
</a>
|
<td><a class="btn btn-primary" href="{% url 'update' object_name=obj_name %}" role="button">
|
||||||
<a class="btn btn-primary btn-sm" href="{% url 'send' object_name=obj_name %}" role="button">
|
<i class="bi bi-cloud-fill"></i><i class="bi bi-arrow-right"></i><i class="bi bi-asterisk"></i>
|
||||||
<i class="bi bi-arrow-clockwise"></i>
|
</a></td>
|
||||||
BenchCoach
|
<td><a class="btn btn-primary" href="{% url 'send' object_name=obj_name %}" role="button">
|
||||||
</a>
|
<i class="bi bi-asterisk"/><i class="bi bi-arrow-right"/><i class="bi bi-clipboard"/>
|
||||||
</li>
|
</a></td>
|
||||||
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -32,14 +32,27 @@ def edit_event(request, id):
|
|||||||
event = Event.objects.get(id = id)
|
event = Event.objects.get(id = id)
|
||||||
return redirect(event.edit_url)
|
return redirect(event.edit_url)
|
||||||
|
|
||||||
|
@login_required()
|
||||||
def home(request):
|
def home(request):
|
||||||
current_benchcoach_user = request.user
|
current_benchcoach_user = request.user
|
||||||
current_teamsnap_user = request.user.profile.teamsnap_user
|
current_teamsnap_user = request.user.profile.teamsnap_user
|
||||||
current_teamsnap_team = request.user.profile.teamsnapsettings.managed_team
|
current_teamsnap_team = request.user.profile.teamsnapsettings.managed_team
|
||||||
teamsnap_objects = {}
|
teamsnap_objects = {}
|
||||||
for obj in [Availability, Event, LineupEntry, Location, Member, Opponent, Team, User]:
|
for teamsnap_obj, benchcoach_object in [
|
||||||
teamsnap_objects[obj.__name__.lower()] = {}
|
(Availability, benchcoach.models.Availability),
|
||||||
teamsnap_objects[obj.__name__.lower()]['object_count']=obj.objects.count()
|
(Event, benchcoach.models.Event),
|
||||||
|
(LineupEntry, benchcoach.models.Positioning),
|
||||||
|
(Location, benchcoach.models.Venue),
|
||||||
|
(Member, benchcoach.models.Player),
|
||||||
|
(Opponent, benchcoach.models.Team),
|
||||||
|
(Team, benchcoach.models.Team),
|
||||||
|
(User, None)
|
||||||
|
]:
|
||||||
|
teamsnap_objects[teamsnap_obj.__name__.lower()] = {}
|
||||||
|
teamsnap_objects[teamsnap_obj.__name__.lower()]['object_count'] = teamsnap_obj.objects.count()
|
||||||
|
if benchcoach_object:
|
||||||
|
teamsnap_objects[teamsnap_obj.__name__.lower()]['counterpart'] = {'name':benchcoach_object.__name__.lower()}
|
||||||
|
teamsnap_objects[teamsnap_obj.__name__.lower()]['counterpart']['object_count'] = benchcoach_object.objects.count()
|
||||||
|
|
||||||
context= {
|
context= {
|
||||||
'benchcoach_user': current_benchcoach_user,
|
'benchcoach_user': current_benchcoach_user,
|
||||||
@@ -104,13 +117,18 @@ def update_teamsnapdb_from_teamsnapapi(request, object_name, object_id=None):
|
|||||||
|
|
||||||
for Obj in [Object]:
|
for Obj in [Object]:
|
||||||
r[Obj.__name__.lower()] = []
|
r[Obj.__name__.lower()] = []
|
||||||
|
if not object_id:
|
||||||
a = Obj.ApiObject.search(CLIENT, team_id=TEAM_ID)
|
a = Obj.ApiObject.search(CLIENT, team_id=TEAM_ID)
|
||||||
for _a in a:
|
for _a in a:
|
||||||
obj, created = Obj.update_or_create_from_teamsnap_api(_a.data)
|
obj, created = Obj.update_or_create_from_teamsnap_api(_a.data)
|
||||||
r[Obj.__name__.lower()].append((obj, created))
|
r[Obj.__name__.lower()].append((obj, created))
|
||||||
|
else:
|
||||||
|
a = Obj.ApiObject.search(CLIENT, id=object_id)[0]
|
||||||
|
obj, created = Obj.update_or_create_from_teamsnap_api(a.data)
|
||||||
|
r[Obj.__name__.lower()].append((obj, created))
|
||||||
|
|
||||||
for object_name, results in r.items():
|
for object_name, results in r.items():
|
||||||
if len(r) == 0:
|
if len(results) == 0:
|
||||||
messages.error(request, f"Error! No {object_name} objects created or updated")
|
messages.error(request, f"Error! No {object_name} objects created or updated")
|
||||||
else:
|
else:
|
||||||
result = [created for obj, created in results]
|
result = [created for obj, created in results]
|
||||||
|
|||||||
Reference in New Issue
Block a user