Skip to content

Commit c944acb

Browse files
DidayoloObada Haddad
authored andcommitted
Start date of first phrase in UI
1 parent c896ce6 commit c944acb

File tree

6 files changed

+15
-7
lines changed

6 files changed

+15
-7
lines changed

src/apps/api/serializers/competitions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ class CompetitionSerializerSimple(serializers.ModelSerializer):
458458
created_by = serializers.CharField(source='created_by.username', read_only=True)
459459
owner_display_name = serializers.SerializerMethodField()
460460
participants_count = serializers.IntegerField(read_only=True)
461+
first_phase_start = serializers.DateTimeField(read_only=True)
461462

462463
class Meta:
463464
model = Competition
@@ -467,6 +468,7 @@ class Meta:
467468
'created_by',
468469
'owner_display_name',
469470
'created_when',
471+
'first_phase_start',
470472
'published',
471473
'participants_count',
472474
'logo',
@@ -477,8 +479,7 @@ class Meta:
477479
'contact_email',
478480
'report',
479481
'is_featured',
480-
'submissions_count',
481-
'participants_count'
482+
'submissions_count'
482483
)
483484

484485
def get_created_by(self, obj):

src/apps/competitions/models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ def bundle_dataset(self):
102102
def all_organizers(self):
103103
return [self.created_by] + list(self.collaborators.all())
104104

105+
@property
106+
def first_phase_start(self):
107+
first_phase = self.phases.filter(index=0).first()
108+
if first_phase and first_phase.start:
109+
return first_phase.start
110+
return self.created_when
111+
105112
def user_has_admin_permission(self, user):
106113
if isinstance(user, int):
107114
try:

src/static/riot/competitions/competition_list.tag

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<tr>
1919
<th>Name</th>
2020
<th width="100">Type</th>
21-
<th width="125">Uploaded...</th>
21+
<th width="125">Uploaded</th>
2222
<th width="50px">Publish</th>
2323
<th width="50px">Edit</th>
2424
<th width="50px">Delete</th>
@@ -61,7 +61,7 @@
6161
<thead>
6262
<tr>
6363
<th>Name</th>
64-
<th width="125px">Uploaded...</th>
64+
<th width="125px">Uploaded</th>
6565
</tr>
6666
</thead>
6767
<tbody>

src/static/riot/competitions/public-list.tag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
</div>
7676
</a>
7777
<div class="comp-stats">
78-
{pretty_date(competition.created_when)}
78+
{pretty_date(competition.first_phase_start)}
7979
<div if="{!competition.reward && ! competition.report}" class="ui divider"></div>
8080
<div>
8181
<span if="{competition.reward}"><img width="30" height="30" src="/static/img/trophy.png"></span>

src/static/riot/competitions/tile/competition_tile.tag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</div>
2020
</a>
2121
<div class="comp-stats" id="compStats">
22-
{pretty_date(created_when)}
22+
{pretty_date(first_phase_start)}
2323
<div if="{!reward && !report}" class="ui divider"></div>
2424
<div>
2525
<span if="{reward}"><img width="30" height="30" src="/static/img/trophy.png"></span>

src/static/riot/profiles/profile_detail.tag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</div>
5252
</a>
5353
<div class="comp-stats">
54-
{pretty_date(competition.created_when)}
54+
{pretty_date(competition.first_phase_start)}
5555
<div if="{!competition.reward && ! competition.report}" class="ui divider"></div>
5656
<div>
5757
<span if="{competition.reward}"><img width="30" height="30" src="/static/img/trophy.png"></span>

0 commit comments

Comments
 (0)