From b5a133a3c2f3e963a59a7d433fa88a228012d5f0 Mon Sep 17 00:00:00 2001 From: "Claudio Maggioni (maggicl)" Date: Wed, 7 Aug 2019 12:44:12 +0200 Subject: [PATCH] Added models to score app --- score/__init__.py | 0 score/admin.py | 5 ++++ score/apps.py | 5 ++++ score/migrations/__init__.py | 0 score/models.py | 41 ++++++++++++++++++++++++++++ score/static/img/WA_target.svg | 49 ++++++++++++++++++++++++++++++++++ score/tests.py | 3 +++ score/views.py | 3 +++ 8 files changed, 106 insertions(+) create mode 100644 score/__init__.py create mode 100644 score/admin.py create mode 100644 score/apps.py create mode 100644 score/migrations/__init__.py create mode 100644 score/models.py create mode 100644 score/static/img/WA_target.svg create mode 100644 score/tests.py create mode 100644 score/views.py diff --git a/score/__init__.py b/score/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/score/admin.py b/score/admin.py new file mode 100644 index 0000000..fee2095 --- /dev/null +++ b/score/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin +from .models import Score, ScoreRow + +admin.site.register(Score) +admin.site.register(ScoreRow) diff --git a/score/apps.py b/score/apps.py new file mode 100644 index 0000000..b24f61e --- /dev/null +++ b/score/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ScoreConfig(AppConfig): + name = 'score' diff --git a/score/migrations/__init__.py b/score/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/score/models.py b/score/models.py new file mode 100644 index 0000000..8c09f0b --- /dev/null +++ b/score/models.py @@ -0,0 +1,41 @@ +from django.db import models +from django.conf import settings +from django.contrib.auth.models import User +from django.utils.translation import gettext_lazy as _ +from django.core.validators import RegexValidator, MaxValueValidator, \ + MaxLengthValidator + + +class Score(models.Model): + TARGETS = [ + ('TR', _('40/60/80/120cm Target')), + ('HF', _('H&F target')) + ] + + user = models.ForeignKey( + settings.AUTH_USER_MODEL, + on_delete=models.CASCADE + ) + ends = models.PositiveSmallIntegerField(_('Number of ends in this score'), + validators=[MaxValueValidator(24)]) + arrows_per_end = models.PositiveSmallIntegerField( + _('Number of arrows per end'), validators=[MaxValueValidator(12)]) + date = models.DateField(_('Date of the score')) + notes = models.TextField(_('Additional notes'), + validators=[MaxLengthValidator(500)]) + target = models.CharField(_('Type of target'), max_length=2, + choices=TARGETS) + + +class ScoreRow(models.Model): + class Meta: + unique_togheter = ('score', 'end_number') + + score = models.ForeignKey(Score, on_delete=models.CASCADE) + arrow_list = models.CharField(_('Comma separated list of arrow scores'), + max_length=36, + validators=[RegexValidator(regex="^(\d|10)(,(\d|10)){2,11}$", + message=_("Value given is not a valid score row"))]) + end_number = models.PositiveSmallIntegerField(_('End number'), + validators=[MaxValueValidator(24)]) + diff --git a/score/static/img/WA_target.svg b/score/static/img/WA_target.svg new file mode 100644 index 0000000..edaec6a --- /dev/null +++ b/score/static/img/WA_target.svg @@ -0,0 +1,49 @@ + + + + + + image/svg+xml + + Official FITA 80cm Archery Target + 2006-06-01 + + + Alberto Barbati + + + + + + archery target + + + An official FITA 80cm archery target. +Real colors are: +Yellow: Pantone 107U +Red: Pantone 032U +Light blue: Pantone 306U + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/score/tests.py b/score/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/score/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/score/views.py b/score/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/score/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here.