Compare commits

..

No commits in common. "jones-dev" and "main" have entirely different histories.

2487 changed files with 14590 additions and 79260 deletions

5
.gitignore vendored
View File

@ -1,8 +1,3 @@
# Static & media files
staticfiles/
static/CACHE/
media/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

36
.vscode/launch.json vendored
View File

@ -1,19 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/src/manage.py",
"args": ["runserver"],
"django": true,
"justMyCode": true,
"python": "${workspaceFolder}/venv/bin/python" // Linux
// "python": "${workspaceFolder}\\venv\\Scripts\\python", // Windows
}
]
}
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}\\src\\manage.py",
"args": [
"runserver"
],
"django": true,
"justMyCode": true
}
]
}

View File

@ -1,7 +0,0 @@
from django.apps import AppConfig
class ApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.api'
label = "apps_api"

View File

@ -1,28 +0,0 @@
"""Serializers for the API app."""
from rest_framework import serializers
from apps.home import models
class VenueAddressSerializer(serializers.ModelSerializer):
class Meta:
model = models.VenueAddress
exclude = []
class VenueContactsSerializer(serializers.ModelSerializer):
class Meta:
model = models.VenueContacts
exclude = []
class VenueSerializer(serializers.ModelSerializer):
address = VenueAddressSerializer()
contacts = VenueContactsSerializer()
class Meta:
model = models.Venue
exclude = []

View File

@ -1,14 +0,0 @@
"""URLs for the API app."""
from django.urls import path, include
from . import views
app_name = "api"
urlpatterns = [
path("venues/", include([
path("", views.VenueListView.as_view(), name="venues"),
path("<int:pk>/", views.VenueDetailsView.as_view(), name="venue-detail")
]))
]

View File

@ -1,16 +0,0 @@
"""Views for the API app."""
from django.shortcuts import render
from rest_framework import generics
from .serializers import VenueSerializer
from apps.home import models
class VenueListView(generics.ListCreateAPIView):
serializer_class = VenueSerializer
queryset = models.Venue.objects.all().order_by("id")
class VenueDetailsView(generics.RetrieveUpdateDestroyAPIView):
serializer_class = VenueSerializer
queryset = models.Venue.objects.all().order_by("id")

View File

@ -1,60 +0,0 @@
"""Admin models for the home app."""
from django.contrib import admin
from . import models
@admin.register(models.Angler)
class Angler(admin.ModelAdmin):
"""Admin class for the `Angler` model."""
@admin.register(models.AnglerGroup)
class AnglerGroup(admin.ModelAdmin):
"""Admin class for the `AnglerGroup` model."""
@admin.register(models.Waters)
class Waters(admin.ModelAdmin):
"""Admin class for the `Waters` model."""
@admin.register(models.VenueAddress)
class VenueAddress(admin.ModelAdmin):
"""Admin class for the `VenueAddress` model."""
@admin.register(models.VenueContacts)
class VenueContacts(admin.ModelAdmin):
"""Admin class for the `VenueContacts` model."""
@admin.register(models.Venue)
class Venue(admin.ModelAdmin):
"""Admin class for the `Venue` model."""
@admin.register(models.Match)
class Match(admin.ModelAdmin):
"""Admin class for the `Match` model."""
@admin.register(models.LeagueRule)
class LeagueRule(admin.ModelAdmin):
"""Admin class for the `LeagueRule` model."""
@admin.register(models.League)
class League(admin.ModelAdmin):
"""Admin class for the `League` model."""
@admin.register(models.Sponsor)
class Sponsor(admin.ModelAdmin):
"""Admin class for the `Sponsor` model."""
@admin.register(models.LeagueResult)
class LeagueResult(admin.ModelAdmin):
"""Admin class for the `LeagueResult` model."""

View File

@ -1,218 +0,0 @@
[
{
"model": "apps_home.angler",
"pk": 1,
"fields": {
"name": "William Howard",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 2,
"fields": {
"name": "Thomas Henderson",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 3,
"fields": {
"name": "David Robertson",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 4,
"fields": {
"name": "Charles Willis",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 5,
"fields": {
"name": "Richard Moore",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 6,
"fields": {
"name": "James Andrews",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 7,
"fields": {
"name": "Christopher Pines",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 8,
"fields": {
"name": "Darren Boyd",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 9,
"fields": {
"name": "Jenson Hammond",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 10,
"fields": {
"name": "Dylan Berry",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 11,
"fields": {
"name": "Tori Wright",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 12,
"fields": {
"name": "Rahul Finch",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 13,
"fields": {
"name": "Gary Whitney",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 14,
"fields": {
"name": "Martin Sanford",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 15,
"fields": {
"name": "Kyle Bird",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 16,
"fields": {
"name": "Edward Brandt",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 17,
"fields": {
"name": "Layton Holt",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 18,
"fields": {
"name": "Adam Hayes",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 19,
"fields": {
"name": "Leo Duran",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 20,
"fields": {
"name": "Noah Sims",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 21,
"fields": {
"name": "Louis Holloway",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 22,
"fields": {
"name": "Sean Foster",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 23,
"fields": {
"name": "Josh Lambert",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 24,
"fields": {
"name": "Evan Bass",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 25,
"fields": {
"name": "Marcus Brooke",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 26,
"fields": {
"name": "Cory Cohen",
"redact": false
}
},
{
"model": "apps_home.angler",
"pk": 27,
"fields": {
"name": "Nadia Graves",
"redact": false
}
}
]

View File

@ -1,84 +0,0 @@
[
{
"model": "apps_home.venueaddress",
"pk": 1,
"fields": {
"street_number": null,
"street_address": "Shrewley Common",
"town": "Warwick",
"provence": "Warwickshire",
"post_code": "CV327AN",
"satnav_post_code": null,
"country": "United Kingdom",
"latitude": null,
"longitude": null
}
},
{
"model": "apps_home.venuecontacts",
"pk": 1,
"fields": {
"phone_number": "07795546160",
"email_address": "admin@tbftackle.com",
"website_url": "http://www.tunnelbarnfarm.co.uk/",
"facebook_url": "https://facebook.com/TunnelBarnFarm",
"twitter_url": "https://twitter.com/TunnelBarnFarm",
"instagram_url": "https://instagram.com/tunnel_barn_farm_fishery"
}
},
{
"model": "apps_home.venue",
"pk": 1,
"fields": {
"name": "Tunnel Barn Farm",
"description": "Located in the picturesque village of Shrewley in Warwickshire, Tunnel Barn Farm is the Midlands' premier fishery, with its own onsite Tackle Shop, offering day tickets for pleasure fishermen, daily competitions for match anglers (including and Over 50s and Veterans club) and hosting club matches all year round. We have 9 unique pools that range in size and style and that are stoc",
"extra_notes": null,
"created_at": "2024-11-05T18:49:53.317Z",
"updated_at": "2024-11-05T18:49:53.318Z",
"profile_picture": "",
"banner_picture": "",
"type": 2,
"address": 1,
"contacts": 1
}
},
{
"model": "apps_home.waters",
"pk": 1,
"fields": {
"name": "Canal Pool",
"pegs_from": 1,
"pegs_to": 24,
"map": "",
"venue": 1,
"type": 0,
"fish_types": 0
}
},
{
"model": "apps_home.waters",
"pk": 2,
"fields": {
"name": "Jennys Pool",
"pegs_from": 1,
"pegs_to": 27,
"map": "",
"venue": 1,
"type": 0,
"fish_types": 0
}
},
{
"model": "apps_home.waters",
"pk": 3,
"fields": {
"name": "New Pool",
"pegs_from": 1,
"pegs_to": 44,
"map": "",
"venue": 1,
"type": 0,
"fish_types": 0
}
}
]

View File

@ -1,231 +0,0 @@
# Generated by Django 5.0.6 on 2024-11-05 12:49
import django.db.models.deletion
import django.utils.timezone
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Angler',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=128)),
('redact', models.BooleanField()),
],
options={
'verbose_name': 'angler',
'verbose_name_plural': 'anglers',
},
),
migrations.CreateModel(
name='LeagueRule',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=128)),
('ranking_system', models.PositiveSmallIntegerField(choices=[(0, 'choice 1'), (1, 'choice 2'), (2, 'choice 3')])),
('points_allocation', models.PositiveSmallIntegerField(choices=[(0, 'choice 1'), (1, 'choice 2'), (2, 'choice 3')])),
('points_awarded', models.PositiveSmallIntegerField(choices=[(0, 'choice 1'), (1, 'choice 2'), (2, 'choice 3')])),
('place_secondly_by_weight', models.BooleanField()),
('team_places_secondly_by_section', models.BooleanField()),
('section_placed_positions', models.IntegerField()),
('worst_place_limits', models.BooleanField()),
('attendance_points', models.IntegerField()),
('did_not_weigh', models.PositiveSmallIntegerField(choices=[(0, 'choice 1'), (1, 'choice 2'), (2, 'choice 3')])),
('did_not_weigh_value', models.IntegerField()),
('left_early', models.PositiveSmallIntegerField(choices=[(0, 'choice 1'), (1, 'choice 2'), (2, 'choice 3')])),
('left_early_value', models.IntegerField()),
('did_not_book', models.IntegerField()),
('disqualification', models.PositiveSmallIntegerField(choices=[(0, 'choice 1'), (1, 'choice 2'), (2, 'choice 3')])),
('disqualification_value', models.IntegerField()),
('best_league_sessions', models.IntegerField()),
('worst_league_sessions', models.IntegerField()),
('match_placed_positions', models.IntegerField()),
],
options={
'verbose_name': 'league rule',
'verbose_name_plural': 'league rules',
},
),
migrations.CreateModel(
name='Match',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=128)),
('description', models.CharField(max_length=384)),
('meeting_point', models.CharField(max_length=1024)),
('use_metric', models.BooleanField()),
('allow_in_tournaments', models.BooleanField()),
('start_datetime', models.DateTimeField()),
('end_datetime', models.DateTimeField()),
('draw_datetime', models.DateTimeField()),
('type', models.PositiveSmallIntegerField(choices=[(0, 'choice 1'), (1, 'choice 2'), (2, 'choice 3')])),
('competitor_type', models.PositiveSmallIntegerField(choices=[(0, 'choice 1'), (1, 'choice 2'), (2, 'choice 3')])),
],
options={
'verbose_name': 'match',
'verbose_name_plural': 'matches',
},
),
migrations.CreateModel(
name='Sponsor',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=128)),
('url', models.URLField()),
('image', models.ImageField(upload_to='')),
],
options={
'verbose_name': 'sponsor',
'verbose_name_plural': 'sponsors',
},
),
migrations.CreateModel(
name='Venue',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=128)),
('description', models.CharField(max_length=384)),
('extra_notes', models.CharField(max_length=1028)),
('created_at', models.DateTimeField(default=django.utils.timezone.now, editable=False)),
('updated_at', models.DateTimeField(default=django.utils.timezone.now, editable=False)),
('profile_picture', models.ImageField(upload_to='')),
('banner_picture', models.ImageField(upload_to='')),
('type', models.PositiveSmallIntegerField(choices=[(0, 'Fishery'), (1, 'Club'), (2, 'Private')])),
],
options={
'verbose_name': 'venue',
'verbose_name_plural': 'venues',
},
),
migrations.CreateModel(
name='VenueAddress',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('street_number', models.IntegerField()),
('street_address', models.CharField(max_length=256)),
('town', models.CharField(max_length=256)),
('county', models.CharField(max_length=256)),
('post_code', models.CharField(max_length=32)),
('satnav_post_code', models.CharField(max_length=32)),
('country', models.CharField(max_length=128)),
('latitude', models.DecimalField(decimal_places=16, max_digits=22)),
('longitude', models.DecimalField(decimal_places=16, max_digits=22)),
],
options={
'verbose_name': 'venue address',
'verbose_name_plural': 'venue addresses',
},
),
migrations.CreateModel(
name='VenueContacts',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('phone_number', models.CharField(max_length=64)),
('email_address', models.EmailField(max_length=254)),
('website_url', models.URLField()),
('facebook_url', models.URLField()),
('twitter_url', models.URLField()),
('instagram_url', models.URLField()),
],
options={
'verbose_name': 'venue contacts',
'verbose_name_plural': 'venue contacts',
},
),
migrations.CreateModel(
name='Waters',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=128)),
('pegs_from', models.IntegerField()),
('pegs_to', models.IntegerField()),
('map', models.ImageField(upload_to='')),
('type', models.PositiveSmallIntegerField(choices=[(0, 'Commercial Water'), (1, 'Natural Still Water'), (2, 'Canal'), (3, 'River'), (4, 'Loch')])),
('fish_types', models.PositiveSmallIntegerField(choices=[(0, 'Coarse'), (1, 'Specimen Carp'), (2, 'Game'), (3, 'Predator')])),
],
options={
'verbose_name': 'waters',
'verbose_name_plural': 'waters',
},
),
migrations.CreateModel(
name='AnglerGroup',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=128)),
('type', models.PositiveSmallIntegerField(choices=[(0, 'choice 1'), (1, 'choice 2'), (2, 'choice 3')])),
('anglers', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='apps_home.angler')),
],
options={
'verbose_name': 'angler group',
'verbose_name_plural': 'angler groups',
},
),
migrations.CreateModel(
name='League',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=128)),
('description', models.CharField(max_length=384)),
('extra_notes', models.CharField(max_length=1028)),
('profile_picture', models.ImageField(upload_to='')),
('banner_picture', models.ImageField(upload_to='')),
('anglers', models.ManyToManyField(to='apps_home.angler')),
('rules', models.ManyToManyField(to='apps_home.leaguerule')),
('matches', models.ManyToManyField(to='apps_home.match')),
],
options={
'verbose_name': 'league',
'verbose_name_plural': 'leagues',
},
),
migrations.CreateModel(
name='LeagueResult',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('total_weight', models.CharField(max_length=64)),
('matches', models.IntegerField()),
('date', models.DateField(default=django.utils.timezone.now)),
('angler', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='apps_home.angler')),
('league', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='apps_home.league')),
('sponsor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='apps_home.sponsor')),
],
options={
'verbose_name': 'league result',
'verbose_name_plural': 'league results',
},
),
migrations.AddField(
model_name='match',
name='venue',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='apps_home.venue'),
),
migrations.AddField(
model_name='venue',
name='address',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='apps_home.venueaddress'),
),
migrations.AddField(
model_name='venue',
name='contacts',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='apps_home.venuecontacts'),
),
migrations.AddField(
model_name='venue',
name='waters',
field=models.ManyToManyField(to='apps_home.waters'),
),
migrations.AddField(
model_name='match',
name='waters',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='apps_home.waters'),
),
]

View File

@ -1,28 +0,0 @@
# Generated by Django 5.0.6 on 2024-11-05 13:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('apps_home', '0001_initial'),
]
operations = [
migrations.RenameField(
model_name='venueaddress',
old_name='county',
new_name='provence',
),
migrations.AlterField(
model_name='venueaddress',
name='latitude',
field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True),
),
migrations.AlterField(
model_name='venueaddress',
name='longitude',
field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True),
),
]

View File

@ -1,34 +0,0 @@
# Generated by Django 5.0.6 on 2024-11-05 17:05
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('apps_home', '0002_rename_county_venueaddress_provence_and_more'),
]
operations = [
migrations.RemoveField(
model_name='venue',
name='waters',
),
migrations.AddField(
model_name='waters',
name='venue',
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='apps_home.venue'),
preserve_default=False,
),
migrations.AlterField(
model_name='anglergroup',
name='type',
field=models.PositiveSmallIntegerField(choices=[(0, 'team type 1'), (1, 'team type 2'), (2, 'team type 3')]),
),
migrations.AlterField(
model_name='match',
name='description',
field=models.CharField(max_length=1024),
),
]

View File

@ -1,22 +0,0 @@
# Generated by Django 5.0.6 on 2024-11-05 18:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('apps_home', '0003_remove_venue_waters_waters_venue_and_more'),
]
operations = [
migrations.RemoveField(
model_name='anglergroup',
name='anglers',
),
migrations.AddField(
model_name='anglergroup',
name='anglers',
field=models.ManyToManyField(to='apps_home.angler'),
),
]

View File

@ -1,43 +0,0 @@
# Generated by Django 5.0.6 on 2024-11-05 18:39
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('apps_home', '0004_remove_anglergroup_anglers_anglergroup_anglers'),
]
operations = [
migrations.AlterField(
model_name='venuecontacts',
name='email_address',
field=models.EmailField(blank=True, max_length=254, null=True),
),
migrations.AlterField(
model_name='venuecontacts',
name='facebook_url',
field=models.URLField(blank=True, null=True),
),
migrations.AlterField(
model_name='venuecontacts',
name='instagram_url',
field=models.URLField(blank=True, null=True),
),
migrations.AlterField(
model_name='venuecontacts',
name='phone_number',
field=models.CharField(blank=True, max_length=64, null=True),
),
migrations.AlterField(
model_name='venuecontacts',
name='twitter_url',
field=models.URLField(blank=True, null=True),
),
migrations.AlterField(
model_name='venuecontacts',
name='website_url',
field=models.URLField(blank=True, null=True),
),
]

View File

@ -1,43 +0,0 @@
# Generated by Django 5.0.6 on 2024-11-05 18:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('apps_home', '0005_alter_venuecontacts_email_address_and_more'),
]
operations = [
migrations.AlterField(
model_name='venue',
name='banner_picture',
field=models.ImageField(blank=True, null=True, upload_to=''),
),
migrations.AlterField(
model_name='venue',
name='description',
field=models.CharField(blank=True, max_length=384, null=True),
),
migrations.AlterField(
model_name='venue',
name='extra_notes',
field=models.CharField(blank=True, max_length=1028, null=True),
),
migrations.AlterField(
model_name='venue',
name='profile_picture',
field=models.ImageField(blank=True, null=True, upload_to=''),
),
migrations.AlterField(
model_name='venueaddress',
name='satnav_post_code',
field=models.CharField(blank=True, max_length=32, null=True),
),
migrations.AlterField(
model_name='venueaddress',
name='street_number',
field=models.IntegerField(blank=True, null=True),
),
]

View File

@ -1,75 +0,0 @@
# Generated by Django 5.0.6 on 2024-11-09 21:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('apps_home', '0006_alter_venue_banner_picture_alter_venue_description_and_more'),
]
operations = [
migrations.AddField(
model_name='leaguerule',
name='no_show',
field=models.PositiveSmallIntegerField(choices=[(0, 'Threshold Points'), (1, 'Worst Place Points'), (2, 'Absolute Points'), (3, 'Not Scored')], default=0),
preserve_default=False,
),
migrations.AddField(
model_name='leaguerule',
name='no_show_value',
field=models.IntegerField(default=0),
preserve_default=False,
),
migrations.AlterField(
model_name='anglergroup',
name='type',
field=models.PositiveSmallIntegerField(choices=[(0, 'Set'), (1, 'Team'), (2, 'Pair')]),
),
migrations.AlterField(
model_name='leaguerule',
name='did_not_weigh',
field=models.PositiveSmallIntegerField(choices=[(0, 'Threshold Points'), (1, 'Worst Place Points'), (2, 'Incremental Points'), (2, 'Absolute Points'), (2, 'Not Scored')]),
),
migrations.AlterField(
model_name='leaguerule',
name='disqualification',
field=models.PositiveSmallIntegerField(choices=[(0, 'Threshold Points'), (1, 'Worst Place Points'), (2, 'Incremental Points'), (2, 'Absolute Points'), (2, 'Not Scored')]),
),
migrations.AlterField(
model_name='leaguerule',
name='left_early',
field=models.PositiveSmallIntegerField(choices=[(0, 'Threshold Points'), (1, 'Worst Place Points'), (2, 'Incremental Points'), (2, 'Absolute Points'), (2, 'Not Scored')]),
),
migrations.AlterField(
model_name='leaguerule',
name='points_allocation',
field=models.PositiveSmallIntegerField(choices=[(0, 'First Place Low'), (1, 'First Place High')]),
),
migrations.AlterField(
model_name='leaguerule',
name='points_awarded',
field=models.PositiveSmallIntegerField(choices=[(0, 'Per Section'), (1, 'Per Zone'), (2, 'Per Match')]),
),
migrations.AlterField(
model_name='leaguerule',
name='ranking_system',
field=models.PositiveSmallIntegerField(choices=[(0, 'By Points'), (1, 'By Weight')]),
),
migrations.AlterField(
model_name='match',
name='competitor_type',
field=models.PositiveSmallIntegerField(choices=[(0, 'Individuals'), (1, 'Pairs'), (2, 'Teams')]),
),
migrations.AlterField(
model_name='match',
name='type',
field=models.PositiveSmallIntegerField(choices=[(0, 'Club Match'), (1, 'Open Match'), (2, 'Majors')]),
),
migrations.AlterField(
model_name='waters',
name='map',
field=models.ImageField(blank=True, null=True, upload_to=''),
),
]

View File

@ -1,476 +0,0 @@
"""Models for the mainapp."""
from django.db import models
from django.utils import timezone
# region Anglers & Groups
class Angler(models.Model):
"""A participant of one or more events.
Attributes:
id (int): Automatically incrementing identifier number.
name (str): Full name or label describing the angler.
redact (bool): Determines if the `name` attr should be redacted.
"""
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=128)
redact = models.BooleanField()
class Meta:
verbose_name = "angler"
verbose_name_plural = "anglers"
def __str__(self):
return self.name
class AnglerGroup(models.Model):
"""A group of one or more anglers.
Attributes:
id (int): Automatically incrementing identifier number.
name (str): A human-readable label to identify this group.
anglers (list of `Angler`): The members of this group.
type (int): An enum-like value representing the type of group.
"""
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=128)
anglers = models.ManyToManyField(to=Angler)
class Types:
SET = 0 # Collection of commonly used anglers to aide in their selection for a match or league.
TEAM = 1 # Collection of anglers that acts as a single competing unit in a match or league.
PAIR = 2 # Two anglers that acts as a single competing unit in a match or league.
type = models.PositiveSmallIntegerField(
choices=(
(Types.SET, "Set"),
(Types.TEAM, "Team"),
(Types.PAIR, "Pair")
)
)
class Meta:
verbose_name = "angler group"
verbose_name_plural = "angler groups"
def __str__(self):
return f"{self.name} ({self.anglers.count} anglers)"
# region Venues & Waters
class VenueAddress(models.Model):
id = models.AutoField(primary_key=True)
street_number = models.IntegerField(null=True, blank=True)
street_address = models.CharField(max_length=256)
town = models.CharField(max_length=256)
provence = models.CharField(max_length=256)
post_code = models.CharField(max_length=32)
satnav_post_code = models.CharField(max_length=32, null=True, blank=True)
country = models.CharField(max_length=128)
latitude = models.DecimalField(max_digits=9, decimal_places=6, null=True, blank=True)
longitude = models.DecimalField(max_digits=9, decimal_places=6, null=True, blank=True)
class Meta:
verbose_name = "venue address"
verbose_name_plural = "venue addresses"
def __str__(self):
return f"{self.street_address}, {self.town} ({self.country})"
class VenueContacts(models.Model):
id = models.AutoField(primary_key=True)
phone_number = models.CharField(max_length=64, null=True, blank=True)
email_address = models.EmailField(null=True, blank=True)
website_url = models.URLField(null=True, blank=True)
facebook_url = models.URLField(null=True, blank=True)
twitter_url = models.URLField(null=True, blank=True)
instagram_url = models.URLField(null=True, blank=True)
class Meta:
verbose_name = "venue contacts"
verbose_name_plural = "venue contacts"
def __str__(self):
return self.email_address or str(self.id)
class Venue(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=128)
description = models.CharField(max_length=384, null=True, blank=True)
extra_notes = models.CharField(max_length=1028, null=True, blank=True)
created_at = models.DateTimeField(default=timezone.now, editable=False)
updated_at = models.DateTimeField(default=timezone.now, editable=False)
profile_picture = models.ImageField(null=True, blank=True)
banner_picture = models.ImageField(null=True, blank=True)
class Types:
FISHERY = 0
CLUB = 1
PRIVATE = 2
type = models.PositiveSmallIntegerField(
choices=(
(Types.FISHERY, "Fishery"),
(Types.CLUB, "Club"),
(Types.PRIVATE, "Private")
)
)
address = models.ForeignKey(to=VenueAddress, on_delete=models.CASCADE)
contacts = models.ForeignKey(to=VenueContacts, on_delete=models.CASCADE)
class Meta:
verbose_name = "venue"
verbose_name_plural = "venues"
def __str__(self):
return self.name
def save(self, *args, **kwargs):
self.updated_at = timezone.now()
return super().save(*args, **kwargs)
@property
def waters(self):
"""Returns all waters belonging to this venue."""
return Waters.objects.filter(venue=self)
class Waters(models.Model):
"""A body of water belonging to a particular venue.
Attributes:
id (int): Automatically incrementing identifier number.
name (str): A human-readable label to identify this item.
pegs_from (int): The lowest peg number available.
pegs_to (int): The highest peg number available.
map (file): An image map showing the body of water.
venue (`Venue`): The real world venue where this waters can be found.
type (int): The type of waters represented (canal, river, etc...)
fish_type (int): The fish categories that can be found in this water.
"""
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=128)
pegs_from = models.IntegerField()
pegs_to = models.IntegerField()
map = models.ImageField(null=True, blank=True)
venue = models.ForeignKey(to=Venue, on_delete=models.CASCADE)
class Types:
COMMERCIAL = 0
NATURAL_STILL = 1
CANAL = 2
RIVER = 3
LOCH = 4
type = models.PositiveSmallIntegerField(
choices=(
(Types.COMMERCIAL, "Commercial Water"),
(Types.NATURAL_STILL, "Natural Still Water"),
(Types.CANAL, "Canal"),
(Types.RIVER, "River"),
(Types.LOCH, "Loch")
)
)
class FishTypes:
COARSE = 0
SPECIMEN_CARP = 1
GAME = 2
PREDATOR = 3
fish_types = models.PositiveSmallIntegerField(
choices=(
(FishTypes.COARSE, "Coarse"),
(FishTypes.SPECIMEN_CARP, "Specimen Carp"),
(FishTypes.GAME, "Game"),
(FishTypes.PREDATOR, "Predator")
)
)
class Meta:
verbose_name = "waters"
verbose_name_plural = "waters"
def __str__(self):
return self.name
# region Leagues & Matches
class Match(models.Model):
"""Represents an a fishing event/competition.
Attributes:
id (int): Automatically incrementing identifier number.
name (str): A human-readable label to identify this item.
description (str): A detailed description of the event.
venue (`Venue`): Where this match is hosted.
waters (`Waters`): Which waters will be used in this match, can only use waters from the assigned venue.
meeting_point (str): TODO: what is this for?
use_metric (bool): Should the metric system be used in measurements, imperial is used if `False`.
allow_in_tournaments (bool): Should this match be allowed in tournaments? (TODO: is this correct?)
start_datetime (datetime): When the match will begin.
end_datetime (datetime): When the match will finish.
draw_datetime (datetime): When the draw is made (during the match).
type (int): TODO: match types?
competitor_type (int): TODO what are these?
"""
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=128)
description = models.CharField(max_length=1024)
venue = models.ForeignKey(to=Venue, on_delete=models.CASCADE)
waters = models.ForeignKey(to=Waters, on_delete=models.CASCADE) # can only select waters from the matching venue
meeting_point = models.CharField(max_length=1024)
use_metric = models.BooleanField()
allow_in_tournaments = models.BooleanField()
start_datetime = models.DateTimeField()
end_datetime = models.DateTimeField()
draw_datetime = models.DateTimeField()
TYPES = (
(0, "Club Match"),
(1, "Open Match"),
(2, "Majors")
)
type = models.PositiveSmallIntegerField(choices=TYPES)
# TODO: this might be wrong, maybe should inherit value from related league or league rules
COMPETITOR_TYPES = (
(0, "Individuals"),
(1, "Pairs"),
(2, "Teams")
)
competitor_type = models.PositiveSmallIntegerField(choices=COMPETITOR_TYPES)
class Meta:
verbose_name = "match"
verbose_name_plural = "matches"
def __str__(self):
return self.name
class LeagueRule(models.Model):
"""Rules for leagues.
Rules can be reused against multiple leagues, and aren't strictly owned by
any particular `League` instance.
Attributes:
id (int): Automatically incrementing identifier number.
name (str): A human-readable label to identify this item.
ranking_system (int): TODO
points_allocation (int): Whether people win by having the lowest or heighest points.
points_awarded (int): TODO
place_secondly_by_weight (bool): TODO
team_places_secondly_by_section (bool): TODO
section_placed_positions = (int): TODO
worst_place_limits (bool): TODO
attendance_points (int): TODO
did_not_weigh (int): TODO
did_not_weigh_value (int): TODO
left_early (int): TODO
left_early_value (int): TODO
did_not_book (int): TODO
did_not_book_value (int): TODO
disqualification (int): TODO
disqualification_value (int): TODO
best_league_sessions (int): TODO
worst_league_sessions (int): TODO
match_placed_positions (int): TODO
"""
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=128)
RANKING_SYSTEMS = (
(0, "By Points"),
(1, "By Weight")
)
ranking_system = models.PositiveSmallIntegerField(choices=RANKING_SYSTEMS)
POINTS_ALLOCATIONS = (
(0, "First Place Low"),
(1, "First Place High")
)
points_allocation = models.PositiveSmallIntegerField(choices=POINTS_ALLOCATIONS)
POINTS_AWARDED = (
(0, "Per Section"),
(1, "Per Zone"), # TODO: what is a zone?
(2, "Per Match")
)
points_awarded = models.PositiveSmallIntegerField(choices=POINTS_AWARDED)
# Use fish weight as a fallback for anglers with matching points? Otherwise they get the same placement.
place_secondly_by_weight = models.BooleanField()
# False:
# people at the end have the same amount of points, they both come first
# True:
# two people have same number of points, winner is the section with the highest section placement
team_places_secondly_by_section = models.BooleanField()
# The number of awarded placements per section
section_placed_positions = models.IntegerField() # max: 200, min: 0
# TODO: waiting on james to ask kelly for clarification on this.
worst_place_limits = models.BooleanField()
# Number of points adjusted for attending a match:
# if points allocation == 0: adjusted = deducted
# if points allocation == 1: adjusted = added
attendance_points = models.IntegerField() # max: 20, min: 0
# Impact on points if an angler hasn't weighed his fish
DID_NOT_WEIGHS = (
(0, "Threshold Points"), # TODO: waiting on description
(1, "Worst Place Points"), # The points given for a DNW are equal to the points of last place
(2, "Incremental Points"), # A fixed number of points added for a DWN
(2, "Absolute Points"), # A fixed number of points given for a DNW
(2, "Not Scored") # Don't count to overall points
)
did_not_weigh = models.PositiveSmallIntegerField(choices=DID_NOT_WEIGHS)
did_not_weigh_value = models.IntegerField()
# Same as DNW, except is invoked because the angler left before the match end.
LEFT_EARLYS = DID_NOT_WEIGHS
left_early = models.PositiveSmallIntegerField(choices=LEFT_EARLYS)
left_early_value = models.IntegerField()
# Same as DNW, except invoked for not showing up.
# This is used to balance teams who are missing players.
NO_SHOWS = (
(0, "Threshold Points"),
(1, "Worst Place Points"),
(2, "Absolute Points"),
(3, "Not Scored")
)
no_show = models.PositiveSmallIntegerField(choices=NO_SHOWS)
no_show_value = models.IntegerField()
# Same as Now Show, except for angler's who didn't book their place
DID_NOT_BOOKS = NO_SHOWS
did_not_book = models.PositiveSmallIntegerField(choices=DID_NOT_BOOKS)
did_not_book = models.IntegerField()
# Same as DNW, except invoked when an angler is disqualified.
DISQUALIFICATIONS = DID_NOT_WEIGHS
disqualification = models.PositiveSmallIntegerField(choices=DISQUALIFICATIONS)
disqualification_value = models.IntegerField()
# TODO
best_league_sessions = models.IntegerField() # max: 20, min: 0
worst_league_sessions = models.IntegerField() # max: 20, min: 0
match_placed_positions = models.IntegerField() # max: 200, min: 0
class Meta:
verbose_name = "league rule"
verbose_name_plural = "league rules"
def __str__(self):
return self.name
class League(models.Model):
"""A League of matches (TODO: should match not be foreignkey linked to league?)
Attributes:
id (int): Automatically incrementing identifier number.
name (str): A human-readable label to identify this item.
description (str):
extra_notes (str):
profile_picture (file):
banner_picture (file):
matches (list of `Match`):
anglers (list of `Angler`):
rules (list of `LeagueRule`):
"""
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=128)
description = models.CharField(max_length=384)
extra_notes = models.CharField(max_length=1028)
profile_picture = models.ImageField()
banner_picture = models.ImageField()
matches = models.ManyToManyField(to=Match)
anglers = models.ManyToManyField(to=Angler)
rules = models.ManyToManyField(to=LeagueRule)
class Meta:
verbose_name = "league"
verbose_name_plural = "leagues"
def __str__(self):
return self.name
@property
def results(self):
return LeagueResult.objects.filter(league=self)
class Sponsor(models.Model):
"""Represent those sponsoring.
Attribute:
id (int): Automatically incrementing identifier number.
name (str): The sponsor's name.
url (str): Link to the sponsor's external resource.
image (file): An image representing the sponsor.
"""
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=128)
url = models.URLField()
image = models.ImageField()
class Meta:
verbose_name = "sponsor"
verbose_name_plural = "sponsors"
def __str__(self):
return self.name
class LeagueResult(models.Model):
"""An entry representing an angler's result in a league.
Attributes:
TODO
"""
id = models.AutoField(primary_key=True)
league = models.ForeignKey(to=League, on_delete=models.CASCADE)
angler = models.ForeignKey(to=Angler, on_delete=models.CASCADE)
sponsor = models.ForeignKey(to=Sponsor, on_delete=models.CASCADE, null=True, blank=True)
total_weight = models.CharField(max_length=64)
matches = models.IntegerField()
date = models.DateField(default=timezone.now)
class Meta:
verbose_name = "league result"
verbose_name_plural = "league results"
def __str__(self):
return f"{self.league.name} - {self.angler.name}"

View File

@ -1,119 +0,0 @@
var venueTypes;
$(document).ready(async () => {
await loadVenueTypes();
await loadVenues();
});
const loadVenueTypes = async () => {
const response = await $.ajax({
url: "/api/venues",
method: "OPTIONS"
});
venueTypes = response?.actions?.POST?.type?.choices || [];
}
const loadVenues = async () => {
const response = await $.ajax({
url: "/api/venues/",
method: "GET"
});
for (const venue of response?.results || []) {
addVenue(venue);
addVenue(venue);
addVenue(venue);
addVenue(venue);
addVenue(venue);
addVenue(venue);
addVenue(venue);
addVenue(venue);
addVenue(venue);
addVenue(venue);
}
}
const addVenue = venue => {
let $venue = $($("#venueItemTemplate").html());
const type = venueTypes.find(type => type.value === venue.type);
$venue.find(".venue-type").text(type.display_name);
$venue.find(".venue-item").data("id", venue.id);
$venue.find(".venue-name").text(venue.name);
$description = $venue.find(".venue-description");
$description.text(venue.description);
$clamp($description[0], {clamp: 3});
appendVenueAddress($venue, venue.address);
appendVenueContacts($venue, venue.contacts);
$venue.off("click").on("click", async () => await selectVenue(venue.id));
$("#venueContainer").append($venue);
}
const appendVenueAddress = ($venue, address) => {
if (!address) {
return;
}
const location = address?.post_code;
addVenueTemplateContact($venue, location, "bi-geo-alt");
}
const appendVenueContacts = ($venue, contacts) => {
if (!contacts) {
return;
}
const phoneNumber = contacts?.phone_number;
addVenueTemplateContact($venue, phoneNumber, "bi-telephone");
const emailAddress = contacts?.email_address;
addVenueTemplateContact($venue, emailAddress, "bi-envelope");
const websiteUrl = contacts?.website_url;
addVenueTemplateContact($venue, websiteUrl, "bi-globe");
const facebookUrl = contacts?.facebook_url;
addVenueTemplateContact($venue, facebookUrl, "bi-facebook");
const twitterUrl = contacts?.twitter_url;
addVenueTemplateContact($venue, twitterUrl, "bi-twitter-x");
const instagramUrl = contacts?.instagram_url;
addVenueTemplateContact($venue, instagramUrl, "bi-instagram");
}
const addVenueTemplateContact = ($venue, value, iconClass) => {
if (!value) {
return;
}
let $contact = $($("#venueContactTemplate").html())
$contact.find(".venue-contact-icon")
.addClass(iconClass)
.attr("data-bs-title", value)
.attr("data-bs-toggle", "tooltip")
.tooltip();
$venue.find(".venue-contacts").append($contact);
}
const selectVenue = async id => {
const response = await $.ajax({
url: `/api/venues/${id}/`,
method: "GET"
})
$(".js-createVenueBtn").trigger("click");
console.log(JSON.stringify(response, null, 4));
}
$(".js-createVenueBtn").on("click", () => {
$("#venueModal").modal("show");
});

View File

@ -1 +0,0 @@
@import "scss/base.scss";

View File

@ -1 +0,0 @@
@import "scss/base.scss";

View File

@ -1,165 +0,0 @@
@import "scss/base.scss";
.search-group {
max-width: 400px;
.form-control {
border-left: none !important;
border-top-right-radius: 0.25rem;
border-bottom-right-radius: 0.25rem;
&:focus, &:focus-within {
box-shadow: none;
border: var(--bs-border-width) solid var(--bs-border-color);
}
}
.input-group-text {
background-color: transparent;
border-top-left-radius: 0.25rem;
border-bottom-left-radius: 0.25rem;
padding-right: 0.25rem;
cursor: text;
}
}
.venue-item {
color: var(--bs-body-color);
padding: 1rem;
border: 1px solid var(--bs-border-color);
border-radius: 0.25rem;
min-width: 0;
.venue-type {
color: var(--bs-tertiary-color);
margin-bottom: 0.25rem;
@extend small;
@extend .text-truncate;
}
.venue-name {
font-weight: bold;
margin-bottom: 1rem;
color: var(--bs-body-color);
// Single line with ellipsis
max-width: 100%;
overflow: hidden;
text-wrap: nowrap;
text-overflow: ellipsis;
}
.venue-description {
color: var(--bs-secondary-color);
margin-bottom: 1rem;
}
.venue-contacts {
display: flex;
flex-direction: row;
list-style: none;
margin-bottom: 0;
padding-left: 0;
.venue-contact {
margin-right: 0.75rem;
.venue-contact-icon { @extend .bi; }
}
}
}
.venue-modal {
.modal-content { min-height: 0 !important; }
.venue-modal-header {
@extend .modal-header;
color: #fff;
background-color: #04385c;
border-radius: 0;
padding: 1rem 1.5rem;
}
.venue-modal-body {
flex-grow: 1;
.form-control { border-radius: var(--bs-border-radius-sm); }
textarea {
--height: calc(6em + 0.75rem + calc(var(--bs-border-width) * 2));;
max-height: var(--height);
min-height: var(--height);
height: var(--height);
resize: none;
}
.venue-modal-sidebar {
display: flex;
flex-direction: column;
height: 100%;
background-color: var(--bs-tertiary-bg);
.venue-sidebar-btn {
@extend .btn;
--bs-btn-active-color: #fff;
--bs-btn-active-bg: #04385c;
--bs-btn-hover-color: #fff;
--bs-btn-hover-bg: #085c8d;
padding: 0.75rem 1.5rem;
width: 100%;
border: none;
border-radius: 0;
}
}
.venue-modal-content {
padding: 1.5rem;
height: 100%;
background-color: var(--bs-body-bg);
}
.btn-primary {
}
}
}

View File

@ -1,483 +0,0 @@
{% extends "base.html" %}
{% load static %}
{% load compress %}
{% block stylesheets %}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="" />
{% compress css %}
<link type="text/x-scss" rel="stylesheet" href="{% static 'home/scss/index.scss' %}">
{% endcompress %}
{% endblock stylesheets %}
{% block header_buttons %}
{% endblock header_buttons %}
{% block content %}
<div class="px-4 bg-body shadow mb-5">
<div class="d-flex justify-content-between align-items-center p-2 flex-wrap">
<h1 class="fw-bold h4 mb-0 ms-2">Venues &amp; Waters</h1>
<div class="input-group w-auto">
<div class="input-group-text bg-body pe-0">
<i class="bi bi-search"></i>
</div>
<input type="search" class="form-control border-start-0" placeholder="Search Venues">
</div>
<div class="d-flex flex-row align-items-center">
<button class="btn btn-primary rounded-2 me-3" onclick="openVenueModal(-1);">
<i class="bi bi-plus-lg me-1"></i>
New
</button>
<button class="btn btn-outline-secondary border-secondary-subtle rounded-2 me-3">
<i class="bi bi-upload me-1"></i>
Import
</button>
<button class="btn btn-outline-secondary border-secondary-subtle rounded-2 me-3">
<i class="bi bi-sort-alpha-up me-sm-1"></i>
<i class="bi bi-chevron-down"></i>
</button>
<button class="btn btn-outline-secondary border-secondary-subtle rounded-2">
<i class="bi bi-filter-right me-sm-1"></i>
<i class="bi bi-chevron-down"></i>
</button>
</div>
</div>
</div>
<div class="row flex-row-reverse my-4 mx-lg-4">
<div class="col-lg-3 d-flex flex-column">
<div id="locationMapContainer" class="w-100 position-relative shadow mb-4 bg-body rounded-3 overflow-hidden" style="height: 300px;">
<div id="allLocationsMap" class="w-100 h-100"></div>
</div>
<div class="bg-body rounded-3 p-4 flex-grow-1 shadow mb-3">
<div class="text-body small">
placeholder<br>
maybe a graph here?
</div>
</div>
</div>
<div class="col-lg-9">
<div class="row gx-3 px-2 mt-0">
{% for venue in venues %}
<div class="col-xxl-4 col-xl-6 col-md-6 col-sm-12 mb-3">
<div class="rounded-2 h-100 p-4 bg-body shadow d-flex flex-column">
<header class="d-flex justify-content-between align-items-start mb-3 dropend">
<div class="text-truncate">
<h4 class="h6 mb-1 text-body-secondary small">
{% if venue.venue_type == "FISHERY" %}
Fishery
{% elif venue.venue_type == "PRIVATE" %}
Private
{% elif venue.venue_type == "CLUB" %}
Club
{% endif %}
</h4>
<h4 class="h6 mb-0 me-2 text-truncate fw-bold">{{ venue.name }}</h4>
</div>
<button class="border-0 bg-transparent" type="button" data-bs-toggle="dropdown">
<i class="bi bi-three-dots fs-4 d-flex"></i>
</button>
<ul class="dropdown-menu rounded-4 overflow-hidden py-0 shadow-sm" style="width: fit-content; min-width: fit-content;">
<li>
<button class="dropdown-item hover-fill-primary py-2" onclick="viewVenueModal({{ venue.id }})">
<i class="bi bi-eye"></i>
</button>
</li>
<li>
<hr class="dropdown-divider my-0">
</li>
<li>
<button class="dropdown-item py-2" onclick="openVenueModal({{ venue.id }});">
<i class="bi bi-pencil"></i>
</button>
</li>
<li>
<hr class="dropdown-divider my-0">
</li>
<li>
<button class="dropdown-item py-2 hover-fill-danger" onclick="deleteVenueBtn({{ venue.id }});">
<i class="bi bi-trash"></i>
</button>
</li>
</ul>
</header>
<p class="text-body-secondary venue-description mb-4">{{ venue.description }}</p>
<div class="d-flex align-items-center fs-6 mt-auto ">
{% if venue.email_address %}
<a href="mailto:{{ venue.email_address }}" class="text-reset text-hover-primary me-3" data-bs-toggle="tooltip" data-bs-title="{{ venue.email_address }}">
<i class="bi bi-envelope-at"></i>
</a>
{% endif %}
{% if venue.phone_number %}
<a href="tel:{{ venue.phone_number }}" class="text-reset text-hover-primary me-3" data-bs-toggle="tooltip" data-bs-title="{{ venue.phone_number }}">
<i class="bi bi-telephone"></i>
</a>
{% endif %}
{% if venue.latitude and venue.longitude %}
<a href="https://www.openstreetmap.org/?mlat={{ venue.latitude }}&mlon={{ venue.longitude }}" target="_blank" class="text-reset text-hover-primary me-3" data-bs-toggle="tooltip" data-bs-html="true" data-bs-title="{{ venue.street_address }}<br>{{ venue.city }}, {{ venue.provence }}<br>{{ venue.postal_code }}">
<i class="bi bi-geo-alt"></i>
</a>
{% endif %}
{% if venue.website_url %}
<a href="{{ venue.website_url }}" class="text-reset text-hover-primary me-3" target="_blank" data-bs-toggle="tooltip" data-bs-title="{{ venue.website_url }}">
<i class="bi bi-globe2"></i>
</a>
{% endif %}
<div class="d-inline mx-auto"></div>
{% if venue.waters %}
<div class="badge bg-info-subtle text-info-emphasis ms-2" data-bs-toggle="tooltip" data-bs-title="There are {{ venue.waters|length }} waters in this venue">
{{ venue.waters|length }}
<i class="bi bi-droplet-half "></i>
</div>
{% endif %}
{% if not venue.latitude or not venue.longitude or not venue.phone_number or not venue.website_url or not venue.email_address %}
<div class="badge bg-warning-subtle text-warning-emphasis ms-2" data-bs-toggle="tooltip" data-bs-title="There are missing details for this venue">
<i class="bi bi-exclamation-triangle"></i>
</div>
{% endif %}
{% if not venue.active %}
<div class="badge bg-danger-subtle text-danger-emphasis ms-2" data-bs-toggle="tooltip" data-bs-title="This venue is inactive">
<i class="bi bi-x-lg"></i>
</div>
{% endif %}
</div>
</div>
</div>
{% endfor %}
<div class="col-xxl-4 col-xl-6 col-md-6 col-sm-12">
<div class="fluid-hover-zoom h-100 d-flex flex-column justify-content-center align-items-center" role="button" onclick="openVenueModal(-1);">
<i class="bi bi-plus-lg fs-1"></i>
<span class="fw-bold">
Create new
</span>
</div>
</div>
</div>
</div>
</div>
<div id="venueModal" class="modal fade" data-venue-id="-1" data-bs-backdrop="static">
<div class="modal-dialog modal-dialog-centered modal-fullscreen-lg-down modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title text-truncate me-5">New Venue</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<form id="venueForm" class="flex-md-grow-1 d-flex" novalidate>
<div class="row g-0 flex-md-grow-1">
<div class="col-md-1">
<div id="sidebarNavigation" class="bg-body-tertiary">
<div class="modal-sidebar flex-row flex-md-column align-items-start text-center" role="tablist">
<button id="detailsTab" class="modal-sidebar-btn active" type="button" data-bs-toggle="tab" data-bs-target="#detailsContent" role="tab" aria-controls="detailsContent" aria-selected="true">
<i class="bi bi-file-earmark-text"></i>
</button>
<button id="addressTab" class="modal-sidebar-btn" type="button" data-bs-toggle="tab" data-bs-target="#addressContent" role="tab" aria-controls="addressContent" aria-selected="false">
<i class="bi bi-geo-alt"></i>
</button>
<button id="contactTab" class="modal-sidebar-btn" type="button" data-bs-toggle="tab" data-bs-target="#contactContent" role="tab" aria-controls="contactContent" aria-selected="false">
<i class="bi bi-telephone"></i>
</button>
<button id="watersTab" class="modal-sidebar-btn" type="button" data-bs-toggle="tab" data-bs-target="#watersContent" role="tab" aria-controls="watersContent" aria-selected="false">
<i class="bi bi-droplet-half"></i>
</button>
<button id="confirmTab" class="modal-sidebar-btn mt-md-auto" type="button" data-bs-toggle="tab" data-bs-target="#confirmContent" role="tab" aria-controls="confirmContent" aria-selected="false">
<i class="bi bi-check-lg"></i>
</button>
</div>
</div>
</div>
<div class="col-md-11 overflow-auto">
<div class="tab-content d-inline-block w-100 h-100 py-3 px-4">
<div id="detailsContent" class="tab-pane fade flex-column h-100 show active">
<div class="form-floating mb-4">
<input type="text" name="venueName" id="venueName" class="form-control" placeholder="">
<label for="venueName" class="form-label">Venue Name</label>
</div>
<div class="form-floating mb-4">
<textarea name="venueDesc" id="venueDesc" class="form-control" style="height: 150px; resize: none;" placeholder=""></textarea>
<label for="venueDesc" class="form-label">Description</label>
</div>
<div class="mb-4">
<div class="form-check form-check-inline">
<input type="radio" name="venueType" id="venueFishery" class="form-check-input" value="FISHERY">
<label for="venueFishery" class="form-check-label">Fishery</label>
</div>
<div class="form-check form-check-inline">
<input type="radio" name="venueType" id="venueClub" class="form-check-input" value="CLUB">
<label for="venueClub" class="form-check-label">Club</label>
</div>
<div class="form-check form-check-inline">
<input type="radio" name="venueType" id="venuePrivate" class="form-check-input" value="PRIVATE">
<label for="venuePrivate" class="form-check-label">Private</label>
</div>
</div>
<div class="form-check form-switch">
<input type="checkbox" name="venueActive" id="venueActive" class="form-check-input">
<label for="venueActive" class="form-check-label">Venue is active?</label>
</div>
<div class="mt-5 mt-md-auto d-flex justify-content-end">
<button class="btn btn-primary px-3" type="button" onclick="$('#addressTab').click();">Next</button>
</div>
</div>
<div id="addressContent" class="tab-pane fade flex-column h-100">
<div class="form-floating mb-4">
<input type="text" name="venueSearch" id="venueSearch" class="form-control" placeholder="">
<label for="venueSearch" class="form-label">
<i class="bi bi-search me-1"></i>
Post Code or Street Address
</label>
</div>
<div id="venueSearchResults" style="display: none">
<div class="row">
<div class="col-lg-6">
<div class="form-floating mb-3">
<input type="text" name="venueStreetNum" id="venueStreetNum" class="form-control-plaintext" placeholder="" readonly>
<label for="venueStreetNum" class="form-label">Street Number</label>
</div>
</div>
<div class="col-lg-6">
<div class="form-floating mb-3">
<input type="text" name="venueStreet" id="venueStreet" class="form-control-plaintext" placeholder="" readonly>
<label for="venueStreet" class="form-label">Street Address</label>
</div>
</div>
<div class="col-lg-6">
<div class="form-floating mb-3">
<input type="text" name="venueCity" id="venueCity" class="form-control-plaintext" placeholder="" readonly>
<label for="venueCity" class="form-label">Town/City</label>
</div>
</div>
<div class="col-lg-6">
<div class="form-floating mb-3">
<input type="text" name="venueCounty" id="venueCounty" class="form-control-plaintext" placeholder="" readonly>
<label for="venueCounty" class="form-label">County/Region</label>
</div>
</div>
<div class="col-lg-6">
<div class="form-floating mb-3">
<input type="text" name="venuePost" id="venuePost" class="form-control-plaintext" placeholder="" readonly>
<label for="venuePost" class="form-label">Post Code</label>
</div>
</div>
<div class="col-lg-6">
<div class="form-floating mb-3">
<input type="text" name="venueCountry" id="venueCountry" class="form-control-plaintext" placeholder="" readonly>
<label for="venueCountry" class="form-label">Country</label>
</div>
</div>
<div class="col-lg-6">
<div class="form-floating mb-3">
<input type="text" name="venueLat" id="venueLat" class="form-control-plaintext" placeholder="" readonly>
<label for="venueLat" class="form-label">Latitude</label>
</div>
</div>
<div class="col-lg-6">
<div class="form-floating mb-3">
<input type="text" name="venueLng" id="venueLng" class="form-control-plaintext" placeholder="" readonly>
<label for="venueLng" class="form-label">Longitude</label>
</div>
</div>
</div>
</div>
<div id="venueSearchHelper" class="my-auto text-center">
<label for="venueSearch" class="fs-4 mx-lg-4 text-body-secondary">Use the search to find your venue.</label>
</div>
<div class="mt-5 mt-md-auto d-flex justify-content-end">
<button class="btn btn-outline-secondary me-3" type="button" onclick="$('#detailsTab').click();">Back</button>
<button class="btn btn-primary px-3" type="button" onclick="$('#contactTab').click();">Next</button>
</div>
</div>
<div id="contactContent" class="tab-pane fade flex-column h-100">
<div class="row">
<div class="col-6">
<div class="form-floating mb-4">
<input type="tel" name="venuePhone" id="venuePhone" class="form-control" placeholder="">
<label for="venuePhone" class="form-label">Phone Number</label>
</div>
</div>
<div class="col-6">
<div class="form-floating mb-4">
<input type="email" name="venueEmail" id="venueEmail" class="form-control" placeholder="">
<label for="venueEmail" class="form-label">Email Address</label>
</div>
</div>
</div>
<div class="form-floating mb-4">
<input type="url" name="venueWebsite" id="venueWebsite" class="form-control" placeholder="">
<label for="venueWebsite" class="form-label">Website URL</label>
</div>
<div class="form-floating mb-4">
<input type="url" name="venueFacebook" id="venueFacebook" class="form-control" placeholder="">
<label for="venueFacebook" class="form-label">Facebook URL</label>
</div>
<div class="form-floating mb-4">
<input type="url" name="venueInstagram" id="venueInstagram" class="form-control" placeholder="">
<label for="venueInstagram" class="form-label">Instagram URL</label>
</div>
<div class="form-floating mb-4">
<input type="url" name="venueTwitter" id="venueTwitter" class="form-control" placeholder="">
<label for="venueTwitter" class="form-label">Twitter URL</label>
</div>
<div class="mt-5 mt-md-auto d-flex justify-content-end">
<button class="btn btn-outline-secondary me-3" type="button" onclick="$('#addressTab').click();">Back</button>
<button class="btn btn-primary px-3" type="button" onclick="$('#watersTab').click();">Next</button>
</div>
</div>
<div id="watersContent" class="tab-pane fade flex-column h-100">
waters
<div class="mt-5 mt-md-auto d-flex justify-content-end">
<button class="btn btn-outline-secondary me-3" type="button" onclick="$('#contactTab').click();">Back</button>
<button class="btn btn-primary px-3" type="button" onclick="$('#confirmTab').click();">Next</button>
</div>
</div>
<div id="confirmContent" class="tab-pane fade flex-column h-100">
<h5 class="mb-3">Preview:</h5>
<div class="row">
<div class="col-12">
<div class="form-floating mb-3 venue-preview-field">
<input type="text" class="form-control-plaintext" placeholder="" readonly data-linked-field="#venueName">
<label class="form-label">Venue Name</label>
</div>
</div>
<div class="col-lg-6">
<div class="form-floating mb-3 venue-preview-field">
<input type="text" class="form-control-plaintext" placeholder="" readonly data-linked-field="#venueDesc">
<label class="form-label">Description</label>
</div>
</div>
<div class="col-lg-6">
<div class="form-floating mb-3 venue-preview-field">
<input type="text" class="form-control-plaintext" placeholder="" readonly data-linked-field="#venueType">
<label class="form-label">Venue Type</label>
</div>
</div>
</div>
<div class="mt-5 mt-md-auto d-flex justify-content-end">
<button class="btn btn-outline-secondary me-3" type="button" onclick="$('#watersTab').click();">Back</button>
<button id="submitVenueBtn" class="btn btn-primary" type="submit">Save Changes</button>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- <div id="venueModal" class="modal fade" data-venue-id="-1" data-bs-backdrop="static">
<div class="modal-dialog modal-dialog-centered modal-fullscreen-sm-down ">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">New Venue</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div id="newVenuePages" class="modal-body">
<div id="detailsPage" class="page active">
<div class="form-floating mb-3">
<input type="text" class="form-control" placeholder="">
<label for="" class="form-label">Name</label>
</div>
<div class="form-floating mb-3">
<textarea class="form-control venue-textarea" placeholder=""></textarea>
<label for="" class="form-label">Description</label>
</div>
<label class="form-label">Type</label>
<div class="mb-3 group-radio-btns">
<input type="radio" name="vType" id="vtFishery" class="btn-check">
<label for="vtFishery" class="btn btn-outline-primary">Fishery</label>
<input type="radio" name="vType" id="vtClub" class="btn-check">
<label for="vtClub" class="btn btn-outline-primary">Club</label>
<input type="radio" name="vType" id="vtPrivate" class="btn-check">
<label for="vtPrivate" class="btn btn-outline-primary">Private</label>
</div>
</div>
<div id="addressPage" class="page">
<label class="form-label">Type part of the address or postcode to begin</label>
<input type="text" class="form-control" placeholder="E.g. 'CR0 3RL' or '36 Factory Lane'">
</div>
<div id="contactPage" class="page">
<div class="row mb-3">
<div class="col-lg-6">
<div class="form-floating">
<input type="tel" class="form-control" placeholder="">
<label for="">Phone Number</label>
</div>
</div>
<div class="col-lg-6">
<div class="form-floating">
<input type="email" class="form-control" placeholder="">
<label for="">Email Address</label>
</div>
</div>
</div>
<div class="form-floating mb-3">
<input type="url" class="form-control" placeholder="">
<label for="">
<i class="bi bi-link-45deg"></i>
Website
</label>
</div>
<div class="form-floating mb-3">
<input type="url" class="form-control" placeholder="">
<label for="">
<i class="bi bi-link-45deg"></i>
Facebook
</label>
</div>
<div class="form-floating mb-3">
<input type="url" class="form-control" placeholder="">
<label for="">
<i class="bi bi-link-45deg"></i>
Instagram
</label>
</div>
<div class="form-floating mb-3">
<input type="url" class="form-control" placeholder="">
<label for="">
<i class="bi bi-link-45deg"></i>
Twitter
</label>
</div>
</div>
<div id="watersPage" class="page">
Waters
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary me-auto" data-bs-dismiss="modal">Cancel</button>
<button type="button" id="newVenueBack" class="btn btn-secondary" style="display: none">
<i class="bi bi-arrow-left me-1"></i>
Back
</button>
<button type="button" id="newVenueNext" class="btn btn-primary">
Next
<i class="bi bi-arrow-right ms-1"></i>
</button>
<button type="button" id="newVenueFinished" class="btn btn-primary" style="display: none;">
Save Changes
</button>
</div>
</div>
</div>
</div> -->
{% endblock content %}
{% block scripts %}
<script>
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl, {trigger : 'hover'}))
</script>
<script>
(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r, "places"]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
key: "AIzaSyDFR2xw2LhMPb6FC8OrfiLrJZRMRLMocvw",
v: "weekly",
});
</script>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
<script src="https://unpkg.com/@turf/turf@6.5.0/turf.min.js"></script>
<script src="{% static 'js/mainapp/venues.js' %}" data-csrfmiddlewaretoken="{{ csrf_token }}"></script>
{% endblock scripts %}+

View File

@ -1,11 +0,0 @@
{% extends "base.html" %}
{% load static %}
{% load compress %}
{% block title %} · Leagues{% endblock title %}
{% block stylesheets %}
{% compress css %}
<link type="text/x-scss" rel="stylesheet" href="{% static 'home/scss/leagues.scss' %}">
{% endcompress %}
{% endblock stylesheets %}

View File

@ -1,66 +0,0 @@
<div id="venueModal" class="venue-modal modal fade" data-bs-backdrop="static">
<div class="modal-dialog modal-dialog-centered modal-fullscreen-lg-down modal-lg">
<div class="modal-content rounded-1">
<div class="venue-modal-header" data-bs-theme="dark">
<h5 class="modal-title me-5 fw-bold">Create a Venue</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="venue-modal-body row g-0">
<div class="col-md-1">
<div class="venue-modal-sidebar">
<button type="button" class="venue-sidebar-btn active">
<i class="bi bi-card-text"></i>
</button>
<button type="button" class="venue-sidebar-btn">
<i class="bi bi-geo-alt"></i>
</button>
<button type="button" class="venue-sidebar-btn">
<i class="bi bi-telephone"></i>
</button>
<button type="button" class="venue-sidebar-btn">
<i class="bi bi-images"></i>
</button>
<button type="button" class="venue-sidebar-btn">
<i class="bi bi-droplet-half"></i>
</button>
<button type="button" class="venue-sidebar-btn mt-auto">
<i class="bi bi-check-lg"></i>
</button>
</div>
</div>
<div class="col-md-11">
<div class="venue-modal-content">
<div class="form-group">
<label for="venueName" class="form-label">Name</label>
<input type="text" name="venueName" id="venueName" class="form-control">
</div>
<div class="form-group mt-4">
<label for="venueDescription" class="form-label">Description</label>
<textarea name="venueDescription" id="venueDescription" class="form-control"></textarea>
</div>
<div class="mt-4">
<label class="form-label w-100">Type</label>
<div class="btn-group rounded-1">
<input type="radio" name="venueType" id="venueTypeFishery" class="btn-check" value="fishery">
<label for="venueTypeFishery" class="btn btn-secondary">Fishery</label>
<input type="radio" name="venueType" id="venueTypeClub" class="btn-check" value="club">
<label for="venueTypeClub" class="btn btn-secondary">Club</label>
<input type="radio" name="venueType" id="venueTypePrivate" class="btn-check" value="private">
<label for="venueTypePrivate" class="btn btn-secondary">Private</label>
</div>
</div>
<div class="mt-5 text-end">
<button type="button" class="btn btn-secondary rounded-1 me-3 d-none">
Back
</button>
<button type="button" class="btn btn-primary rounded-1 px-4">
Next
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,55 +0,0 @@
{% extends "base.html" %}
{% load static %}
{% load compress %}
{% block title %} · Venues{% endblock title %}
{% block stylesheets %}
{% compress css %}
<link type="text/x-scss" rel="stylesheet" href="{% static 'home/scss/venues.scss' %}">
{% endcompress %}
{% endblock stylesheets %}
{% block content %}
<div class="container-xxl">
<div class="row mt-4">
<div class="col-md-6">
<div class="input-group search-group mb-4 mb-md-0">
<label for="venueSearch" class="input-group-text">
<i class="bi bi-search"></i>
</label>
<input type="search" id="venueSearch" name="venueSearch" class="form-control" placeholder="Search...">
</div>
</div>
<div class="col-md-6 text-md-end">
<button type="button" class="js-createVenueBtn btn btn-primary rounded-1">
Create a Venue
</button>
</div>
</div>
<div id="venueContainer" class="row gy-0 venue-items"></div>
</div>
{% include "home/venue-modal.html" %}
{% endblock content %}
{% block scripts %}
<script id="venueItemTemplate" type="text/template">
<div class="col-md-6 col-lg-4 col-xxl-3 mt-4">
<div class="venue-item" role="button">
<div class="venue-type"></div>
<div class="venue-name"></div>
<div class="venue-description"></div>
<ul class="venue-contacts"></ul>
</div>
</div>
</script>
<script id="venueContactTemplate" type="text/template">
<li class="venue-contact">
<i class="venue-contact-icon"></i>
</li>
</script>
<script src="{% static 'js/clamp.min.js' %}"></script>
<script src="{% static 'home/js/venues.js' %}"></script>
{% endblock scripts %}

View File

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

@ -1,13 +0,0 @@
"""URLs for the home app."""
from django.urls import path
from . import views
app_name = "home"
urlpatterns = [
path("", views.IndexView.as_view(), name="index"),
path("venues", views.VenueWatersView.as_view(), name="venues-waters"),
path("leagues", views.LeagueView.as_view(), name="leagues")
]

View File

@ -1,22 +0,0 @@
"""Views for the home app."""
from django.shortcuts import render
from django.views.generic import TemplateView
class IndexView(TemplateView):
"""The index view of the home app."""
template_name = "home/index.html"
class VenueWatersView(TemplateView):
"""Page for indexing Venues & Waters."""
template_name = "home/venues.html"
class LeagueView(TemplateView):
"""Page for indexing Leagues."""
template_name = "home/leagues.html"

View File

@ -1,213 +0,0 @@
"""
Django settings for Results project.
Generated by 'django-admin startproject' using Django 4.1.5.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
import json
import environ
import logging
from pathlib import Path
from django.utils import timezone
log = logging.getLogger(__name__)
VERSION = "0.0.0"
# Build paths inside the project like this: BASE_DIR / "subdir".
BASE_DIR = Path(__file__).resolve().parent.parent
# Environment Variables
env = environ.Env(DEBUG=(bool, True))
environ.Env.read_env(BASE_DIR / ".env")
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env("RESULTS_SYSTEM__SECRET_KEY", default="unsecure-default-secret-key")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env("RESULTS_SYSTEM__DEBUG").lower() == "true"
CSRF_TRUSTED_ORIGINS = [
"http://localhost",
"http://127.0.0.1",
"https://" + env("RESULTS_SYSTEM__HOST", default="127.0.0.1")
]
ALLOWED_HOSTS = [
host.replace("http://", "").replace("https://", "")
for host in CSRF_TRUSTED_ORIGINS
]
# Application definition
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_extensions",
"rest_framework",
"compressor",
"apps.api",
"apps.home",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
ROOT_URLCONF = "core.urls"
APPEND_SLASH = True
LOGIN_URL = "/login/"
LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
WSGI_APPLICATION = "core.wsgi.application"
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
DB_ENGINE = env("RESULTS_SYSTEM__DB_ENGINE", default=None)
if not DB_ENGINE:
db_data = {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "db.sqlite3"
}
else:
db_data = {
"ENGINE": env("DB_ENGINE"),
"NAME": env("DB_NAME"),
"USER": env("DB_USER"),
"PASSWORD": env("DB_PASS"),
"HOST": env("DB_HOST"),
"PORT": env("DB_PORT")
}
DATABASES = { "default": db_data }
# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{ "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" },
{ "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator" },
{ "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator" },
{ "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator" },
]
# Logging
# https://docs.djangoproject.com/en/5.0/topics/logging/
LOGGING_DIR = BASE_DIR / "logs"
LOGGING_DIR.mkdir(exist_ok=True)
with open(LOGGING_DIR / "config.json", "r", encoding="utf-8") as file:
LOGGING = json.load(file)
filename = timezone.now().strftime('%Y-%m-%d_%H-%M-%S')
LOGGING["handlers"]["file"]["filename"] = LOGGING_DIR / f"{filename}.log"
# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/
LANGUAGE_CODE = "en-gb"
TIME_ZONE = "Europe/London"
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
STATIC_ROOT = BASE_DIR / "staticfiles"
STATIC_URL = "/static/"
STATICFILES_DIRS = (BASE_DIR / "static",)
STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
"compressor.finders.CompressorFinder",
)
# Compressors
COMPRESS_ENABLED = True
COMPRESS_OFFLINE = not DEBUG
COMPRESS_PRECOMPILERS = [("text/x-scss", "django_libsass.SassCompiler")]
COMPRESS_CSS_FILTERS = ["compressor.filters.css_default.CssAbsoluteIdentifier"]
LIBSASS_ADDITIONAL_INCLUDE_PATHS = [str(BASE_DIR / "static/")]
# Media Files
MEDIA_ROOT = BASE_DIR / "media"
MEDIA_URL = "/media/"
# region Rest Framework
# https://www.django-rest-framework.org/
REST_FRAMEWORK = {
"DEFAULT_THROTTLE_CLASSES": [
"rest_framework.throttling.AnonRateThrottle",
"rest_framework.throttling.UserRateThrottle"
],
"DEFAULT_THROTTLE_RATES": {
"anon": "100/day",
"user": "10000/hour"
},
"DEFAULT_RENDERER_CLASSES": [
"rest_framework.renderers.JSONRenderer",
# "rest_framework.renderers.AdminRenderer",
"rest_framework.renderers.BrowsableAPIRenderer"
],
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
"PAGE_SIZE": 100
}
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

View File

@ -1,7 +1,4 @@
@echo off
echo This file is outdated
set /p dontCare=Do you want to continue? [y/n]
echo The purpose of this file is to populate the database with dummy data for testing. Running this WILL DELETE your current sqlite3 database.
set /p confirm=Do you want to continue? [y/n]

View File

@ -1,20 +0,0 @@
[
{
"model": "auth.user",
"pk": 1,
"fields": {
"password": "pbkdf2_sha256$720000$sz7T3QpIk5GHLR8ezSb7UU$lF2oPTmIs7fKOaa02/+daObbqJs7eCrSu+VLIRX8H+M=",
"last_login": null,
"is_superuser": true,
"username": "admin",
"first_name": "",
"last_name": "",
"email": "admin@mail.com",
"is_staff": true,
"is_active": true,
"date_joined": "2024-11-05T18:15:55.516Z",
"groups": [],
"user_permissions": []
}
}
]

View File

@ -1,47 +0,0 @@
{
"version": 1,
"disable_existing_loggers": false,
"formatters": {
"simple": {
"format": "[%(module)s|%(levelname)s] %(message)s"
},
"detail": {
"format": "[%(asctime)s] [%(levelname)s] [%(module)s]: %(message)s"
},
"complex": {
"format": "[%(levelname)s|%(name)s|L%(lineno)d] %(asctime)s %(message)s",
"datefmt": "%Y-%m-%dT%H:%M:%S%z"
}
},
"handlers": {
"file": {
"level": "DEBUG",
"class": "logging.FileHandler",
"formatter": "complex"
},
"stdout": {
"level": "INFO",
"class": "logging.StreamHandler",
"formatter": "simple",
"stream": "ext://sys.stdout"
}
},
"loggers": {
"root": {
"level": "DEBUG",
"handlers": [
"file",
"stdout"
]
},
"apps": {
"level": "DEBUG"
},
"django": {
"level": "INFO"
},
"django.request": {
"level": "ERROR"
}
}
}

Binary file not shown.

View File

@ -1,11 +0,0 @@
@echo off
cd %~dp0
call venv/Scripts/activate.bat
python src/manage.py migrate
python src/manage.py create_superuser --username admin --password password --noinput --email "admin@mail.com"
echo "A superuser has been created username='admin' and password='password'"
pause

View File

@ -1,5 +0,0 @@
cd "$(dirname "$(readlink -f "$0")")"/..
source ./venv/bin/activate
python manage.py graph_models apps_home | dot -Tpng -o entity-relationship-diagram.png

View File

@ -7,7 +7,6 @@ Target Audience Tech Knowledge - Mid to Low
Notes:
- Pull up the system for an event, input data that is happening in the event.
- Live scoreboard, updated when new data is inserted into the database.
- Seperate marks per event. Stores finished events in an archive.
Assuming the number of members are divised equally amongst the teams - the total number of pegs can be calculated by
multiplying the total number of teams by the amount of members a team

View File

@ -11,6 +11,6 @@ import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Results.settings')
application = get_asgi_application()

144
src/Results/settings.py Normal file
View File

@ -0,0 +1,144 @@
"""
Django settings for Results project.
Generated by 'django-admin startproject' using Django 4.1.5.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-==z9@atc)#1c@%@+txwiie=3qk)9r92antn3b$v#4o8r2q63&d'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ["*", "192.168.5.105"]
# Application definition
INSTALLED_APPS = [
'baton',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# 'rest_framework_datatables'
'mainapp',
'baton.autodiscover',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'Results.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'Results.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
STATIC_URL = 'static/'
STATICFILES_DIRS = [BASE_DIR / 'static/']
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# Rest Framework for Data Table
#REST_FRAMEWORK = {
# 'DEFAULT_RENDERER_CLASSES': (
# 'rest_framework.renderers.JSONRenderer',
# 'rest_framework.renderers.BrowsableAPIRenderer',
# 'rest_framework_datatables.renderers.DatatablesRenderer',
# ),
# 'DEFAULT_FILTER_BACKENDS': (
# 'rest_framework_datatables.filters.DatatablesFilterBackend',
# ),
# 'DEFAULT_PAGINATION_CLASS': 'rest_framework_datatables.pagination.DatatablesPageNumberPagination',
# 'PAGE_SIZE': 50,
#}

View File

@ -13,11 +13,11 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from baton.autodiscover import admin
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path("api/", include("apps.api.urls", namespace="api")),
path("", include("apps.home.urls", namespace="home")),
path('admin/', admin.site.urls),
path('baton/', include('baton.urls')),
path('', include('mainapp.urls')),
]

View File

@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Results.settings')
application = get_wsgi_application()

41
src/mainapp/admin.py Normal file
View File

@ -0,0 +1,41 @@
"""Admin models for the mainapp app."""
from django.contrib import admin
from .models import Peg, Member, Team
@admin.register(Peg)
class PegAdmin(admin.ModelAdmin):
"""Admin model for the Peg model."""
change_list_template = "entities/bulk_pegging.html"
readonly_fields = ("peg_number",)
list_display = ("peg_number",)
search_fields = ("peg_number",)
@admin.register(Member)
class MemberAdmin(admin.ModelAdmin):
"""Admin model for the Member model."""
list_display = ("first_name", "last_name", "team")
search_fields = ("first_name", "last_name", "team")
list_filter = ("team",)
@admin.register(Team)
class TeamAdmin(admin.ModelAdmin):
"""Admin model for the Team model."""
readonly_fields = ("team_number",)
list_display = ("team_number",)
search_fields = ("team_number",)
# @admin.register(Section)
# class SectionAdmin(admin.ModelAdmin):
# """Admin model for the Section model."""
# list_display = ("character",)
# search_fields = ("character",)

View File

@ -3,5 +3,4 @@ from django.apps import AppConfig
class MainappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.home'
label = "apps_home"
name = 'mainapp'

23
src/mainapp/filters.py Normal file
View File

@ -0,0 +1,23 @@
from decimal import Decimal
from django.db.models import Q
import django_filters
from .models import Scoreboard
class ProductFilter(django_filters.FilterSet):
query = django_filters.CharFilter(method='universal_search',
label="")
class Meta:
model = Scoreboard
fields = ['query']
def universal_search(self, queryset, name, value):
if value.replace(".", "", 1).isdigit():
value = Decimal(value)
return Scoreboard.objects.filter(
Q(price=value) | Q(cost=value)
)
return Scoreboard.objects.filter(
Q(name__icontains=value) | Q(category__icontains=value)
)

View File

@ -0,0 +1,302 @@
[
{
"model": "mainapp.member",
"pk": 1,
"fields": {
"first_name": "Robert",
"last_name": "Reid",
"team": 1,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 2,
"fields": {
"first_name": "Ronald",
"last_name": "Jones",
"team": 1,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 3,
"fields": {
"first_name": "Casey",
"last_name": "Cohen",
"team": 1,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 4,
"fields": {
"first_name": "James",
"last_name": "Scudder",
"team": 2,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 5,
"fields": {
"first_name": "Randall",
"last_name": "Young",
"team": 2,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 6,
"fields": {
"first_name": "Helen",
"last_name": "Doak",
"team": 2,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 7,
"fields": {
"first_name": "Brenda",
"last_name": "Powell",
"team": 3,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 8,
"fields": {
"first_name": "Constance",
"last_name": "Abild",
"team": 3,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 9,
"fields": {
"first_name": "Patsy",
"last_name": "Branham",
"team": 3,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 10,
"fields": {
"first_name": "Cheryl",
"last_name": "Sears",
"team": 4,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 11,
"fields": {
"first_name": "Justin",
"last_name": "Cramer",
"team": 4,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 12,
"fields": {
"first_name": "Theodore",
"last_name": "Wilson",
"team": 4,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 13,
"fields": {
"first_name": "Geneva",
"last_name": "Low",
"team": 5,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 14,
"fields": {
"first_name": "John",
"last_name": "Burtt",
"team": 5,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 15,
"fields": {
"first_name": "Alfred",
"last_name": "Diaz",
"team": 5,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 16,
"fields": {
"first_name": "Arthur",
"last_name": "Alton",
"team": 6,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 17,
"fields": {
"first_name": "Vicki",
"last_name": "Greer",
"team": 6,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 18,
"fields": {
"first_name": "Lewis",
"last_name": "Segovia",
"team": 6,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 19,
"fields": {
"first_name": "Vince",
"last_name": "Robinson",
"team": 7,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 20,
"fields": {
"first_name": "Blake",
"last_name": "Mueller",
"team": 7,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 21,
"fields": {
"first_name": "Luis",
"last_name": "Hazel",
"team": 7,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 22,
"fields": {
"first_name": "Diane",
"last_name": "Lloyd",
"team": 8,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 23,
"fields": {
"first_name": "Jamey",
"last_name": "Mendes",
"team": 8,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 24,
"fields": {
"first_name": "Virgilio",
"last_name": "Nixon",
"team": 8,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 25,
"fields": {
"first_name": "Rodney",
"last_name": "White",
"team": 9,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 26,
"fields": {
"first_name": "Kathleen",
"last_name": "Ashe",
"team": 9,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 27,
"fields": {
"first_name": "Stephanie",
"last_name": "Taylor",
"team": 9,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 28,
"fields": {
"first_name": "John",
"last_name": "Brennan",
"team": 10,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 29,
"fields": {
"first_name": "Kenneth",
"last_name": "Duff",
"team": 10,
"peg_number": null
}
},
{
"model": "mainapp.member",
"pk": 30,
"fields": {
"first_name": "Matthew",
"last_name": "Whitesell",
"team": 10,
"peg_number": null
}
}
]

View File

@ -0,0 +1,72 @@
[
{
"model": "mainapp.team",
"pk": 1,
"fields": {
"section_letter": "D"
}
},
{
"model": "mainapp.team",
"pk": 2,
"fields": {
"section_letter": "P"
}
},
{
"model": "mainapp.team",
"pk": 3,
"fields": {
"section_letter": "L"
}
},
{
"model": "mainapp.team",
"pk": 4,
"fields": {
"section_letter": "M"
}
},
{
"model": "mainapp.team",
"pk": 5,
"fields": {
"section_letter": "Z"
}
},
{
"model": "mainapp.team",
"pk": 6,
"fields": {
"section_letter": "Y"
}
},
{
"model": "mainapp.team",
"pk": 7,
"fields": {
"section_letter": "J"
}
},
{
"model": "mainapp.team",
"pk": 8,
"fields": {
"section_letter": "W"
}
},
{
"model": "mainapp.team",
"pk": 9,
"fields": {
"section_letter": "T"
}
},
{
"model": "mainapp.team",
"pk": 10,
"fields": {
"section_letter": "F"
}
}
]

View File

@ -0,0 +1,52 @@
import random
import names
import json
from django.core.management.base import BaseCommand
from mainapp.models import Member, Team
# TODO: refactor this file like create_teams_fixtures.py
class Command(BaseCommand):
help = "Creates a fixture with randomly generated Member objects"
def add_arguments(self, parser):
parser.add_argument("num_members", type=int)
def handle(self, *args, **options):
num_members = options["num_members"]
teams = Team.objects.all()
if not teams:
print("No teams found. Please create some teams first.")
return
members = []
for team in teams:
for _ in range(num_members):
first_name = names.get_first_name()
last_name = names.get_last_name()
member = Member(first_name=first_name, last_name=last_name, team=team)
members.append(member)
Member.objects.bulk_create(members)
self.stdout.write(self.style.SUCCESS(f"Created {num_members} members."))
# create a members fixture file
members_fixture = []
for member in members:
member_fixture = {
"model": "mainapp.member",
"pk": member.pk,
"fields": {
"first_name": member.first_name,
"last_name": member.last_name,
"team": member.team_id,
"peg_number": member.peg_number
}
}
members_fixture.append(member_fixture)
with open("src/mainapp/fixtures/members_fixture.json", "w") as f:
f.write(json.dumps(members_fixture, indent=2))
self.stdout.write(self.style.SUCCESS("Created members_fixture.json."))

View File

@ -0,0 +1,64 @@
"""Command to create test data fixture for teams."""
import random
import json
from string import ascii_uppercase
from django.core.management.base import BaseCommand
from django.db.utils import IntegrityError
from mainapp.models import Team, BLOCKED_SECTION_LETTERS
class Command(BaseCommand):
help = "Creates a fixture file for Team objects"
def add_arguments(self, parser):
parser.add_argument("amount_of_teams", type=int, help="Number of teams to create")
def handle(self, *args, **options):
existing_teams = Team.objects.all()
# Available sections
available_sections = [
char for char in [*ascii_uppercase]
if char.lower() not in BLOCKED_SECTION_LETTERS
and char not in [team.section_letter for team in existing_teams]
]
if not available_sections:
self.stdout.write(self.style.ERROR(
f"There are no available sections for new teams."
))
return
teams_amount = options["amount_of_teams"]
max_teams = len(available_sections)
if teams_amount > max_teams:
self.stdout.write(self.style.ERROR(
f"Number of teams is too large [{teams_amount}/{max_teams}]."
))
return
# Create the new teams (this will create them in the database)#
new_teams = []
for i in range(teams_amount):
section_letter = random.choice(available_sections)
available_sections.remove(section_letter)
team = Team.objects.create(section_letter=section_letter)
new_teams.append(team)
teams_fixture = [{
"model": "mainapp.team",
"pk": team.pk,
"fields": {"section_letter": team.section_letter}
} for team in new_teams]
# Remove the teams from the database
for team in new_teams:
team.delete()
with open("src/mainapp/fixtures/teams_fixture.json", "w") as file:
file.write(json.dumps(teams_fixture, indent=4))
self.stdout.write(self.style.SUCCESS("Created teams_fixture.json."))

View File

@ -0,0 +1,39 @@
# Generated by Django 4.1.5 on 2023-05-07 21:57
from django.db import migrations, models
import django.db.models.deletion
import mainapp.models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Peg',
fields=[
('peg_number', mainapp.models.ReusableAutoField(default=mainapp.models.ReusableAutoField.get_default, editable=False, primary_key=True, serialize=False)),
],
),
migrations.CreateModel(
name='Team',
fields=[
('team_number', mainapp.models.ReusableAutoField(default=mainapp.models.ReusableAutoField.get_default, editable=False, primary_key=True, serialize=False)),
('section_letter', models.CharField(choices=[('A', 'A'), ('B', 'B'), ('C', 'C'), ('D', 'D'), ('E', 'E'), ('F', 'F'), ('G', 'G'), ('H', 'H'), ('I', 'I'), ('J', 'J'), ('K', 'K'), ('L', 'L'), ('M', 'M'), ('N', 'N'), ('O', 'O'), ('P', 'P'), ('Q', 'Q'), ('R', 'R'), ('S', 'S'), ('T', 'T'), ('U', 'U'), ('V', 'V'), ('W', 'W'), ('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], max_length=1, unique=True)),
],
),
migrations.CreateModel(
name='Member',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=255)),
('last_name', models.CharField(max_length=255)),
('peg_number', models.PositiveIntegerField(null=True, unique=True)),
('team', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='members', to='mainapp.team', validators=[mainapp.models.validate_team_size])),
],
),
]

131
src/mainapp/models.py Normal file
View File

@ -0,0 +1,131 @@
from string import ascii_uppercase
from django.db import models
from django.core.exceptions import ValidationError
from django.db import models
class ReusableAutoField(models.PositiveIntegerField):
"""A django auto field that can reuse deleted primary keys"""
def get_next_available_id(self, model_cls, using=None):
"""
Returns the next available id for the given model class.
"""
all_ids = set(range(1, model_cls._default_manager.count()+1))
used_ids = set(model_cls._default_manager.all().values_list('pk', flat=True))
available_ids = all_ids - used_ids
if available_ids:
return min(available_ids)
if used_ids:
return max(used_ids) + 1
return 1
def get_default(self):
"""Returns the default value for this field"""
return self.get_next_available_id(self.model)
class Peg(models.Model):
"""Represents a person's peg"""
peg_number = ReusableAutoField(primary_key=True, default=ReusableAutoField.get_default, editable=False)
def __str__(self):
return f"Peg {self.peg_number}"
def validate_team_size(value):
if Member.objects.filter(team=value).count() >= 3:
raise ValidationError('Team already has maximal amount of members (3)')
class Member(models.Model):
"""Represents a member of a team"""
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
team = models.ForeignKey("Team", on_delete=models.SET_NULL, null=True, blank=True, validators=(validate_team_size,), related_name='members')
peg_number = models.PositiveIntegerField(null=True, editable=True, unique=True)
# peg = models.OneToOneField("Peg", on_delete=models.SET_NULL, null=True, blank=True)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# If the peg_number field is not set, we assign it the smallest
# available positive integer, excluding any used values.
if not self.peg_number:
used_peg_numbers = Member.objects.exclude(id=self.id).exclude(peg_number=None).values_list("peg_number", flat=True)
peg_numbers = set(range(1, Member.objects.count() + 1)) - set(used_peg_numbers)
if peg_numbers:
self.peg_number = min (peg_numbers)
def __str__(self):
return f"{self.first_name} {self.last_name} (team {self.team.team_number}))"
@property
def fullname(self) -> str:
return f"{self.first_name} {self.last_name}"
BLOCKED_SECTION_LETTERS = ["i"] # lowercase only, sections cannot be any of these letters#
class Team(models.Model):
"""Represents a team"""
team_number = ReusableAutoField(primary_key=True, default=ReusableAutoField.get_default, editable=False)
section_letter = models.CharField(max_length=1, unique=True, choices=[
(char, char) for char in ascii_uppercase if char.lower() not in BLOCKED_SECTION_LETTERS
])
def __str__(self):
return f"Team {self.team_number}"
@property
def members(self) -> list[Member]:
Member.objects.filter(team=self)
def validate_section_character(value):
"""Validates the section character"""
value = value.upper()
banned_characters = ["I"]
if value in banned_characters:
raise ValidationError(f"The character <{value}> is a prohibited character.")
# class Section(models.Model):
# """Represents a section of the scoreboard"""
# # character field stores a single character but doesnt allow for 'I' or 'i'
# character = models.CharField(primary_key=True, max_length=1, validators=(validate_section_character, ))
# def clean(self):
# self.character = self.character.upper()
# def __str__(self):
# return f"Section {self.character}"
#class Scoreboard(models.Model):
# class Status(models.IntegerChoices):
# ACTIVE = 1, "Active"
# INACTIVE = 2, "Inactive"
# ARCHIVED = 3, "Archived"
#
# name = models.CharField(max_length=255)
# category = models.CharField(max_length=255)
# price = models.DecimalField(max_digits=10, decimal_places=2)
# cost = models.DecimalField(max_digits=10, decimal_places=2)
# status = models.PositiveSmallIntegerField(choices=Status.choices)
#
# def __str__(self):
# return self.name

View File

@ -0,0 +1,11 @@
import names
from string import ascii_lowercase
created_teams = []
for char in ascii_lowercase:
created_teams.append({
"identifier": char.upper(),
"members": [{
"name": names.get_full_name()
} for i in range(9)]
})

View File

@ -0,0 +1,35 @@
{% extends "admin/change_list.html" %}
{% block object-tools %}
<div class="bg-body pt-2 pb-3 d-flex justify-content-end">
<button class="btn btn-primary me-3" data-bs-toggle="modal" data-bs-target="#peggingModal">Add Many Pegs</button>
<form method="POST" action="/bulk-peg/">
{% csrf_token %}
<input type="hidden" name="pegAmount" value="1" min="1" max="1" required="true">
<button type="submit" class="btn btn-secondary">Add One Peg</button>
</form>
</div>
<div class="modal fade" tabindex="-1" id="peggingModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Bulk Add Pegs</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form method="POST" action="/bulk-peg/">
{% csrf_token %}
<div class="form-group mb-3">
<label class="form-label" for="pegAmount">Number of Pegs</label>
<input type="number" class="form-control" id="pegAmount" name="pegAmount" min="1" max="9999" required="true">
</div>
<div class="d-flex">
<button type="submit" class="btn btn-success me-auto">Start Pegging</button>
<button type="button" class="btn btn-danger" data-bs-dismiss="modal" aria-label="Close">Cancel</button>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock object-tools %}

View File

@ -0,0 +1,56 @@
{% extends "base.html" %}
{% block content %}
<section class="py-5 text-center container">
<div class="row py-lg-5">
<div class="col-lg-6 col-md-8 mx-auto">
<h1 class="fw-light text-white">Results System</h1>
<p class="lead text-white">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi faucibus elementum diam nec semper. Nullam vestibulum enim eu nisi condimentum, vitae suscipit risus imperdiet.</p>
</div>
</div>
</section>
<div class="album py-5 bg-light">
<div class="container">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
<!-- Teams & Members -->
<div class="col">
<div class="card shadow-sm">
<a href="{% url 'teams' %}">
<svg class="bd-placeholder-img card-img-top" width="100%" height="225" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: Thumbnail" preserveAspectRatio="xMidYMid slice" focusable="false"><title>Placeholder</title><rect width="100%" height="100%" fill="#55595c"/><text x="50%" y="50%" fill="#eceeef" dy=".3em">Thumbnail</text></svg>
<div class="card-body">
<p class="card-text">Teams / Members</p>
</div>
</a>
</div>
</div>
<!-- Scoreboard -->
<div class="col">
<div class="card shadow-sm">
<a href="{% url 'scoreboard' %}">
<svg class="bd-placeholder-img card-img-top" width="100%" height="225" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: Thumbnail" preserveAspectRatio="xMidYMid slice" focusable="false"><title>Placeholder</title><rect width="100%" height="100%" fill="#55595c"/><text x="50%" y="50%" fill="#eceeef" dy=".3em">Thumbnail</text></svg>
<div class="card-body">
<p class="card-text">Scoreboard</p>
</div>
</a>
</div>
</div>
<!-- Results -->
<div class="col">
<div class="card shadow-sm">
<a href="{% url 'results' %}">
<svg class="bd-placeholder-img card-img-top" width="100%" height="225" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: Thumbnail" preserveAspectRatio="xMidYMid slice" focusable="false"><title>Placeholder</title><rect width="100%" height="100%" fill="#55595c"/><text x="50%" y="50%" fill="#eceeef" dy=".3em">Thumbnail</text></svg>
<div class="card-body">
<p class="card-text">Results</p>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
{% endblock content %}

View File

@ -0,0 +1,11 @@
{% extends "base.html" %}
{% block title %}
Results |
{% endblock title %}
{% block content %}
<div class="bg-dark-subtle p-4">
<a href="{% url 'index' %}" class="btn btn-primary">Back</a>
</div>
{% endblock content %}

View File

@ -0,0 +1,11 @@
{% extends "base.html" %}
{% block title %}
Scoreboard |
{% endblock title %}
{% block content %}
<div class="bg-dark-subtle p-4">
<a href="{% url 'index' %}" class="btn btn-primary">Back</a>
</div>
{% endblock content %}

View File

@ -0,0 +1,160 @@
{% extends "base.html" %}
{% block title %}
Teams & Members |
{% endblock title %}
{% block content %}
<div class="bg-body p-4">
<a href="{% url 'index' %}" class="btn btn-company px-4">Back</a>
</div>
<div class="container my-4 p-4 pb-0 bg-body rounded">
<div class="row mb-4">
<div class="col-12 col-xl-4">
<h3 class="mb-3 mb-xl-0">Teams &amp; Members</h3>
</div>
<div class="col-sm-3 col-md-6 col-xl-4 mb-3 mb-sm-0">
<div class="input-group justify-content-xl-end">
<button class="btn border-secondary-subtle btn-outline-company" id="addMember" data-bs-toggle="tooltip" data-bs-title="Add Member">
<i class="bi bi-person"></i>
</button>
<button class="btn border-secondary-subtle btn-outline-company" id="addTeam" data-bs-toggle="tooltip" data-bs-title="Add Team">
<i class="bi bi-people"></i>
</button>
</div>
</div>
<div class="col-sm-9 col-md-6 col-xl-4">
<div class="input-group dropdown">
<button type="button" data-bs-toggle="dropdown" class="btn btn-outline-company border-secondary-subtle">
<i class="bi bi-sort-up"></i>
</button>
<input type="search" class="form-control border-secondary-subtle shadow-none" placeholder="Search Members" id="search">
<button type="button" class="btn btn-outline-company border-secondary-subtle rounded-end" id="searchButton"><i class="bi bi-search"></i></button>
<form id="sortForm">
<ul class="dropdown-menu py-3 text-body-secondary bg-body-tertiary border border-light-subtle shadow-sm justify-self-center mt-2" onclick="event.stopPropagation()">
<li class="px-4">
<h3 class="h6 mb-3">Sort groups by</h3>
<div>
<div class="d-inline-block form-check">
<input type="radio" class="form-check-input" checked value="team_number" name="sortTeams" id="sortTeamsName">
<label for="sortTeamsName" class="form-check-label">Teams</label>
</div>
<div class="d-inline-block form-check ms-4">
<input type="radio" class="form-check-input" value="section_letter" name="sortTeams" id="sortTeamsSection">
<label for="sortTeamsSection" class="form-check-label">Sections</label>
</div>
</div>
</li>
<li class="dropdown-divider my-3 mx-4 bg-light-subtle"></li>
<li class="px-4">
<h3 class="h6 mb-3">Sort members by</h3>
<div>
<div class="d-inline-block form-check">
<input type="radio" class="form-check-input" value="first_name" name="sortMembers" id="sortMembersName">
<label for="sortMembersName" class="form-check-label">Name</label>
</div>
<div class="d-inline-block form-check ms-4">
<input type="radio" class="form-check-input" checked value="peg_number" name="sortMembers" id="sortMembersPeg">
<label for="sortMembersPeg" class="form-check-label">Peg Number</label>
</div>
</div>
</li>
</ul>
</form>
</div>
</div>
</div>
<div class="row" id="teamsContainer"></div>
<div class="col-12 text-center pb-4" id="teamsLoadingSpinner">
<div class="spinner-border spinner-border-lg" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
<div class="pb-4" id="teamsNotFound">
<div class="alert alert-danger m-0" role="alert">
No teams found under that search
</div>
</div>
</div>
<!-- Edit Team Modal -->
<div class="modal fade" id="editTeamModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content border-0">
<div class="modal-header">
<h3 class="modal-title fs-5" id="editTeamTitle">Team Number Here</h3>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="close"></button>
</div>
<div class="modal-body">
<form id="editTeamForm">
<div class="row">
<div class="col-md-6 mb-3 mb-md-0">
<label for="editTeamNumber" class="form-label">Team Number</label>
<input type="number" name="editTeamNumber" class="form-control" id="editTeamNumber">
</div>
<div class="col-md-6">
<label for="editTeamSection" class="form-label">Section Letter</label>
<input type="text" name="editTeamSection" class="form-control" id="editTeamSection">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="saveEditTeamModal">Save Changes</button>
</div>
</div>
</div>
</div>
<!-- Edit Member Modal -->
<div class="modal fade" id="editMemberModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content border-0">
<div class="modal-header">
<h3 class="modal-title fs-5" id="editMemberName">Member Name Here</h3>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="close"></button>
</div>
<div class="modal-body">
<form id="editMemberForm">
<div class="row">
<div class="col-md-6 mb-3">
<label for="editMemberFirstName" class="form-label">Forename</label>
<input type="text" name="editMemberFirstName" id="editMemberFirstName" class="form-control" required minlength="1" maxlength="30">
</div>
<div class="col-md-6 mb-3">
<label for="editMemberLastName" class="form-label">Surname</label>
<input type="text" name="editMemberLastName" id="editMemberLastName" class="form-control" required minlength="1" maxlength="30">
</div>
<div class="col-md-6">
<label for="editMemberTeam" class="form-label">Team</label>
<select name="editMemberTeam" id="editMemberTeam" class="form-select" required></select>
</div>
<div class="col-md-6">
<label for="editMemberPeg" class="form-label">Peg Number</label>
<input type="number" name="editMemberPeg" id="editMemberPeg" class="form-control" min="1" max="9999">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="saveEditModal">Save Changes</button>
</div>
</div>
</div>
</div>
{% endblock content %}
{% load static %}
{% block scripts %}
<script type="text/javascript">
const getTeamsUrl = "{% url 'get-teams' %}";
const updateMemberUrl = "{% url 'update-member' %}";
const csrfMiddlewareToken = "{{ csrf_token }}";
</script>
<script src="{% static 'js/teams.js' %}"></script>
{% endblock scripts %}

13
src/mainapp/urls.py Normal file
View File

@ -0,0 +1,13 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('results/', views.results, name='results'),
path('scoreboard/', views.scoreboard, name='scoreboard'),
path('teams/', views.teams, name='teams'),
path('bulk-peg/', views.bulk_create_pegs, name='bulk-peg'),
path('get-teams/', views.get_teams, name='get-teams'),
path('update-member/', views.update_member, name='update-member')
]

116
src/mainapp/views.py Normal file
View File

@ -0,0 +1,116 @@
"""Views for the main app."""
from functools import reduce
from django.shortcuts import render, redirect
from django.http import JsonResponse
from django.db.models import Q, Case, When, Value, IntegerField
from .models import Peg, Team, Member
def index(request):
return render(request, 'index.html')
def results(request):
return render(request, 'results.html')
def scoreboard(request):
return render(request, 'scoreboard.html')
def teams(request):
return render(request, 'teams.html')
def bulk_create_pegs(request):
"""Bulk create pegs"""
number_of_pegs = request.POST.get("pegAmount")
for i in range(int(number_of_pegs)):
Peg.objects.create()
# return to previous page
return redirect(request.META.get('HTTP_REFERER'))
def get_teams(request):
"""Returns a JsonResponse containing a dictionary with a k/v pair for a list of teams.
Args:
request: the web request object.
Returns:
JsonResponse: dictionary of teams like so {'teams': [{}, {}, {}]}.
"""
if not request.POST:
return
search = request.POST.get("search")
sort_teams = request.POST.get("sortTeams") or "team_number"
sort_members = request.POST.get("sortMembers") or "peg_number"
teams = Team.objects.order_by(sort_teams).all()
# Filter out teams that don't contain members being searched for
if search:
search_terms = search.split()
members = Member.objects.filter(
reduce(
lambda x, y: x | y,
[
Q(first_name__icontains=term) | Q(last_name__icontains=term)
for term in search_terms
]
)
)
teams = teams.filter(members__in=members).distinct()
# Create a dictionary for the data that is JSON safe
response_data = {"teams": []}
for team in teams:
team_data = {
"team_number": team.team_number,
"section_letter": team.section_letter if team.section_letter else None,
"members": [
{
"first": member.first_name,
"last": member.last_name,
"id": member.id,
"team": team.team_number,
"peg": member.peg_number,
"section": team.section_letter if team.section_letter else None
}
for member in team.members.order_by(sort_members).all()
]
}
response_data["teams"].append(team_data)
response_data["sortTeams"] = sort_teams
response_data["sortMembers"] = sort_members
return JsonResponse(response_data)
def update_member(request):
"""Update a member. Returns a JsonResponse with the updated teams."""
if not request.POST:
return
# Get the updated values
member_id = request.POST.get("memberId")
first = request.POST.get("first")
last = request.POST.get("last")
team_number = request.POST.get("teamNumber")
peg_number = request.POST.get("pegNumber")
# Get the member and team
member = Member.objects.get(id=member_id)
team = Team.objects.get(team_number=team_number)
# Update the member
member.first_name = first
member.last_name = last
member.team = team
member.peg_number = peg_number
member.save()
return get_teams(request)

View File

@ -6,7 +6,7 @@ import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Results.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:

View File

@ -58,10 +58,6 @@
font-family: "Source Sans Pro";
}
.font-helvetica {
font-family: Arial, Helvetica, sans-serif;
}
.pencil-btn {
width: 32px;
height: 32px;
@ -105,7 +101,6 @@
.btn-outline-company {
border: 1px solid #04385c;
color: #04385c;
}
.btn-outline-company:hover {
@ -123,16 +118,4 @@ input[type='radio']:checked {
background-color: #04385c;
border: 1px solid #04385c;
box-shadow: none;
}
.light-tooltip {
--bs-tooltip-bg: #04385c;
}
html, body {
overflow: hidden !important;
max-width: 100vw;
height: 100%;
margin: 0;
}
}

View File

@ -53,7 +53,7 @@
-webkit-overflow-scrolling: touch;
}
/* .card{
.card{
border-radius: 4px;
background: #fff;
box-shadow: 0 6px 10px rgba(0,0,0,.08), 0 0 6px rgba(0,0,0,.05);
@ -64,4 +64,4 @@
.card:hover{
transform: scale(1.05);
box-shadow: 0 10px 20px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);
} */
}

2218
src/static/css/keyframes.css Normal file

File diff suppressed because it is too large Load Diff

View File

Some files were not shown because too many files have changed in this diff Show More