Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show semester name and school year when displaying semsester and year. #1163

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions trojsten/contests/migrations/0011_competition_founded.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.10 on 2018-06-13 21:44
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('contests', '0010_round_results_final'),
]

operations = [
migrations.AddField(
model_name='competition',
name='founded',
field=models.IntegerField(blank=True, null=True, verbose_name='Year of foundation'),
),
]
14 changes: 8 additions & 6 deletions trojsten/contests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class Competition(models.Model):
required_user_props = models.ManyToManyField(
UserPropertyKey, limit_choices_to={'hidden': False}, verbose_name='Povinné vlastnosti človeka', blank=True
)
founded = models.IntegerField(verbose_name=_('Year of foundation'), blank=True, null=True)

@property
def rules(self):
Expand Down Expand Up @@ -121,8 +122,11 @@ class Meta:
verbose_name_plural = 'Časti'

def __str__(self):
return '%i. (%s) časť, %i. ročník %s'\
% (self.number, self.name, self.year, self.competition)
semester_name = '(%s) ' % self.name if len(self.name) > 0 else ''
school_year = '(%d/%d) ' % (self.competition.founded + self.year, self.competition.founded + self.year + 1) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do funkcie, viď nižšie

if self.competition.founded else ''
return '%i. %sčasť, %i. ročník %s%s'\
% (self.number, semester_name, self.year, school_year, self.competition)

def short_str(self):
return '%i. (%s) časť'\
Expand Down Expand Up @@ -239,11 +243,9 @@ class Meta:
verbose_name_plural = 'Kolá'

def __str__(self):
return '%i. kolo, %i. časť, %i. ročník %s' % (
return '%i. kolo, %s' % (
self.number,
self.semester.number,
self.semester.year,
self.semester.competition,
self.semester,
)

def short_str(self):
Expand Down
5 changes: 2 additions & 3 deletions trojsten/contests/templates/trojsten/contests/list_tasks.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

{% block page_header %}
<h1>
Zadania
Zadania<br>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Toto by sme mohli mať ujednotené, že či teda ide názov kola vedľa alebo popod.
Podľa mňa keď sa to zmestí v pohode do riadku, tak nech je to vedľa (nech zbytočne neplytváme vertikálnym miestom).
Ak to vyzerá škaredo, možno stačí medzi pridať väčšiu medzeru?

Vyskytuje sa to ešte minimálne v list_active_rounds_tasks, v round_submit a tiež vo výsledkovkách ... a možno aj inde - najlepšie to skúsiť vyregexiť v kóde? preklikať sa stránkou?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pôvodne tam bolo Zadania # kola # časti..., teda názov časti by bolo treba vyskloňovať, tak preto som to oddelil, neoddelené si tak viac pýta skloňovanie :D, ale asi bude v pohode v riadku a nevyskloňované. Alebo mám sa nejako pohrať so skloňovaním?

Preklikával som sa, na tých dvoch miestach, čo si dal, sa volá str() na round a to som prerobil, aby zobrazovalo aj názov časti, aj šk. rok. Ešte to checknem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hej, na niektorých stránkach je to vyskloňované (aj pri výsledkoch) a na ostatných sa dáva priamo {{round}}, v pohode to tam nechaj nevyskloňované.

A viem, že sa tam volá str. Tie ostatné linky som tam dal hlavne pre ukázanie ako je to spravené inde - možno tam tiež pridať nejako medzeru? miesto small spraviť class v css?

<small>
{{ round.number }}. kola {{ round.semester.number }}. časti
{{ round.semester.year }}. ročníka {{ round.semester.competition.name }}
{{ round }}
{% if not round.visible %}
<span class="label label-danger">skryté</span>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<tr>
<th colspan="3" class="active">
{{ year }}. ročník
{% if competition.founded %}
({{ competition.founded|add:year }}/{{ competition.founded|add:year|add:"1" }})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asi by bolo vhodnejšie spraviť metódu pre semester že school_year ktorá vráti string 2017/2018 a volať tú.

{% endif %}
</th>
</tr>
</thead>
Expand All @@ -20,7 +23,7 @@
{% endif %}
</td>
<td>
{{ round.semester.number }}. časť
{{ round.semester.number }}.{% if round.semester.name %} ({{ round.semester.name }}){% endif %} časť
</td>
<td style="text-align:right;">
<a href="{% url 'task_list' round_id=round.id %}" class="btn btn-primary btn-sm">
Expand Down
1 change: 1 addition & 0 deletions trojsten/contests/templatetags/archive_parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def show_round_list(user, competition):
all_rounds = get_rounds_by_year(user, competition)
data = {
'all_rounds': all_rounds,
'competition': competition,
}
return data

Expand Down
24 changes: 19 additions & 5 deletions trojsten/contests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_one_year(self):
competition = Competition.objects.create(name='TestCompetition')
competition.sites.add(self.site)
semester = Semester.objects.create(
number=1, name='Test semester', competition=competition, year=1
number=1, competition=competition, year=1
)
Round.objects.create(number=1, semester=semester, solutions_visible=True, visible=True)

Expand All @@ -65,6 +65,20 @@ def test_one_year(self):
# @ToDo: translations
self.assertContains(response, "Výsledky")

def test_one_semester_with_name(self):
competition = Competition.objects.create(name='TestCompetition')
competition.sites.add(self.site)
semester = Semester.objects.create(
number=1, name='test semseter', competition=competition, year=1
)
Round.objects.create(number=1, semester=semester, solutions_visible=True, visible=True)

response = self.client.get(self.url)
# @ToDo: translations
self.assertContains(response, "1. (test semseter) časť")
# @ToDo: translations
self.assertNotContains(response, "1. časť")

def test_two_competitions(self):
competition1 = Competition.objects.create(name='TestCompetition 42')
competition1.sites.add(self.site)
Expand All @@ -80,10 +94,10 @@ def test_two_competitions(self):
self.assertContains(response, "TestCompetition 47")

semester1 = Semester.objects.create(
number=42, name='Test semester 42', competition=competition1, year=42
number=42, competition=competition1, year=42
)
semester2 = Semester.objects.create(
number=47, name='Test semester 47', competition=competition2, year=47
number=47, competition=competition2, year=47
)
Round.objects.create(number=42, semester=semester1, solutions_visible=True, visible=True)
Round.objects.create(number=47, semester=semester2, solutions_visible=True, visible=True)
Expand Down Expand Up @@ -129,10 +143,10 @@ def test_two_semester(self):
competition = Competition.objects.create(name='TestCompetition')
competition.sites.add(self.site)
semester1 = Semester.objects.create(
number=1, name='Test semester 1', competition=competition, year=1
number=1, competition=competition, year=1
)
semester2 = Semester.objects.create(
number=2, name='Test semester 2', competition=competition, year=1
number=2, competition=competition, year=1
)
Round.objects.create(number=1, semester=semester1, solutions_visible=True, visible=True)

Expand Down
Loading