Private
Public Access
1
0

it's a start

This commit is contained in:
Sander Roosendaal
2019-02-14 17:45:19 +01:00
parent e70bd6a627
commit 95afb04dd2
2 changed files with 94 additions and 25 deletions

View File

@@ -30,7 +30,7 @@ from django.utils import timezone
import pandas as pd
from dateutil import parser
import datetime
from django.core.exceptions import ValidationError
from rowers.rows import validate_file_extension
from collections import OrderedDict
from timezonefinder import TimezoneFinder
@@ -313,6 +313,13 @@ class C2WorldClassAgePerformance(models.Model):
return thestring
def is_not_basic(user):
if user.rower.rowerplan == 'basic':
raise ValidationError(
"Basic user cannot be team manager"
)
# For future Team functionality
class Team(models.Model):
choices = (
@@ -327,7 +334,7 @@ class Team(models.Model):
name = models.CharField(max_length=150,unique=True,verbose_name='Team Name')
notes = models.CharField(blank=True,max_length=200,verbose_name='Team Purpose')
manager = models.ForeignKey(User, null=True)
manager = models.ForeignKey(User, null=True, validators=[is_not_basic])
private = models.CharField(max_length=30,choices=choices,default='open',
verbose_name='Team Type')

View File

@@ -1,40 +1,102 @@
from statements import *
from django.utils import timezone
nu = datetime.datetime.now(tz=timezone.utc)
# set up
## Users - Pro, Basic, Coach & Self Coach
import rowers.teams as teams
import rowers.plannedsessions as plannedsessions
## Couple of workouts
## TeamPro, TeamCoach, TeamSelfCoach
@override_settings(TESTING=True)
class PermissionsBasicsTests(TestCase):
def setUp:
self.c = Client()
## Users - Pro, Basic, Coach & Self Coach
# Requirements
self.ucoach = UserFactory(username='coachuser')
self.rcoach = Rower.objects.create(user=self.ucoach,
birthdate=faker.profile()['birthdate'],
gdproptin=True,gdproptindate=timezone.now(),
rowerplan='coach')
## Low level
self.ucoach_workouts = WorkoutFactory.create_batch(5, user=self.rcoach)
self.factory = RequestFactory()
self.password = faker.word()
self.ucoach.set_password(self.password)
self.ucoach.save()
self.uplan = UserFactory(username='planuser')
self.rplan = Rower.objects.create(user=self.uplan,
birthdate=faker.profile()['birthdate'],
gdproptin=True,gdproptindate=timezone.now(),
rowerplan='plan')
## Coach can have any number of groups
self.uselfplan_workouts = WorkoutFactory.create_batch(5, user=self.rselfplan)
self.factory = RequestFactory()
self.password = faker.word()
self.uselfplan.set_password(self.password)
self.uselfplan.save()
self.upro = UserFactory(username='prouser')
self.rpro = Rower.objects.create(user=self.upro,
birthdate=faker.profile()['birthdate'],
gdproptin=True,gdproptindate=timezone.now(),
rowerplan='pro')
## Basic athletes can be member of Coach led group
self.upro_workouts = WorkoutFactory.create_batch(5, user=self.rpro)
self.factory = RequestFactory()
self.password = faker.word()
self.upro.set_password(self.password)
self.upro.save()
## Coach can create planned sessions and team planned sessions
self.ubasic = UserFactory(username='basicuser')
self.rbasic = Rower.objects.create(user=self.ubasic,
birthdate=faker.profile()['birthdate'],
gdproptin=True,gdproptindate=timezone.now(),
rowerplan='basic')
## Self coach can create one group
self.ubasic_workouts = WorkoutFactory.create_batch(5, user=self.rbasic)
self.factory = RequestFactory()
self.password = faker.word()
self.ubasic.set_password(self.password)
self.ubasic.save()
## TeamPro, TeamCoach, TeamSelfCoach
## Self coach cannot create more than one group
# Requirements
## Low level
## Coach can have any number of groups
## Basic athletes can be member of Coach led group
## Coach can create planned sessions and team planned sessions
## Self coach can create one group
## Self coach cannot create more than one group
## Pro users (and higher) can join group led by other Pro (or higher) user
## Self Coach can create planned sessions and team planned sessions
## Pro can have one group
## Pro cannot create more than one group
## Pro cannot create planned sessions or team planned sessions
## Basic cannot join groups led by Pro or Self Coach
## Basic can join group led by Coach
## Pro users (and higher) can join group led by other Pro (or higher) user
## Self Coach can create planned sessions and team planned sessions
## Pro can have one group
## Pro cannot create more than one group
## Pro cannot create planned sessions or team planned sessions
## Basic cannot join groups led by Pro or Self Coach
## Basic can join group led by Coach
## Basic cannot manage a group
def test_basic_groupmanager(self):
self.assertRaises ...
# View based