Commit 00be3101 authored by Elger Jonker's avatar Elger Jonker

nicer colors, link to your team

parent bdf06372
......@@ -42,6 +42,9 @@ class ContestForm(forms.Form):
# code='invalid', )
# django forms are absolutely terrible. For cosmetic changes such as not showing an empty ------ in a
# RadioSelect, there is a lot of hacking, terrible answers on stackoverflow and other mismatches available
# to the point that you're working hours to fix a miniscule thing that should be trivial.
class TeamForm(forms.Form):
contest = Contest()
......@@ -64,7 +67,9 @@ class TeamForm(forms.Form):
team = cleaned_data.get("team")
secret = cleaned_data.get("secret")
# wait a second to deter brute force attacks (you can still do them)
# wait a second to deter brute force attacks (you can still do them, but good luck cracking one...)
# 16 positions, 26 characters... each with 1 second delay. (you can of course try brute force in another
# submit form perhaps?
time.sleep(1)
# it's possible NOT to select a team, in that case, don't try and validate secret.
......
# Generated by Django 2.1.3 on 2018-12-03 10:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('game', '0012_contest_admin_user'),
]
operations = [
migrations.AlterField(
model_name='team',
name='name',
field=models.CharField(default='Unspecified', help_text='Whatever name the team wants. Must be at least PEGI 88.', max_length=42, verbose_name='Team name'),
),
]
# Generated by Django 2.1.3 on 2018-12-03 10:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('game', '0013_auto_20181203_1038'),
]
operations = [
migrations.AlterField(
model_name='team',
name='name',
field=models.CharField(help_text='Whatever name the team wants. Must be at least PEGI 88.', max_length=42, verbose_name='Team name'),
),
]
# Generated by Django 2.1.3 on 2018-12-03 10:52
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('game', '0014_auto_20181203_1038'),
]
operations = [
migrations.AlterField(
model_name='team',
name='name',
field=models.CharField(default=None, help_text='Whatever name the team wants. Must be at least PEGI 88.', max_length=42, verbose_name='Team name'),
),
]
# Generated by Django 2.1.3 on 2018-12-03 10:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('game', '0015_auto_20181203_1052'),
]
operations = [
migrations.AlterField(
model_name='team',
name='name',
field=models.CharField(help_text='Whatever name the team wants. Must be at least PEGI 88.', max_length=42, verbose_name='Team name'),
),
]
from colorful.fields import RGBColorField
from django.contrib.auth.models import User
from django.db import models
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from django_countries.fields import CountryField
from djgeojson.fields import GeoJSONField
......@@ -100,7 +101,8 @@ class Team(models.Model):
verbose_name_plural = _('teams')
def __str__(self):
return "%s/%s" % (self.participating_in_contest, self.name)
return mark_safe("%s/<span style='background-color: %s'>%s</span>" % (
self.participating_in_contest, self.color, self.name))
class OrganizationSubmission(models.Model):
......
......@@ -3,7 +3,9 @@
{% comment for="What is the origin of -?" %}{% endcomment %}
{% if team and team.name != "-" %}
<div class="alert alert-success" role="alert">
<p style="width: 100%; text-align: center;"><i>You are part of team: {{ team.name | truncatechars:24 }}</i><br>
<p style="width: 100%; text-align: center;"><i>You are part of team: <span style="background-color: {{ team.color }}">{{ team.name | truncatechars:24 }}</span>,
{% for score in scores %} {% if team.name == score.team %} currently placed at <a href="#{{ forloop.counter }}">#{{ forloop.counter }}</a>. {% endif %} {% endfor %}</i>
<br>
<br>
<a href="/game/submit_organization" role="button" class="btn btn-success">Submit Organization</a>
<a href="/game/submit_url" role="button" class="btn btn-success">Submit URL</a>
......@@ -16,19 +18,19 @@
<p style="width: 100%; text-align: center; font-size: 2em;">Starts at {{ contest.from_moment }}. Deadline: {{ contest.until_moment }}.</p>
{% for score in scores %}
<table class="table table-sm table-striped table-bordered table-hover" style="width: 29%; float:left; margin: 20px;">
<table class="table table-sm table-striped table-bordered table-hover"
style="width: 29%; float:left; margin: 20px; box-shadow: 0px 13px 82px -47px rgba(0,0,0,0.75); background-color: {{ score.team_color_soft }}; {% if team.name == score.team %} border: 1px solid lightgreen; {% endif %}">
<tbody>
<tr><td colspan="3" style="font-weight: bold; font-family: impact, sans-serif; font-size: 6em; text-align: center;"># {{ forloop.counter }}</td></tr>
<tr><td colspan="3" style="font-weight: bold; font-family: impact, sans-serif; font-size: 6em; text-align: center;"><a name="{{ forloop.counter }}"></a># {{ forloop.counter }}</td></tr>
<tr><td colspan="3" style="font-size: 3em; text-align: center; background-color: {{ score.team_color }}; height: 160px; vertical-align: middle;">{{ score.team | truncatechars:24 }}</td></tr>
<tr><td>Total score</td> <td colspan="2" style="text-align: center; font-size: 2em;">{{ score.total_score }}</td></tr>
<tr><td>Organizations</td> <td>{{ score.added_organizations }}</td><td><small>* {{ score.added_organizations_multiplier }} = {{ score.added_organizations_score }}</small></td></tr>
<tr><td><small>Rejected</small></td> <td><small>{{ score.rejected_organizations }}</small></td><td><small>* -{{ score.rejected_organizations_multiplier }} = -{{ score.rejected_organizations_score }}</small></td></tr>
<tr><td>Urls</td> <td>{{ score.added_urls }}</td><td><small>* {{ score.added_urls_multiplier }} = {{ score.added_urls_score }}</small></td></tr>
<tr><td><small>Rejected</small></td> <td><small>{{ score.rejected_urls }}</small></td><td><small>* -{{ score.rejected_urls_multiplier }} = -{{ score.rejected_urls_score }}</small></td></tr>
<tr><td>High risk</td> <td>{{ score.high }}</td><td><small>* {{ score.high_multiplier }} = {{ score.high_score }}</small></td></tr>
<tr><td>Medium risk</td> <td>{{ score.medium }}</td><td><small> * {{ score.medium_multiplier }} = {{ score.medium_score }}</small></td></tr>
<tr><td>Low risk</td> <td>{{ score.low }}</td><td><small>* {{ score.low_multiplier }} = {{ score.low_score }}</small></td></tr>
<tr><td>High risk issues</td> <td>{{ score.high }}</td><td><small>* {{ score.high_multiplier }} = {{ score.high_score }}</small></td></tr>
<tr><td>Medium risk issues</td> <td>{{ score.medium }}</td><td><small> * {{ score.medium_multiplier }} = {{ score.medium_score }}</small></td></tr>
<tr><td>Low risk issues</td> <td>{{ score.low }}</td><td><small>* {{ score.low_multiplier }} = {{ score.low_score }}</small></td></tr>
</tbody>
</table>
{% endfor %}
......
......@@ -2,6 +2,11 @@
{% load crispy_forms_tags %}
{% block content %}
<style>
input[type="radio"] {
margin-right: 6px;
}
</style>
<h1>Select your team</h1>
<p>Feel free to join, mix and match teams on the go. But please don't leak the secret for your team. If you do,
other teams might submit bogus urls which will be rejected and will ruin your score.</p>
......
......@@ -202,9 +202,18 @@ def scores(request):
'url': 250,
}
import spectra
color = spectra.html(team.color.upper())
# nope, deep frying doesn't help us
# color = color.saturate(100) # deep fry the color, so something remains even after insane brighten
color = color.brighten(10)
score = {
'team': team.name,
'team_color': team.color,
# transparency makes it lighter and more beautiful.
'team_color_soft': "%s%s" % (color.hexcode, '33'),
'high': final_calculation['high'],
'high_multiplier': score_multiplier['high'],
'high_score': final_calculation['high'] * score_multiplier['high'],
......
......@@ -130,3 +130,6 @@ docker
# generic retry library
tenacity
# game
spectra
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment