Skip to content
Merged
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
9 changes: 9 additions & 0 deletions src/apps/api/serializers/competitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ class Meta:
'allow_robot_submissions',
'competition_type',
'fact_sheet',
'reward',
'contact_email',
'report',
)

def validate_phases(self, phases):
Expand Down Expand Up @@ -297,6 +300,9 @@ class Meta:
'competition_type',
'fact_sheet',
'forum',
'reward',
'contact_email',
'report',
)

def get_leaderboards(self, instance):
Expand Down Expand Up @@ -326,6 +332,9 @@ class Meta:
'logo',
'description',
'competition_type',
'reward',
'contact_email',
'report',
)


Expand Down
17 changes: 9 additions & 8 deletions src/apps/competitions/migrations/0026_auto_20201110_1932.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Generated by Django 2.2.13 on 2020-11-10 19:32
# Manual edit on 2023-08-22 by Adrien Pavao

import django.contrib.postgres.fields.jsonb
from django.db import migrations

from competitions.models import Competition

def set_blank_fact_sheet_to_null(apps, schema_editor):
Competition = apps.get_model('competitions', 'Competition')
for comp in Competition.objects.all():
if comp.fact_sheet == "":
comp.fact_sheet = None
comp.save()

class Migration(migrations.Migration):

def set_blank_fact_sheet_to_null(self, schema_editor):
for comp in Competition.objects.all():
if comp.fact_sheet == "":
comp.fact_sheet = None
comp.save()
class Migration(migrations.Migration):

dependencies = [
('competitions', '0025_submission_is_specific_task_re_run'),
Expand All @@ -24,5 +25,5 @@ def set_blank_fact_sheet_to_null(self, schema_editor):
name='fact_sheet',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=None, max_length=4096, null=True),
),
migrations.RunPython(set_blank_fact_sheet_to_null),
migrations.RunPython(set_blank_fact_sheet_to_null, migrations.RunPython.noop),
]
28 changes: 28 additions & 0 deletions src/apps/competitions/migrations/0035_auto_20230806_0715.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.2.17 on 2023-08-06 07:15

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('competitions', '0034_auto_20230727_1147'),
]

operations = [
migrations.AddField(
model_name='competition',
name='contact_email',
field=models.EmailField(blank=True, max_length=256, null=True),
),
migrations.AddField(
model_name='competition',
name='report',
field=models.CharField(blank=True, max_length=256, null=True),
),
migrations.AddField(
model_name='competition',
name='reward',
field=models.CharField(blank=True, max_length=256, null=True),
),
]
4 changes: 4 additions & 0 deletions src/apps/competitions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class Competition(ChaHubSaveMixin, models.Model):

fact_sheet = JSONField(blank=True, null=True, max_length=4096, default=None)

contact_email = models.EmailField(max_length=256, null=True, blank=True)
reward = models.CharField(max_length=256, null=True, blank=True)
report = models.CharField(max_length=256, null=True, blank=True)

def __str__(self):
return f"competition-{self.title}-{self.pk}-{self.competition_type}"

Expand Down
2 changes: 2 additions & 0 deletions src/apps/competitions/unpackers/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def __init__(self, *args, **kwargs):
"description": self.competition_yaml.get("description", ""),
"competition_type": self.competition_yaml.get("competition_type", "competition"),
"fact_sheet": self.competition_yaml.get("fact_sheet", None),
"reward": self.competition_yaml.get("reward", None),
"contact_email": self.competition_yaml.get("contact_email", None),
"pages": [],
"phases": [],
"leaderboards": [],
Expand Down
Binary file added src/static/img/trophy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions src/static/riot/competitions/detail/_header.tag
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
</div>
</div>
</div>
<div class="row">
<div class="reward-container" if="{competition.reward}">
<img class="reward-icon" src="/static/img/trophy.png">
<div class="reward-text">{competition.reward}</div>
</div>
</div>
<div if="{competition.admin}">
<a href="{URLS.COMPETITION_EDIT(competition.id)}" class="ui button">Edit</a>
<button class="ui small button" onclick="{show_modal.bind(this, '.manage-participants.modal')}">
Expand All @@ -36,6 +42,7 @@
<div>
<span class="detail-label">Organized by:</span>
<span class="detail-item">{competition.created_by}</span>
<span if="{competition.contact_email}">(<span class="contact-email">{competition.contact_email}</span>)</span>
</div>
<div>
<span class="detail-label">Current phase ends:</span>
Expand All @@ -61,6 +68,15 @@
<i class="ui copy icon"></i>
</span>
</div>
<!-- Competition Report -->
<div class="competition-secret-key" if="{competition.report}">
<span class="report-label">Competition Report:</span>
<span id="report-url">{ competition.report }</span>
<span onclick="{copy_report_url}" class="ui send-pop-report" data-content="Copied!">
<i class="ui copy icon"></i>
</span>

</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -230,6 +246,16 @@
$('.send-pop-docker').popup('toggle')
}

self.copy_report_url = function () {
let range = document.createRange();
range.selectNode(document.getElementById("report-url"));
window.getSelection().removeAllRanges(); // clear current selection
window.getSelection().addRange(range); // to select text
document.execCommand("copy");
window.getSelection().removeAllRanges();// to deselect
$('.send-pop-report').popup('toggle')
}

self.get_end_date = function (competition) {
let end_date = _.get(_.find(competition.phases, {status: 'Current'}), 'end')
return end_date ? pretty_date(end_date) : 'Never'
Expand Down Expand Up @@ -269,12 +295,20 @@
.competition-secret-key
font-size 13px

.contact-email
font-size 1em
color $teal
font-family 'Overpass Mono', monospace

.secret-label
color $red

.docker-label
color $teal

.report-label
color $teal

.secret-url
color $blue

Expand Down Expand Up @@ -313,5 +347,25 @@
thead > tr > th
color $blue !important
background-color $lightblue !important

.reward-container
background linear-gradient(to right, #ff9966, #ff5e62)
color #fff
border 1px solid #E6E9EB
border-radius 5px
padding 10px
display flex
align-items center
margin-left 1rem

.reward-icon
width 40px
height 40px
margin-right 10px

.reward-text
font-size 24px
font-weight 900
display inline-block
</style>
</comp-detail-header>
18 changes: 18 additions & 0 deletions src/static/riot/competitions/editor/_competition_details.tag
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@
</a>
</sup>
</div>
<div class="field">
<label>Competition Reward</label>
<input type="text" ref="reward" placeholder="Example: $1000 for the top participant" onchange="{form_updated}">
</div>
<div class="field">
<label>Organizer Contact Email</label>
<input type="email" ref="contact_email" placeholder="Example: email@example.com" onchange="{form_updated}">
</div>
<div class="field">
<label>Competition Report</label>
<input type="text" ref="report" placeholder="Example: https://example.com/report.pdf" onchange="{form_updated}">
</div>
</div>

<script>
Expand Down Expand Up @@ -182,6 +194,9 @@
self.data["docker_image"] = $(self.refs.docker_image).val()
self.data["competition_type"] = $(self.refs.competition_type).dropdown('get value')
self.data['fact_sheet'] = self.serialize_fact_sheet_questions()
self.data['reward'] = $(self.refs.reward).val()
self.data['contact_email'] = $(self.refs.contact_email).val()
self.data['report'] = $(self.refs.report).val()
if (self.data.fact_sheet === false){
is_valid = false
}
Expand Down Expand Up @@ -308,6 +323,9 @@
}
self.refs.detailed_results.checked = competition.enable_detailed_results
$(self.refs.docker_image).val(competition.docker_image)
$(self.refs.reward).val(competition.reward)
$(self.refs.contact_email).val(competition.contact_email)
$(self.refs.report).val(competition.report)
if(competition.fact_sheet !== null){
for(question in competition.fact_sheet){
var q_json = competition.fact_sheet[question]
Expand Down
6 changes: 5 additions & 1 deletion src/static/riot/competitions/editor/form.tag
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@

self.update({errors: errors})
}
toastr.error("Creation failed, error occurred")
if(self.opts.competition_id){
toastr.error("Creation failed, error occurred")
}else{
toastr.error("Updation failed, error occurred")
}
})

}
Expand Down
3 changes: 2 additions & 1 deletion src/static/riot/competitions/public-list.tag
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
</div>
<div class="comp-stats">
{pretty_date(competition.created_when)}
<div class="ui divider"></div>
<div if="{!competition.reward}" class="ui divider"></div>
<div if="{competition.reward}"><img width="30" height="30" src="/static/img/trophy.png"></div>
<strong>{competition.participant_count}</strong> Participants
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/static/riot/competitions/tile/competition_tile.tag
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
</div>
<div class="comp-stats">
{pretty_date(created_when)}
<div class="ui divider"></div>
<div if="{!reward}" class="ui divider"></div>
<div if="{reward}"><img width="30" height="30" src="/static/img/trophy.png"></div>
<strong>{participant_count}</strong> Participants
</div>
</div>
Expand Down
8 changes: 7 additions & 1 deletion src/static/stylus/forum.styl
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.forum-contact
margin-top 20px

.forum-contact-email
color: #4183c4

.forum-post
background-color #fff
padding 10px
Expand Down Expand Up @@ -44,4 +50,4 @@
border-radius: 2px

.forum-pin-icon
color #017BFE
color #017BFE
10 changes: 10 additions & 0 deletions src/templates/forums/base_forum.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ <h1>{{ forum.competition.title }} Forum</h1>
</div>
</div>

{% if forum.competition.contact_email %}
<div class="row">
<div class="forum-contact">
<span>Contact Email: </span>
<span class="forum-contact-email">{{ forum.competition.contact_email }}</span>

</div>
</div>
{% endif %}

<div class="row">
<div class="col-lg-12">
<div class="panel forum-panel">
Expand Down