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
20 changes: 18 additions & 2 deletions src/apps/api/serializers/competitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ class CompetitionCreateSerializer(CompetitionSerializer):

class CompetitionDetailSerializer(serializers.ModelSerializer):
created_by = serializers.CharField(source='created_by.username', read_only=True)
owner_display_name = serializers.SerializerMethodField()
logo_icon = NamedBase64ImageField(allow_null=True)
pages = PageSerializer(many=True)
phases = PhaseDetailSerializer(many=True)
Expand All @@ -346,6 +347,7 @@ class Meta:
'published',
'secret_key',
'created_by',
'owner_display_name',
'created_when',
'logo',
'logo_icon',
Expand All @@ -371,7 +373,7 @@ class Meta:
'reward',
'contact_email',
'report',
'whitelist_emails'
'whitelist_emails',
)

def get_leaderboards(self, instance):
Expand All @@ -389,9 +391,14 @@ def get_whitelist_emails(self, instance):
whitelist_emails_list = [entry.email for entry in whitelist_emails_query]
return whitelist_emails_list

def get_owner_display_name(self, obj):
# Get the user's display name if not None, otherwise return username
return obj.created_by.display_name if obj.created_by.display_name else obj.created_by.username


class CompetitionSerializerSimple(serializers.ModelSerializer):
created_by = serializers.CharField(source='created_by.username')
created_by = serializers.CharField(source='created_by.username', read_only=True)
owner_display_name = serializers.SerializerMethodField()
participant_count = serializers.IntegerField(read_only=True)

class Meta:
Expand All @@ -400,6 +407,7 @@ class Meta:
'id',
'title',
'created_by',
'owner_display_name',
'created_when',
'published',
'participant_count',
Expand All @@ -411,6 +419,14 @@ class Meta:
'report',
)

def get_created_by(self, obj):
# Get the user's display name if not None, otherwise return username
return obj.created_by.display_name if obj.created_by.display_name else obj.created_by.username

def get_owner_display_name(self, obj):
# Get the user's display name if not None, otherwise return username
return obj.created_by.display_name if obj.created_by.display_name else obj.created_by.username


PageSerializer.competition = CompetitionSerializer(many=True, source='competition')

Expand Down
7 changes: 6 additions & 1 deletion src/apps/api/serializers/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class Meta:


class DataDetailSerializer(serializers.ModelSerializer):
created_by = serializers.CharField(source='created_by.username')
created_by = serializers.CharField(source='created_by.username', read_only=True)
owner_display_name = serializers.SerializerMethodField()
competition = serializers.SerializerMethodField()
value = serializers.CharField(source='key', required=False)

Expand All @@ -83,6 +84,7 @@ class Meta:
fields = (
'id',
'created_by',
'owner_display_name',
'created_when',
'name',
'type',
Expand All @@ -108,6 +110,9 @@ def get_competition(self, obj):
}
return None

def get_owner_display_name(self, instance):
return instance.created_by.display_name if instance.created_by.display_name else instance.created_by.username


class DataGroupSerializer(serializers.ModelSerializer):
class Meta:
Expand Down
15 changes: 14 additions & 1 deletion src/apps/api/serializers/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def get_validated(self, instance):


class TaskDetailSerializer(WritableNestedModelSerializer):
created_by = serializers.CharField(source='created_by.username', read_only=True, required=False)
created_by = serializers.CharField(source='created_by.username', read_only=True)
owner_display_name = serializers.SerializerMethodField()
input_data = DataSimpleSerializer(read_only=True)
ingestion_program = DataSimpleSerializer(read_only=True)
reference_data = DataSimpleSerializer(read_only=True)
Expand All @@ -107,6 +108,7 @@ class Meta:
'description',
'key',
'created_by',
'owner_display_name',
'created_when',
'is_public',
'validated',
Expand All @@ -126,19 +128,26 @@ def get_validated(self, task):
def get_shared_with(self, instance):
return self.context['shared_with'][instance.pk]

def get_owner_display_name(self, instance):
# Get the user's display name if not None, otherwise return username
return instance.created_by.display_name if instance.created_by.display_name else instance.created_by.username


class TaskListSerializer(serializers.ModelSerializer):
solutions = SolutionListSerializer(many=True, required=False, read_only=True)
value = serializers.CharField(source='key', required=False)
competitions = serializers.SerializerMethodField()
shared_with = serializers.SerializerMethodField()
created_by = serializers.CharField(source='created_by.username', read_only=True)
owner_display_name = serializers.SerializerMethodField()

class Meta:
model = Task
fields = (
'id',
'created_when',
'created_by',
'owner_display_name',
'key',
'name',
'solutions',
Expand All @@ -160,6 +169,10 @@ def get_competitions(self, instance):
def get_shared_with(self, instance):
return self.context['shared_with'][instance.pk]

def get_owner_display_name(self, instance):
# Get the user's display name if not None, otherwise return username
return instance.created_by.display_name if instance.created_by.display_name else instance.created_by.username


class PhaseTaskInstanceSerializer(serializers.HyperlinkedModelSerializer):
task = serializers.SlugRelatedField(queryset=Task.objects.all(), required=True, allow_null=False, slug_field='key',
Expand Down
3 changes: 3 additions & 0 deletions src/apps/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ def get_context_data(self, *args, **kwargs):
queue_name = "*" if submission.queue is None else submission.queue.name
submission.competition_queue = queue_name

# Add submission owner display name
submission.owner_display_name = submission.owner.display_name if submission.owner.display_name else submission.owner.username

return context

def format_file_size(self, file_size):
Expand Down
2 changes: 1 addition & 1 deletion src/static/riot/competitions/detail/_header.tag
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<!-- Main information -->
<div>
<span class="detail-label">Organized by:</span>
<span class="detail-item"><a href="/profiles/user/{competition.created_by}" target="_BLANK">{competition.created_by}</a></span>
<span class="detail-item"><a href="/profiles/user/{competition.created_by}" target="_BLANK">{competition.owner_display_name}</a></span>
<span if="{competition.contact_email}">(<span class="contact-email">{competition.contact_email}</span>)</span>
</div>
<div>
Expand Down
2 changes: 1 addition & 1 deletion src/static/riot/datasets/management.tag
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
<tbody>
<tr>
<td>{selected_row.key}</td>
<td><a href="/profiles/user/{selected_row.created_by}/" target=_blank>{selected_row.created_by}</a></td>
<td><a href="/profiles/user/{selected_row.created_by}/" target=_blank>{selected_row.owner_display_name}</a></td>
<td>{pretty_date(selected_row.created_when)}</td>
<td>{_.startCase(selected_row.type)}</td>
<td>{_.startCase(selected_row.is_public)}</td>
Expand Down
145 changes: 118 additions & 27 deletions src/static/riot/profiles/profile_detail.tag
Original file line number Diff line number Diff line change
Expand Up @@ -34,47 +34,125 @@

<!-- Second Column -->
<div class="eight wide column">
<!-- Name -->
<span class="header content">{selected_user.first_name} {selected_user.last_name}</span>

<!-- Section Personal Info -->
<div id="horiz-margin" class="ui horizontal divider">Personal Info</div>

<!-- Name -->
<div if="{ selected_user.first_name && selected_user.last_name}" class="about-block">
<div class="flex-container">
<div class="label">Name</div>
<div class="value">{selected_user.first_name} {selected_user.last_name}</div>
</div>
</div>

<!-- Do not show to other users -->
<div if="{selected_user.id === CODALAB.state.user.id}">
<!-- Email -->
<div if="{ selected_user.email }" class="about-block">
<div class="flex-container">
<div class="label">Email</div>
<div class="value">{selected_user.email}</div>
</div>
</div>

<!-- Username -->
<div if="{ selected_user.username }" class="about-block">
<div class="flex-container">
<div class="label">Username</div>
<div class="value">{selected_user.username}</div>
</div>
</div>

<!-- Display Name -->
<div if="{ selected_user.display_name }" class="about-block">
<div class="flex-container">
<div class="label">Display Name</div>
<div class="value">{selected_user.display_name}</div>
</div>
</div>
</div>

<!-- About -->
<!-- Section About -->
<div id="horiz-margin" class="ui horizontal divider">About</div>
<div class="about-block">
<i class="marker icon"></i>
<span if="{!selected_user.location}" class="text-placeholder">Location</span>
<span if="{selected_user.location}">{selected_user.location}</span>

<!-- Location -->
<div if="{ selected_user.location }" class="about-block">
<div class="flex-container">
<div class="label"></i>Location</div>
<div class="value">{selected_user.location}</div>
</div>
</div>
<div class="about-block">
<i class="user icon"></i>
<span if="{!selected_user.title}" class="text-placeholder">Job Title</span>
<span if="{selected_user.title}">{selected_user.title}</span>

<!-- Job title -->
<div if="{ selected_user.title }" class="about-block">
<div class="flex-container">
<div class="label">Job Title</div>
<div class="value">{selected_user.title}</div>
</div>
</div>

<!-- Bio -->
<!-- Empty About Message -->
<span if="{!selected_user.location && !selected_user.title}" class="text-placeholder">Update your profile to show your job title and location here.</span>



<!-- Section Bio -->
<div id="horiz-margin" class="ui horizontal divider">Bio</div>
<span if="{!selected_user.biography}" class="text-placeholder">No bio found! Update your profile to show your bio here.</span>
<!-- Bio -->
<div if="{selected_user.biography}" class="ui justified container">{selected_user.biography}</div>

<!-- Links -->
<!-- Empty Bio Message -->
<span if="{!selected_user.biography}" class="text-placeholder">Update your profile to show your bio here.</span>


<!-- Section Links -->
<div id="horiz-margin" class="ui horizontal divider">Links</div>
<div id="grid-margin" class="ui grid">
<div class="social-block">
<span class="three wide column"><i class="world icon"></i>Website:</span>
<a if="{selected_user.personal_url}" href="{selected_user.personal_url}" class="thirteen wide column">{selected_user.personal_url}</a>

<!-- Website -->
<div if="{ selected_user.personal_url }" class="about-block">
<div class="flex-container">
<div class=""><i class="world icon"></i>Website:</div>
<div class="value">
<a href="{selected_user.personal_url}" target="_blank">{selected_user.personal_url}</a>
</div>
</div>
<div class="social-block">
<span class="three wide column"><i class="github icon"></i>GitHub:</span>
<a if="{selected_user.github_url}" href="https://github.com/" class="thirteen wide column">{selected_user.github_url}</a>
</div>

<!-- GitHub -->
<div if="{ selected_user.github_url }" class="about-block">
<div class="flex-container">
<div class=""><i class="github icon"></i>Website:</div>
<div class="value">
<a href="{ selected_user.github_url }" target="_blank">{selected_user.github_url}</a>
</div>
</div>
<div class="social-block">
<span class="three wide column"><i class="linkedin icon"></i>LinkedIn:</span>
<a if="{selected_user.linkedin_url}" href="https://linkedin.com/" class="thirteen wide column">{selected_user.linkedin_url}</a>
</div>

<!-- LinkedIn -->
<div if="{ selected_user.linkedin_url }" class="about-block">
<div class="flex-container">
<div class=""><i class="linkedin icon"></i>LinkedIn:</div>
<div class="value">
<a href="{ selected_user.linkedin_url }" target="_blank">{selected_user.linkedin_url}</a>
</div>
</div>
<div class="social-block">
<span class="three wide column"><i class="twitter icon"></i>Twitter:</span>
<a if="{selected_user.twitter_url}" href="https://twitter.com/" class="thirteen wide column">{selected_user.twitter_url}</a>
</div>

<!-- Twitter -->
<div if="{ selected_user.twitter_url }" class="about-block">
<div class="flex-container">
<div class=""><i class="twitter icon"></i>Twitter:</div>
<div class="value">
<a href="{ selected_user.twitter_url }" target="_blank">{selected_user.twitter_url}</a>
</div>
</div>
</div>

<!-- Empty Links Message -->
<span if="{!selected_user.personal_url && !selected_user.github_url && !selected_user.linkedin_url && !selected_user.twitter_url}" class="text-placeholder">Update your profile to show your social links here.</span>


</div>
</div>
</div>
Expand Down Expand Up @@ -159,8 +237,21 @@

.about-block
margin-top 10px
display flex
flex-direction column

.flex-container
display flex
flex-direction row

.text-placeholder
color #9e9e9e

.label
width 100px
color: #999
.value
font-size 15px
margin-left 10px
</style>
</profile-detail>
2 changes: 1 addition & 1 deletion src/static/riot/submissions/resource_submissions.tag
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<td if="{selected_row.competition}"><a class="link-no-deco" target="_blank" href="../competitions/{ selected_row.competition.id }">{ selected_row.competition.title }</a></td>
<!-- show empty td if competition is not available -->
<td if="{!selected_row.competition}"></td>
<td><a href="/profiles/user/{selected_row.created_by}/" target=_blank>{selected_row.created_by}</a></td>
<td><a href="/profiles/user/{selected_row.created_by}/" target=_blank>{selected_row.owner_display_name}</a></td>
<td>{pretty_date(selected_row.created_when)}</td>
<td>{_.startCase(selected_row.type)}</td>
<td>{_.startCase(selected_row.is_public)}</td>
Expand Down
2 changes: 1 addition & 1 deletion src/static/riot/tasks/management.tag
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<div class="content">
<h4>{selected_task.description}</h4>
<div class="ui divider" show="{selected_task.description}"></div>
<div><strong>Created By:</strong> <a href="/profiles/user/{selected_task.created_by}/" target=_blank>{selected_task.created_by}</a></div>
<div><strong>Created By:</strong> <a href="/profiles/user/{selected_task.created_by}/" target=_blank>{selected_task.owner_display_name}</a></div>
<div><strong>Key:</strong> {selected_task.key}</div>
<div><strong>Has Been Validated
<span data-tooltip="A task has been validated once one of its solutions has successfully been run against it">
Expand Down
2 changes: 1 addition & 1 deletion src/templates/pages/server_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h1>Recent submissions (up to 250 or 2 days old)</h1>
<td>{{ submission.parent.pk }}</td>
{% endif %}
<td>{{ submission.file_size }}</td>
<td><a target="_blank" href="/profiles/user/{{ submission.owner.username }}">{{ submission.owner.username }}</a></td>
<td><a target="_blank" href="/profiles/user/{{ submission.owner.username }}">{{ submission.owner_display_name }}</a></td>
<td>{{ submission.competition_queue }}</td>
<td>{{ submission.ingestion_worker_hostname }}</td>
<td>{{ submission.scoring_worker_hostname }}</td>
Expand Down