Coverage report: - 90% + 89%
@@ -65,11 +65,11 @@
coverage.py v4.5.2, - created at 2019-01-14 23:19 + created at 2019-01-16 23:14
diff --git a/.coverage b/.coverage index a41b5c3..4c472ec 100644 --- a/.coverage +++ b/.coverage @@ -1 +1 @@ -!coverage.py: This is a private format, don't read it directly!{"lines":{"/mnt/d/Dev/Applications/timelaps_api/manage.py":[2,3,5,6,7,8,22],"/mnt/d/Dev/Applications/timelaps_api/api/__init__.py":[1],"/mnt/d/Dev/Applications/timelaps_api/api/settings.py":[11,13,16,23,26,28,34,35,36,37,38,39,40,41,45,46,47,48,49,50,51,54,58,59,60,62,63,64,65,66,72,79,80,81,82,83,84,85,95,98,101,104,112,114,116,118,120,126],"/mnt/d/Dev/Applications/timelaps_api/timelaps/__init__.py":[1],"/mnt/d/Dev/Applications/timelaps_api/timelaps/models.py":[2,4,8,10,12,16,18,19,21,24,26,28,30,32,34,36,38,40,41,43,45,47,49,52,54,55,56,57,60,62,64,66,68,70,72],"/mnt/d/Dev/Applications/timelaps_api/timelaps/admin.py":[2,4,5,9,10,11,12,13,14],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/__init__.py":[1],"/mnt/d/Dev/Applications/timelaps_api/timelaps/tests.py":[2,4,7,8,9,10,11,48],"/mnt/d/Dev/Applications/timelaps_api/timelaps/serializers.py":[1,2,4,5,6,7,9,10,11,12,14,15,16,17,19,20,21,22,24,25,26,27,29,30,31,32,34,35,36,38,42],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/0001_initial.py":[3,4,7,9,11,15,16,18,19,20,23,24,26,27,28,29,30,31,34,35,37,38,39,40,41,42,45,46,48,49,50,51,52,53,56,57,59,60,63,64,66,67,68,69,72,73,74,75,77,78,79,80],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/0005_auto_20190112_0907.py":[3,6,9,13,14,15,16],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/0008_auto_20190112_0934.py":[3,4,7,10,14,15,16,18,19,20,21,22],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/0006_auto_20190112_0912.py":[3,6,9,13,14,15,16,18,19,20,21,23,24,25,26],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/0009_auto_20190112_0938.py":[3,6,9,13,14,15,16,18,19,20,21,23,24,25,26,28,29,30,31],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/0011_auto_20190112_1017.py":[3,6,9,13,14,15,16],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/0012_auto_20190112_1019.py":[3,6,9,13,14,15,16,18,19,20,21,23,24,25,26,28,29,30,31,33,34,35,36,38,39,40,41,43,44,45,46,48,49,50,51,53,54,55,56,58,59,60,61,63,64,65,66,68,69,70,71,73,74,75,76,78,79,80,81],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/0002_auto_20190112_0858.py":[3,6,9,13,14,15],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/0003_auto_20190112_0903.py":[3,4,7,10,14,15,16,18,19,20,21,22,24,25,26,27],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/0007_auto_20190112_0930.py":[3,6,9,13,14,15,16,18,19,20,22,23,24,25],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/0004_auto_20190112_0906.py":[3,6,9,13,14,15,16],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/0010_auto_20190112_1005.py":[3,6,9,13,14,15,16,18,19,20,21,23,24,25,26],"/mnt/d/Dev/Applications/timelaps_api/api/urls.py":[15,16,17,18,19,20,24,25],"/mnt/d/Dev/Applications/timelaps_api/timelaps/urls.py":[1,2,3,6,7,8,9,10,11,12],"/mnt/d/Dev/Applications/timelaps_api/timelaps/views.py":[2,4,5,6,7,12,15,16,17,19,22,23,24,26,29,30,31,33,36,37,38,40,43,44,45,47,50,51,52,54,58,59,60,61,63],"/mnt/d/Dev/Applications/timelaps_api/api/wsgi.py":[],"/mnt/d/Dev/Applications/timelaps_api/timelaps/apps.py":[]}} \ No newline at end of file +!coverage.py: This is a private format, don't read it directly!{"lines":{"/mnt/d/Dev/Applications/timelaps_api/manage.py":[2,3,5,6,7,8,22],"/mnt/d/Dev/Applications/timelaps_api/api/__init__.py":[1],"/mnt/d/Dev/Applications/timelaps_api/api/settings.py":[11,13,16,23,26,28,34,35,36,37,38,39,40,41,45,46,47,48,49,50,51,54,58,59,60,62,63,64,65,66,72,79,80,81,82,83,84,85,95,98,101,104,112,114,116,118,120,126],"/mnt/d/Dev/Applications/timelaps_api/timelaps/__init__.py":[1],"/mnt/d/Dev/Applications/timelaps_api/timelaps/models.py":[2,4,8,10,11,13,17,19,20,22,25,27,29,31,33,35,37,39,41,42,44,46,48,50,53,55,56,57,58,61,63,65,67,69,71,73],"/mnt/d/Dev/Applications/timelaps_api/timelaps/admin.py":[2,4,5,9,10,11,12,13,14],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/__init__.py":[1],"/mnt/d/Dev/Applications/timelaps_api/timelaps/tests.py":[2,4,7,8,9,10,11,48],"/mnt/d/Dev/Applications/timelaps_api/timelaps/serializers.py":[1,2,4,5,6,7,9,10,11,12,14,15,16,17,19,20,21,22,24,25,26,27,29,30,31,32,34,35,36,37,38,40,41,42,43,44],"/mnt/d/Dev/Applications/timelaps_api/timelaps/migrations/0001_initial.py":[3,4,7,9,11,15,16,18,19,20,23,24,26,27,28,31,32,34,35,36,37,38,39,42,43,45,46,47,48,49,50,51,54,55,57,58,59,60,61,62,65,66,68,69,70,73,74,75,76,78,79,80,81,83,84,85,86],"/mnt/d/Dev/Applications/timelaps_api/api/urls.py":[15,16,17,18,19,20,24,25],"/mnt/d/Dev/Applications/timelaps_api/timelaps/urls.py":[1,2,3,6,7,8,9,10,11,12],"/mnt/d/Dev/Applications/timelaps_api/timelaps/views.py":[2,4,5,6,7,12,15,16,17,19,20,21,23,24,25,27,28,29,31,32,33,35,36,37,39,40,41,63],"/mnt/d/Dev/Applications/timelaps_api/api/wsgi.py":[],"/mnt/d/Dev/Applications/timelaps_api/timelaps/apps.py":[]}} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bbd47eb --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +.coverage diff --git a/api/settings.pyc b/api/settings.pyc index 37744db..4a77856 100644 Binary files a/api/settings.pyc and b/api/settings.pyc differ diff --git a/htmlcov/index.html b/htmlcov/index.html index bfa02a7..65b5f9b 100644 --- a/htmlcov/index.html +++ b/htmlcov/index.html @@ -22,7 +22,7 @@
@@ -65,11 +65,11 @@
coverage.py v4.5.2, - created at 2019-01-14 23:19 + created at 2019-01-16 23:14
« index coverage.py v4.5.2, - created at 2019-01-14 23:19 + created at 2019-01-16 23:08
# Generated by Django 2.1.5 on 2019-01-12 08:54
+# Generated by Django 2.1.5 on 2019-01-15 23:31
@@ -170,70 +176,76 @@
name='Driver',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-('first_name', models.CharField(max_length=30)),
-('last_name', models.CharField(max_length=30)),
+('first_name', models.CharField(blank=True, default=None, max_length=30, null=True)),
+('last_name', models.CharField(blank=True, default=None, max_length=30, null=True)),
],
),
migrations.CreateModel(
-name='Race',
+name='EngagedPilot',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-('name', models.CharField(max_length=30)),
-('start_date', models.DateField()),
-('end_date', models.DateField(null=True)),
-('duration', models.IntegerField()),
-('comment', models.CharField(max_length=256)),
-],
-),
-migrations.CreateModel(
-name='Relay',
-fields=[
-('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-('relay_start', models.DateField()),
-('relay_end', models.DateField(null=True)),
-('has_refuel', models.BooleanField(default=False)),
-('pilot_chrono', models.IntegerField(null=True)),
-('comment', models.CharField(max_length=256, null=True)),
-],
-),
-migrations.CreateModel(
-name='Rule',
-fields=[
-('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-('min_stand_duration', models.IntegerField()),
-('max_autonomy_dry', models.IntegerField()),
-('max_autonomy_wet', models.IntegerField()),
-('max_driving_duration', models.IntegerField(null=True)),
-('relay_default_duration', models.IntegerField(null=True)),
-],
-),
-migrations.CreateModel(
-name='Team',
-fields=[
-('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-('name', models.CharField(max_length=30)),
-],
-),
-migrations.CreateModel(
-name='TeamPilot',
-fields=[
-('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-('pilot', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='timelaps.Driver')),
-('race', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='timelaps.Race')),
-('team', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='timelaps.Team')),
-],
-),
-migrations.AddField(
-model_name='relay',
-name='team',
-field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='timelaps.Team'),
-),
-migrations.AddField(
-model_name='race',
-name='fk_rules',
-field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='timelaps.Rule'),
-),
-]
+('order', models.IntegerField(blank=True, default=None, null=True)),
+('pilot', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pilot', to='timelaps.Driver')),
+],
+),
+migrations.CreateModel(
+name='Race',
+fields=[
+('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+('name', models.CharField(blank=True, default=None, max_length=30, null=True)),
+('start_date', models.DateTimeField(blank=True, default=None, null=True)),
+('end_date', models.DateTimeField(blank=True, default=None, null=True)),
+('duration', models.IntegerField()),
+('comment', models.CharField(blank=True, default=None, max_length=256, null=True)),
+],
+),
+migrations.CreateModel(
+name='Relay',
+fields=[
+('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+('relay_start', models.DateTimeField()),
+('relay_end', models.DateTimeField(blank=True, default=None, null=True)),
+('has_refuel', models.BooleanField(default=False)),
+('pilot_chrono', models.IntegerField(blank=True, default=None, null=True)),
+('comment', models.CharField(blank=True, default=None, max_length=256, null=True)),
+('team_pilot', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='relays', to='timelaps.EngagedPilot')),
+],
+),
+migrations.CreateModel(
+name='Rules',
+fields=[
+('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+('min_stand_duration', models.IntegerField(blank=True, default=None, null=True)),
+('max_autonomy_dry', models.IntegerField()),
+('max_autonomy_wet', models.IntegerField()),
+('max_driving_duration', models.IntegerField(blank=True, default=None, null=True)),
+('relay_default_duration', models.IntegerField(blank=True, default=None, null=True)),
+],
+),
+migrations.CreateModel(
+name='Team',
+fields=[
+('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+('name', models.CharField(blank=True, default=None, max_length=30, null=True)),
+('comment', models.CharField(blank=True, default=None, max_length=256, null=True)),
+],
+),
+migrations.AddField(
+model_name='race',
+name='fk_rules',
+field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='timelaps.Rules'),
+),
+migrations.AddField(
+model_name='engagedpilot',
+name='race',
+field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='race', to='timelaps.Race'),
+),
+migrations.AddField(
+model_name='engagedpilot',
+name='team',
+field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='team', to='timelaps.Team'),
+),
+]
« index coverage.py v4.5.2, - created at 2019-01-14 23:19 + created at 2019-01-16 23:08
# Name of the team
-- -
return self.name
-+ +
+ +
return self.name
- -
# Name of the pilot
- - -- -
return self.last_name
-- -
#Minimum time in the pitlane
- -#Maximum autonomy of the kart in dry condition (In seconds)
- -#Maximum autonomy of the kart in wet condition (In seconds)
- -#Maximum driving time by driver(In seconds)
- -#Start and end date of the race
- -- -
# Name of the race
- -#Start and end date of the race
- - -#Lenth of th race in seconds
- -#Link to the rules of the race
- -#Comment the race
- -- -
return self.name
-- -
# Foreign keys to the team pilot and race
- - - - -+
+ +
# Name of the pilot
+ + ++ +
return self.last_name
++ +
#Minimum time in the pitlane
+ +#Maximum autonomy of the kart in dry condition (In seconds)
+ +#Maximum autonomy of the kart in wet condition (In seconds)
+ +#Maximum driving time by driver(In seconds)
+ +#Start and end date of the race
+ ++ +
# Name of the race
+ +#Start and end date of the race
+ + +#Lenth of th race in seconds
+ +#Link to the rules of the race
+ +#Comment the race
+ ++ +
return self.name
++ +
# Foreign keys to the team pilot and race
+ + + +- -
# Name of the team
- -#Starting timestamp for the relay
- -#ending timestamp for the relay
- -#Does the pilot did refuel
- -#Average chrono for the pulot on this relay
- -#comment the relay
- ++ +
# Name of the team
+ +#Starting timestamp for the relay
+ +#ending timestamp for the relay
+ +#Does the pilot did refuel
+ +#Average chrono for the pulot on this relay
+ +#comment the relay
+« index coverage.py v4.5.2, - created at 2019-01-14 23:19 + created at 2019-01-16 23:08
- +
- +
- +
- +
- + - - + +
- - - -
#fields = ('relay_start','relay_end','has_refuel','pilot_chrono','comment','team_pilot','race')
- -'''
-To get linked elements référenced by a foreign key, use depth to adjust the depth of the request.
-'''
- -+ + + + + +
+ + + + + +
« index coverage.py v4.5.2, - created at 2019-01-14 23:19 + created at 2019-01-16 23:08
path('relays/', ListRelayView.as_view()),
path('rules/', ListRulesView.as_view()),
path('teams/', ListTeamView.as_view()),
-path('teampilots/', ListTeamPilotView.as_view()),
-url('race/(?P<raceid>\d+)/team/(?P<teamid>\d+)/relays', ListRelaysByRaceView.as_view()),
+path('engagedpilots/', ListEngagedPilotView.as_view()),
+url('race/(?P<raceid>\d+)', ListRelaysByRaceAndTeamView.as_view()),
]
@@ -106,7 +106,7 @@« index coverage.py v4.5.2, - created at 2019-01-14 23:19 + created at 2019-01-16 23:08
-
"""
-Provides a get method handler.
-"""
- - -- -
"""
-Provides a get method handler.
-"""
- - -- -
"""
-Provides a get method handler.
-"""
- - -- -
"""
-Provides a get method handler.
-"""
- - -- -
"""
-Provides a get method handler.
-"""
- - -- -
'''
-Getting the params from the url with the "self.kwargs.get"
-and filter with thoses in the relays relation
-'''
- - - -- -
raceid = self.kwargs.get(self.lookup_url_raceid)
-teamid = self.kwargs.get(self.lookup_url_teamid)
-relays = Relay.objects.filter(team_pilot__team=teamid).filter(team_pilot__race=raceid)
-return relays
+ + ++ + + +
+ + + +
+ + + +
+ + + +
+ + + +
raceid = self.kwargs['raceid']
+return Race.objects.filter(id=raceid)
++ +
def get_queryset(self):
+raceid = self.kwargs['raceid']
+teamid = self.kwargs['teamid']
+return Relay.objects.filter(team_pilot__team=teamid).filter(team_pilot__race=raceid)
++
class ListRelaysByRaceAndTeamView(generics.ListAPIView):
+#Getting the params from the url with the "self.kwargs.get"
+#and filter with thoses in the relays relation
+serializer_class = RelayPilotSerializer
+lookup_url_raceid = "raceid"
+lookup_url_teamid = "teamid"
++
def get_queryset(self):
+raceid = self.kwargs.get(self.lookup_url_raceid)
+teamid = self.kwargs.get(self.lookup_url_teamid)
+relays = Relay.objects.filter(team_pilot__team=teamid).filter(team_pilot__race=raceid)
+return relays
+"""
« index coverage.py v4.5.2, - created at 2019-01-14 23:19 + created at 2019-01-16 23:08