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 aggregated tags in settings #444

Merged
merged 37 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9519dbe
Add new AggregatedAlgorithmTagProposal class.
segir187 Nov 24, 2024
028bb2b
Make AggregatedAlgorithmTagProposal increase each time a new Algorith…
segir187 Nov 24, 2024
d7c3a4b
Change handling of modification of AggregatedAlgorithmTagProposal to …
segir187 Nov 24, 2024
4f2794a
Remove created argument from decrease_aggregated_algorithm_tag_propos…
segir187 Nov 24, 2024
825bcf4
Split test_tags.py into test_tags.py file, testing AlgorithmTag and D…
segir187 Nov 25, 2024
de5da6c
Expand test_save_proposals_view in TestSaveProposals class to also ch…
segir187 Nov 25, 2024
f9c1e15
Add AggregatedDifficultyTagProposal.
segir187 Nov 26, 2024
fc5441b
Add checking AggregatedDifficultyTagProposal in test_save_poposals_vi…
segir187 Nov 26, 2024
c7f865b
Merge branch 'sio2project:master' into AggregatedAlgorithmTagProposal
segir187 Nov 26, 2024
61c1df2
Migrate AggregatedTagProposal classes.
segir187 Nov 28, 2024
3deb61e
Fixed test_tag_proposals.py to work correctly.
segir187 Nov 28, 2024
1462c31
Remove unnecessary import.
segir187 Nov 28, 2024
5ea3d5a
Add data migration from TagProposal models to AggregatedTagProposal m…
segir187 Nov 28, 2024
3c1ee01
Merge branch 'sio2project:master' into AggregatedTagProposals
segir187 Nov 28, 2024
b385cd7
Remove unnecessary import.
segir187 Nov 28, 2024
8d7b5ea
Initial version of test_data_migrations.py. It should be restructured.
segir187 Dec 2, 2024
a34fa72
Change import of migration function from static to dynamic.
segir187 Dec 8, 2024
7941d9e
Change user primary keys to keys corresponding to valid users from te…
segir187 Dec 8, 2024
ad0fa08
Change usages of creates in for loops to bulk_creates.
segir187 Dec 9, 2024
a1c00c3
Change exceptions raised to logged messages.
segir187 Dec 9, 2024
de8866c
Make increase_aggregated and decrease_aggregated functions more compact.
segir187 Dec 9, 2024
21243d0
Add atomicity to increase and decrease functions.
segir187 Dec 9, 2024
adce79f
Avoided repeating code through making generic function that increases…
segir187 Dec 9, 2024
34e786a
Add exception logging for decrease_aggregated_tag_proposal function.
segir187 Dec 9, 2024
29aec77
Simplify tests testing Aggregated Tag Proposals with helper functions.
segir187 Dec 9, 2024
d269154
Fix comment explaining _get_tag_amounts helper function.
segir187 Dec 9, 2024
8ee264f
Remove needles whitespaces and end of lines.
segir187 Dec 9, 2024
a22510e
Merge branch 'sio2project:master' into AggregatedTagProposals
segir187 Dec 9, 2024
1398b9f
Merge branch 'sio2project:master' into AggregatedTagProposals
segir187 Dec 15, 2024
5cdafca
Change tag proposals in problem_site_settings functions to pull data …
segir187 Dec 9, 2024
93ac2d8
Change style of display for proposed tags.
segir187 Dec 15, 2024
0d32438
Change way of displaying aggregated tag proposals.
segir187 Dec 15, 2024
d4cd990
Remove not working intended generalisation of get_tag_name function.
segir187 Dec 15, 2024
80069f4
Merge branch 'sio2project:master' into AggregatedTagsInSettings
segir187 Dec 16, 2024
ea4a10e
Merge branch 'sio2project:master' into AggregatedTagsInSettings
segir187 Dec 16, 2024
3bd36c0
Merge branch 'sio2project:master' into AggregatedTagsInSettings
segir187 Dec 16, 2024
fb3b594
Remove needles u before strings.
segir187 Jan 20, 2025
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
4 changes: 4 additions & 0 deletions oioioi/base/utils/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ def get_tag_prefix(tag):
'OriginInfoValue': 'origin',
'AlgorithmTag': 'algorithm',
'DifficultyTag': 'difficulty',
'AlgorithmTagProposal': 'algorithm-proposal',
'DifficultyTagProposal': 'difficulty-proposal',
'AggregatedAlgorithmTagProposal': 'algorithm-proposal',
'AggregatedDifficultyTagProposal': 'difficulty-proposal',
}

return prefixes[tag.__class__.__name__]
Expand Down
6 changes: 4 additions & 2 deletions oioioi/problems/problem_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from oioioi.problems.models import (
AlgorithmTagProposal,
DifficultyTagProposal,
AggregatedAlgorithmTagProposal,
AggregatedDifficultyTagProposal,
Problem,
ProblemAttachment,
ProblemPackage,
Expand Down Expand Up @@ -250,10 +252,10 @@ def problem_site_settings(request, problem):
model_solutions = generate_model_solutions_context(request, problem_instance)
extra_actions = problem.controller.get_extra_problem_site_actions(problem)
algorithm_tag_proposals = (
AlgorithmTagProposal.objects.all().filter(problem=problem).order_by('-pk')[:25]
AggregatedAlgorithmTagProposal.objects.all().filter(problem=problem).order_by('-amount')[:25]
)
difficulty_tag_proposals = (
DifficultyTagProposal.objects.all().filter(problem=problem).order_by('-pk')[:25]
AggregatedDifficultyTagProposal.objects.all().filter(problem=problem).order_by('-amount')[:25]
)

return TemplateResponse(
Expand Down
10 changes: 10 additions & 0 deletions oioioi/problems/static/common/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,13 @@
background-color: #2DB941;
color: #fff;
}

.tag-label-algorithm-proposal {
background-color: #91c5f5;
color: #000;
}

.tag-label-difficulty-proposal {
background-color: #90EE90;
color: #000;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ <h4 class="text-center item-title">{% trans "Current tags" %}</h4>
<hr class="separator">
<h4 class="text-center item-title">{% trans "Users algorithms proposals" %}</h4>
{% for proposal in algorithm_tag_proposals %}
{% tag_label proposal.tag %}
{% aggregated_tag_label proposal %}
{% endfor %}
{% endif %}

{% if difficulty_tag_proposals %}
<hr class="separator">
<h4 class="text-center item-title">{% trans "Users difficulty proposals" %}</h4>
{% for proposal in difficulty_tag_proposals %}
{% tag_label proposal.tag %}
{% aggregated_tag_label proposal %}
{% endfor %}
{% endif %}

Expand Down
18 changes: 16 additions & 2 deletions oioioi/problems/templatetags/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def prefetch_tags(problems):
def tag_label(tag):
prefix = get_tag_prefix(tag)
return format_html(
u'<a title="{tooltip}" class="badge tag-label tag-label-{cls}" href="{href}" '
'<a title="{tooltip}" class="badge tag-label tag-label-{cls}" href="{href}" '
'>{name}</a>',
tooltip=getattr(tag, 'full_name', tag.name),
name=get_tag_name(tag),
Expand All @@ -32,11 +32,25 @@ def tag_label(tag):
)


@register.simple_tag
def aggregated_tag_label(aggregated_tag):
prefix = get_tag_prefix(aggregated_tag)
twalen marked this conversation as resolved.
Show resolved Hide resolved
return format_html(
'<a title="{tooltip}" class="badge tag-label tag-label-{cls}" href="{href}" '
'>{name} | {amount}</a>',
tooltip=getattr(aggregated_tag.tag, 'full_name', aggregated_tag.tag.name),
name=get_tag_name(aggregated_tag.tag),
cls=prefix,
amount=str(aggregated_tag.amount),
href="?" + prefix + "=" + aggregated_tag.tag.name,
)


@register.simple_tag
def origininfo_label(info):
prefix = get_tag_prefix(info)
return format_html(
u'<a title="{tooltip}" class="badge tag-label tag-label-{cls}" href="{href}" '
'<a title="{tooltip}" class="badge tag-label tag-label-{cls}" href="{href}" '
'>{name}</a>',
tooltip=info.full_name,
name=info.value,
Expand Down
Loading