#}
+ {# {% for day in days %}#}
+ {# {% get_obj_attr club day as dayDict %}#}
+ {##}
+ {# {% for time, info in dayDict %}#}
+ {##}
+ {# {% endfor %}#}
+ {##}
+ {# {% endfor %}#}
+ {#
#}
+
+
+ {% for day in days %}
+
+
+
+
+
+
-
+
+
+
- {{ info }}
- {# DESCRIPTON#}
-
- {% endif %}
+
+
+
+
+
+ {% endfor %}
+
+
+
+
- {% endfor %}
-
- {% endif %}
- {% endfor %}
-
-
- {% endfor %}
- {##}
- {% endfor %}
- {#
#}
-
-
- {#
#}
- {# {% for day in days %}#}
- {# {% get_obj_attr club day as dayDict %}#}
- {##}
- {# {% for time, info in dayDict %}#}
- {##}
- {# {% endfor %}#}
- {##}
- {# {% endfor %}#}
- {#
#}
-
-
- {% for day in days %}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {% endfor %}
-
-
-
+ {# {% endif %}#}
+ {##}
-
-
-
- {# {% endif %}#}
- {##}
-
+ {% endif %}
{% endblock %}
\ No newline at end of file
diff --git a/Clubs/templates/Clubs/clubsTrainings.html b/Clubs/templates/Clubs/clubsTrainings.html
index a91130c..15e9705 100644
--- a/Clubs/templates/Clubs/clubsTrainings.html
+++ b/Clubs/templates/Clubs/clubsTrainings.html
@@ -1,7 +1,14 @@
{% extends base_template %}
{% block content %}
+{% if not userHasClub %}
+ {% include 'Clubs/noClub.html' %}
+{% else %}
+
+{% endif %}
+
+
{% endblock %}
\ No newline at end of file
diff --git a/Clubs/templates/Clubs/noClub.html b/Clubs/templates/Clubs/noClub.html
new file mode 100644
index 0000000..a48c72a
--- /dev/null
+++ b/Clubs/templates/Clubs/noClub.html
@@ -0,0 +1,11 @@
+{% load static %}
+
+
Looks like you don't have a Club, so there is no content to show
+
+
+
+
+
Please go to
+ Clubs List and join a Club, or create one if you are owner.
+
+
\ No newline at end of file
diff --git a/Clubs/templates/Clubs/singleClubView.html b/Clubs/templates/Clubs/singleClubView.html
index 4eaf3df..13075ea 100644
--- a/Clubs/templates/Clubs/singleClubView.html
+++ b/Clubs/templates/Clubs/singleClubView.html
@@ -1,11 +1,12 @@
{% load crispy_forms_filters %}
{% load static %}
-
+
-
+
- {% if not userHasClub and not alreadySent %}
+ {% if not alreadySent %}
+{# {% if not userHasClub and not alreadySent %}#}
diff --git a/Clubs/templatetags/Clubs_tags.py b/Clubs/templatetags/Clubs_tags.py
index e508e39..a2379ff 100644
--- a/Clubs/templatetags/Clubs_tags.py
+++ b/Clubs/templatetags/Clubs_tags.py
@@ -1,12 +1,12 @@
-from django import template
-from Clubs.models import Schedule, userClub
-
-register = template.Library()
-
-
-@register.simple_tag
-def get_obj_attr(club, attr):
-
- obj = Schedule.objects.get(club_id=club.id)
- dayTable = getattr(obj, attr)
- return sorted(dayTable.items())
\ No newline at end of file
+# from django import template
+# from Clubs.models import Schedule
+#
+# register = template.Library()
+#
+#
+# @register.simple_tag
+# def get_obj_attr(club, attr):
+#
+# obj = Schedule.objects.get(club_id=club.id)
+# dayTable = getattr(obj, attr)
+# return sorted(dayTable.items())
\ No newline at end of file
diff --git a/Clubs/templatetags/__pycache__/Clubs_tags.cpython-310.pyc b/Clubs/templatetags/__pycache__/Clubs_tags.cpython-310.pyc
index 947dc97..2f24e91 100644
Binary files a/Clubs/templatetags/__pycache__/Clubs_tags.cpython-310.pyc and b/Clubs/templatetags/__pycache__/Clubs_tags.cpython-310.pyc differ
diff --git a/Clubs/views.py b/Clubs/views.py
index b839681..dec9ffb 100644
--- a/Clubs/views.py
+++ b/Clubs/views.py
@@ -6,9 +6,18 @@
from django.contrib.auth.decorators import login_required
from main.views import getBaseTemplate
from django.contrib import messages
-
+from django.core.cache import cache
# Create your views here.
+def userClub( userID):
+ return UserMembership.objects.get(user_id=userID).club
+
+def userHasClub(request):
+ try:
+ userClub(request.user.id)
+ return True
+ except:
+ return False
def checkRequests():
requests = Request.objects.filter(status = 'YES')
@@ -21,6 +30,7 @@ def checkRequests():
@login_required
def ClubsIndex(request):
+
authorized = True
try:
# find what club is the user in
@@ -39,7 +49,8 @@ def ClubsIndex(request):
'form': form,
'Club': yourClub,
'user': request.user,
- 'authorized': authorized
+ 'authorized': authorized,
+
}
if request.method == 'POST':
yourClub, created = Club.objects.get_or_create(id=membership.club_id)
@@ -111,6 +122,7 @@ def clubMembers(request):
'Club': yourClub,
'authorized': authorized,
'requestsDict': requestsDict,
+ 'userHasClub' : userHasClub(request),
'base_template' : getBaseTemplate(request, "Clubs")
}
@@ -172,7 +184,8 @@ def memberProfile(request, clubID, userID):
def clubTrainings(request):
context = {
- 'base_template': getBaseTemplate(request, "Clubs")
+ 'base_template': getBaseTemplate(request, "Clubs"),
+ 'userHasClub': userHasClub(request),
}
return render(request, "Clubs/clubsTrainings.html", context)
@@ -192,12 +205,11 @@ def singleClubView(request, id):
myClub = Club.objects.get(pk=id)
context = {
'Club': myClub,
- 'userHasClub': False
}
try:
userMembership = UserMembership.objects.get(user=request.user)
- context['userHasClub'] = True
+ # context['userHasClub'] = True
except:
userMembership = None
diff --git a/Clubs/views_schedule.py b/Clubs/views_schedule.py
index e90a68f..6461fe9 100644
--- a/Clubs/views_schedule.py
+++ b/Clubs/views_schedule.py
@@ -1,54 +1,56 @@
from django.shortcuts import render, HttpResponseRedirect, reverse
from datetime import datetime, date
-from .models import Schedule, UserMembership, userClub
+from .models import Schedule, UserMembership
from .utilis import Calendar
from django.contrib.auth.decorators import login_required
from main.views import getBaseTemplate
from .forms import ScheduleForm
from django.utils.safestring import mark_safe
-
+from .views import userHasClub, userClub
@login_required
def clubSchedule(request):
days = Schedule.days
- # userHasClub = False
- myClub = userClub(request.user.id)
+ authorized = False
+ hoursDict = {}
+
+
+ try:
+ myClub = userClub(request.user.id)
+ membership = UserMembership.objects.get(user_id=request.user.id)
+ if membership.authorized == 'FULL':
+ authorized = True
+ except:
+ myClub = False
+
try:
mySchedule = Schedule.objects.get(club_id=myClub.id)
fields = mySchedule._meta.get_fields()
except:
mySchedule = None
- hoursDict = {}
- for day in days:
- dayTable = getattr(mySchedule, day)
- if bool(dayTable):
- dayDict = sorted(dayTable.items())
- for time, info in dayDict:
- timeHours = int(time[:2])
- if timeHours not in hoursDict:
- hoursDict[timeHours] = []
-
- hoursDict[timeHours].append([day, time, info])
- hoursDict = sorted(hoursDict.items())
+ if mySchedule:
+ for day in days:
+ dayTable = getattr(mySchedule, day)
+ if bool(dayTable):
+ dayDict = sorted(dayTable.items())
+ for time, info in dayDict:
+ timeHours = int(time[:2])
+ if timeHours not in hoursDict:
+ hoursDict[timeHours] = []
+
+ hoursDict[timeHours].append([day, time, info])
+ hoursDict = sorted(hoursDict.items())
- authorized = False
- membership = UserMembership.objects.get(user_id=request.user.id)
- if membership.authorized == 'FULL':
- authorized = True
- # for timeHour, sessionsArray in hoursDict:
- # print(timeHour, sessionsArray)
context = {
- # 'userHasClub' : UserMembership.objects.get(user_id = request.user.id),
- # 'cal' : mark_safe(HTMLcal),
- # 'dayDict' : dayDict,
'authorized' : authorized,
- 'club' : userClub(request.user.id),
+ 'club' : myClub,
'days' : days,
'hoursDict' : hoursDict,
- 'base_template': getBaseTemplate(request, "Clubs")
+ 'base_template': getBaseTemplate(request, "Clubs"),
+ 'userHasClub': userHasClub(request)
}
diff --git a/Notifications/routing.py b/Notifications/routing.py
index c561339..84e4022 100644
--- a/Notifications/routing.py
+++ b/Notifications/routing.py
@@ -2,6 +2,6 @@
from . import consumers
-ws_urlpatterns = [
- path('ws/notify', consumers.WSConsumer.as_asgi())
-]
\ No newline at end of file
+# ws_urlpatterns = [
+# path('ws/notify', consumers.WSConsumer.as_asgi())
+# ]
\ No newline at end of file
diff --git a/Presentation/tests.py b/Presentation/tests.py
index 7ce503c..a79ca8b 100644
--- a/Presentation/tests.py
+++ b/Presentation/tests.py
@@ -1,3 +1,3 @@
-from django.test import TestCase
+# from django.test import TestCase
# Create your tests here.
diff --git a/WorkoutJournal/__pycache__/forms.cpython-310.pyc b/WorkoutJournal/__pycache__/forms.cpython-310.pyc
index f9a6b63..dadb56e 100644
Binary files a/WorkoutJournal/__pycache__/forms.cpython-310.pyc and b/WorkoutJournal/__pycache__/forms.cpython-310.pyc differ
diff --git a/WorkoutJournal/__pycache__/models.cpython-310.pyc b/WorkoutJournal/__pycache__/models.cpython-310.pyc
index 1d4efc2..0a13a05 100644
Binary files a/WorkoutJournal/__pycache__/models.cpython-310.pyc and b/WorkoutJournal/__pycache__/models.cpython-310.pyc differ
diff --git a/WorkoutJournal/__pycache__/views.cpython-310.pyc b/WorkoutJournal/__pycache__/views.cpython-310.pyc
index a8a4cfd..523153d 100644
Binary files a/WorkoutJournal/__pycache__/views.cpython-310.pyc and b/WorkoutJournal/__pycache__/views.cpython-310.pyc differ
diff --git a/WorkoutJournal/forms.py b/WorkoutJournal/forms.py
index 84a3c8a..1c02847 100644
--- a/WorkoutJournal/forms.py
+++ b/WorkoutJournal/forms.py
@@ -3,7 +3,7 @@
from django import forms
from django.forms import ModelForm
from django.utils.safestring import mark_safe
-
+from Clubs.views import userClub
from .models import *
@@ -13,11 +13,12 @@ class DatePickerInput(forms.DateInput):
class TrainingSessionForm(ModelForm):
- # def __init__(self, *args, **kwargs):
+ # def __init__(self, userID, *args, **kwargs):
# super().__init__(*args, **kwargs)
- # if user is not None:
- # self.fields['addedByUser'].initial = user
-
+ # if self.fields['club']:
+ # self.fields['club'] = userClub(userID)
+ # else:
+ # self.fields['club'] = None
class Meta:
model = TrainingSession
fields = '__all__'
@@ -72,6 +73,9 @@ class Meta:
widget=forms.CheckboxSelectMultiple(),
required=False)
+ # club = forms.ChoiceField(widget=forms.CheckboxInput(
+ # attrs={"class": "form-check-input", "id": "flexSwitchCheckDefault"}),
+ # required=False)
# widget=forms.CheckboxSelectMultiple(attrs={'class':'techniqueOption list-group-item p-2 d-flex '
# 'align-items-center cursor-pointer justify-content-between '
@@ -82,16 +86,6 @@ class Meta:
class addTechniqueForm(ModelForm):
type = forms.ChoiceField(choices=Technique.TechniqueTypes, widget=forms.RadioSelect())
- # def __init__(self, *args, **kwargs):
- # super().__init__(*args, **kwargs)
- # self.helper = FormHelper()
- # self.helper.layout = Layout(
- # # Field('type', css_class='sessionType', template="BJR_Techniques_types.html"),
- # Field('type', css_class='sessionType'),
- # Field('EnglishName', css_class='form-control'),
- # Field('otherName', css_class='form-control'),
- # # Field('description', css_class='form-control mb-3')
- # )
class Meta:
model = Technique
diff --git a/WorkoutJournal/migrations/0010_remove_trainingsession_user_trainingsession_club_and_more.py b/WorkoutJournal/migrations/0010_remove_trainingsession_user_trainingsession_club_and_more.py
new file mode 100644
index 0000000..f788295
--- /dev/null
+++ b/WorkoutJournal/migrations/0010_remove_trainingsession_user_trainingsession_club_and_more.py
@@ -0,0 +1,31 @@
+# Generated by Django 4.1.2 on 2023-03-18 20:23
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ('Clubs', '0027_delete_clubtrainingsession'),
+ ('WorkoutJournal', '0009_remove_trainingsession_addedbyuser_and_more'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='trainingsession',
+ name='user',
+ ),
+ migrations.AddField(
+ model_name='trainingsession',
+ name='club',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='Clubs.club'),
+ ),
+ migrations.AddField(
+ model_name='trainingsession',
+ name='participants',
+ field=models.ManyToManyField(blank=True, to=settings.AUTH_USER_MODEL),
+ ),
+ ]
diff --git a/WorkoutJournal/migrations/0011_trainingsession_user.py b/WorkoutJournal/migrations/0011_trainingsession_user.py
new file mode 100644
index 0000000..27381d3
--- /dev/null
+++ b/WorkoutJournal/migrations/0011_trainingsession_user.py
@@ -0,0 +1,22 @@
+# Generated by Django 4.1.2 on 2023-03-18 20:24
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ('WorkoutJournal', '0010_remove_trainingsession_user_trainingsession_club_and_more'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='trainingsession',
+ name='user',
+ field=models.ForeignKey(blank=True, default=1, on_delete=django.db.models.deletion.CASCADE, related_name='userOwner', to=settings.AUTH_USER_MODEL),
+ preserve_default=False,
+ ),
+ ]
diff --git a/WorkoutJournal/migrations/0012_remove_trainingsession_club_and_more.py b/WorkoutJournal/migrations/0012_remove_trainingsession_club_and_more.py
new file mode 100644
index 0000000..7534027
--- /dev/null
+++ b/WorkoutJournal/migrations/0012_remove_trainingsession_club_and_more.py
@@ -0,0 +1,21 @@
+# Generated by Django 4.1.2 on 2023-03-18 21:02
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('WorkoutJournal', '0011_trainingsession_user'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='trainingsession',
+ name='club',
+ ),
+ migrations.RemoveField(
+ model_name='trainingsession',
+ name='participants',
+ ),
+ ]
diff --git a/WorkoutJournal/migrations/__pycache__/0010_remove_trainingsession_user_trainingsession_club_and_more.cpython-310.pyc b/WorkoutJournal/migrations/__pycache__/0010_remove_trainingsession_user_trainingsession_club_and_more.cpython-310.pyc
new file mode 100644
index 0000000..9bac1b4
Binary files /dev/null and b/WorkoutJournal/migrations/__pycache__/0010_remove_trainingsession_user_trainingsession_club_and_more.cpython-310.pyc differ
diff --git a/WorkoutJournal/migrations/__pycache__/0011_trainingsession_user.cpython-310.pyc b/WorkoutJournal/migrations/__pycache__/0011_trainingsession_user.cpython-310.pyc
new file mode 100644
index 0000000..b603455
Binary files /dev/null and b/WorkoutJournal/migrations/__pycache__/0011_trainingsession_user.cpython-310.pyc differ
diff --git a/WorkoutJournal/migrations/__pycache__/0012_remove_trainingsession_club_and_more.cpython-310.pyc b/WorkoutJournal/migrations/__pycache__/0012_remove_trainingsession_club_and_more.cpython-310.pyc
new file mode 100644
index 0000000..7ca684d
Binary files /dev/null and b/WorkoutJournal/migrations/__pycache__/0012_remove_trainingsession_club_and_more.cpython-310.pyc differ
diff --git a/WorkoutJournal/models.py b/WorkoutJournal/models.py
index c76d4f4..b8df046 100644
--- a/WorkoutJournal/models.py
+++ b/WorkoutJournal/models.py
@@ -23,7 +23,6 @@ class Technique (models.Model):
def __str__(self):
return self.EnglishName
-
class TrainingSession(models.Model):
TStypes = (
('GI', 'GI'),
@@ -47,7 +46,11 @@ class TrainingSession(models.Model):
notes = models.TextField(max_length=2500,blank=True, null=True)
techniques = models.ManyToManyField(Technique, blank=True)
fightTime = models.IntegerField(blank=True, null=True)
- user = models.ForeignKey(User, blank=True, on_delete=models.CASCADE)
+ user = models.ForeignKey(User, related_name="userOwner", blank=True, on_delete=models.CASCADE)
+ # club = models.ForeignKey("Clubs.Club", blank=True, null=True, on_delete=models.CASCADE)
+ # participants = models.ManyToManyField(User, blank=True)
+
+
#change to foreign key???????? ^
def __str__(self):
return f'{self.type} {self.date}'
@@ -66,6 +69,8 @@ def save(self, *args, **kwargs):
self.totalLength = self.parseMinutes(self.hoursLength, self.minutesLength)
super(TrainingSession, self).save(*args, **kwargs)
+
+
class Suggestion(models.Model):
addedByUser = models.ManyToManyField(User, related_name="suggestedByUser", default=None)
technique = models.ForeignKey(Technique, on_delete=models.CASCADE, default=None, null=True, blank=True)
diff --git a/WorkoutJournal/templates/BJJournal/BJR_addSession/BJR_addSession.html b/WorkoutJournal/templates/BJJournal/BJR_addSession/BJR_addSession.html
index 9ea8445..77d6fc4 100644
--- a/WorkoutJournal/templates/BJJournal/BJR_addSession/BJR_addSession.html
+++ b/WorkoutJournal/templates/BJJournal/BJR_addSession/BJR_addSession.html
@@ -1,4 +1,4 @@
-{% extends base_template%}
+{% extends base_template %}
{% load static %}
{% load crispy_forms_filters %}
@@ -6,140 +6,150 @@
{% block content %}
-
- {% include 'common/messages.html' %}
+
+ {% include 'common/messages.html' %}
+
+ {#
#}
+
+ {% csrf_token %}
+
+
Add new session
+{# {% if authorized %}#}
+{# #}
+{# {{ form.club }}#}
+{# Club Training Session#}
+{# #}
+{# {% endif %}#}
+
+
- {#
#}
-
- {% csrf_token %}
-
Add new session
-
+
-
{{ form.errors }}
-
{{ form.errors }}
+
- {% include 'BJJournal/BJR_addSession/BJR_addSession_sessionType.html' %}
+ {% include 'BJJournal/BJR_addSession/BJR_addSession_sessionType.html' %}
-
-
-
-
+
+
+
- {% include 'BJJournal/BJR_addSession/BJR_addSession_Techniques.html' %}
-
- {# DATE #}
+ {% include 'BJJournal/BJR_addSession/BJR_addSession_Techniques.html' %}
+
+ {# DATE #}
-
-
-
+
-
-
+
-
-
Date
-
-
+
+
Date
+
+
-
- Today
- Yesterday
-
+
+ Today
+ Yesterday
+
+
-
-
-
-
Time
-
+
+
Time
+
-
- 6:00
- 9:00
- 12:00
- 18:00
- 20:00
-
+
+ 6:00
+ 9:00
+ 12:00
+ 18:00
+ 20:00
+
-
+
-
+
-
-
- 1h
-
-
- 5min
-
-
- 15min
-
+
+
+ 1h
+
+
+ 5min
+
+
+ 15min
+
-
- 1h
+
+ 1h
+
-
+
-
+
-
-
-
-
-
+
+
+
+
-
-
+
-
+
-
+
- {% include 'BJJournal/BJR_addSession/BJR_addSession_sessionLength.html' %}
+ {% include 'BJJournal/BJR_addSession/BJR_addSession_sessionLength.html' %}
-
-
-
-
+
-
+
-
+
{% endblock %}
\ No newline at end of file
diff --git a/WorkoutJournal/templates/BJJournal/BJR_dashboard_count.html b/WorkoutJournal/templates/BJJournal/BJR_dashboard_count.html
index 07b4602..7638c75 100644
--- a/WorkoutJournal/templates/BJJournal/BJR_dashboard_count.html
+++ b/WorkoutJournal/templates/BJJournal/BJR_dashboard_count.html
@@ -2,7 +2,7 @@