Merge pull request 'home-refacto' (#40) from Starthur/website:home-refacto into campus_scoreboard

Reviewed-on: 42CTF/website#40
This commit is contained in:
Danhia 2022-03-29 20:35:03 +02:00
commit 6110408cd0
23 changed files with 249 additions and 48 deletions

View File

@ -7,6 +7,6 @@ from django.contrib import admin
@admin.register(UserProfileInfo) @admin.register(UserProfileInfo)
class userprofile(admin.ModelAdmin): class userprofile(admin.ModelAdmin):
#list display #list display
list_display = ['user', 'score', 'last_submission_date'] list_display = ['user', 'score', 'last_submission_date', 'intra42_campus']
# search list # search list
search_fields = ['score', 'user__username'] search_fields = ['score', 'user__username', 'intra42_campus']

View File

@ -0,0 +1,23 @@
# Generated by Django 3.2.11 on 2022-03-29 08:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0007_auto_20220123_1704'),
]
operations = [
migrations.AddField(
model_name='userprofileinfo',
name='intra42_campus',
field=models.CharField(blank=True, max_length=50, null=True),
),
migrations.AddField(
model_name='userprofileinfo',
name='intra42_id',
field=models.CharField(blank=True, max_length=20, null=True, unique=True),
),
]

View File

@ -0,0 +1,22 @@
# Generated by Django 3.2.11 on 2022-03-29 11:39
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0008_auto_20220329_1034'),
]
operations = [
migrations.AlterModelOptions(
name='userprofileinfo',
options={'ordering': ['-score', 'last_submission_date', 'user__username', 'intra42_campus'], 'permissions': (('view_info', 'View user info'),), 'verbose_name': 'profile', 'verbose_name_plural': 'profiles'},
),
migrations.AddField(
model_name='userprofileinfo',
name='intra42_campus_id',
field=models.CharField(blank=True, max_length=10, null=True),
),
]

View File

@ -12,13 +12,16 @@ class UserProfileInfo(models.Model):
last_submission_date = models.DateTimeField('Last Submission Date', default=timezone.now) last_submission_date = models.DateTimeField('Last Submission Date', default=timezone.now)
token = models.CharField(max_length=200, blank=True) token = models.CharField(max_length=200, blank=True)
discord_id = models.CharField(max_length=20, null=True, blank=True, unique=True) discord_id = models.CharField(max_length=20, null=True, blank=True, unique=True)
intra42_id = models.CharField(max_length=20, null=True, blank=True, unique=True)
intra42_campus = models.CharField(max_length=50, null=True, blank=True)
intra42_campus_id = models.CharField(max_length=10, null=True, blank=True)
member = models.BooleanField(default=False) member = models.BooleanField(default=False)
member_since = models.DateTimeField('Member since', default=timezone.now) member_since = models.DateTimeField('Member since', default=timezone.now)
member_until = models.DateTimeField('Member until', default=timezone.now) member_until = models.DateTimeField('Member until', default=timezone.now)
def __str__(self): def __str__(self):
return self.user.username return self.user.username
class Meta: class Meta:
ordering = ['-score', 'last_submission_date', 'user__username'] ordering = ['-score', 'last_submission_date', 'user__username', 'intra42_campus']
verbose_name = 'profile' verbose_name = 'profile'
verbose_name_plural = 'profiles' verbose_name_plural = 'profiles'
permissions = (("view_info", "View user info"),) permissions = (("view_info", "View user info"),)

View File

@ -60,6 +60,21 @@
</form> </form>
{% endif %} {% endif %}
</div> </div>
<div class="d-flex">
{% if user.userprofileinfo.intra42_id|length > 0 %}
<form action="{% url 'accounts:connections-disconnect-intra42' %}" method='POST'
class="form-inline p-2">
{%csrf_token%}
<button class="btn btn-dark" type="submit">{% trans "Disconnect 42" %}</button>
</form>
{% else %}
<form action="{% url 'accounts:connections-connect-intra42' %}" method='POST'
class="form-inline p-2">
{%csrf_token%}
<button class="btn btn-dark" type="submit">{% trans "Connect 42" %}</button>
</form>
{% endif %}
</div>
</div> </div>
</div> </div>
</div> </div>
@ -87,4 +102,4 @@
</ul> </ul>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -10,8 +10,11 @@ urlpatterns = [
path('edit/', views.edit, name='edit'), path('edit/', views.edit, name='edit'),
path('logout/', views.out, name='out'), path('logout/', views.out, name='out'),
path('rank/<str:token>', views.rank, name='rank'), path('rank/<str:token>', views.rank, name='rank'),
path('connections/connect/discord', views.connection.connect, name='connections-connect-discord'), path('connections/connect/discord', views.connection.connect_discord, name='connections-connect-discord'),
path('connections/connect/discord/authorize', views.connection.authorize, name='connections-connect-discord-authorize'), path('connections/connect/discord/authorize', views.connection.authorize_discord, name='connections-connect-discord-authorize'),
path('connections/disconnect/discord', views.connection.disconnect, name='connections-disconnect-discord'), path('connections/disconnect/discord', views.connection.disconnect_discord, name='connections-disconnect-discord'),
path('connections/connect/intra42', views.connection.connect_intra42, name='connections-connect-intra42'),
path('connections/connect/intra42/authorize', views.connection.authorize_intra42, name='connections-connect-intra42-authorize'),
path('connections/disconnect/intra42', views.connection.disconnect_intra42, name='connections-disconnect-intra42'),
path('delete_account/', views.delete_account, name='delete_account'), path('delete_account/', views.delete_account, name='delete_account'),
] ]

View File

@ -19,20 +19,69 @@ oauth.register(
api_base_url='https://discord.com/api/' api_base_url='https://discord.com/api/'
) )
oauth.register(
name='intra42',
client_id=os.getenv('OAUTH2_INTRA42_CLIENT_ID'),
client_secret=os.getenv('OAUTH2_INTRA42_CLIENT_SECRET'),
access_token_url='https://api.intra.42.fr/oauth/token',
authorize_url='https://api.intra.42.fr/oauth/authorize',
api_base_url='https://api.intra.42.fr/'
)
@login_required @login_required
@require_POST @require_POST
def connect(request): def connect_intra42(request):
if request.user.userprofileinfo.intra42_id:
return bad_request(request, "Already connected")
site = Site.objects.get_current()
redirect_uri = reverse('accounts:connections-connect-intra42-authorize')
redirect_uri = "https://" + site.domain + redirect_uri[3:] # remove language code
return oauth.intra42.authorize_redirect(request, redirect_uri)
@login_required
def authorize_intra42(request):
if request.user.userprofileinfo.intra42_id:
return bad_request(request, "Already connected")
try:
token = oauth.intra42.authorize_access_token(request)
except:
return redirect('accounts:edit')
response = oauth.intra42.get('v2/me', token=token)
response = response.json()
intra42_id = response['id']
intra42_campus = response['campus'][0]['name']
intra42_campus_id = response['campus'][0]['id']
request.user.userprofileinfo.intra42_id = intra42_id
request.user.userprofileinfo.intra42_campus = intra42_campus
request.user.userprofileinfo.intra42_campus_id = intra42_campus_id
request.user.userprofileinfo.save()
return redirect('accounts:edit')
@login_required
@require_POST
def disconnect_intra42(request):
if not request.user.userprofileinfo.intra42_id:
return bad_request(request, "Already disconnected")
request.user.userprofileinfo.intra42_id = None
request.user.userprofileinfo.intra42_campus = None
request.user.userprofileinfo.save()
return redirect('accounts:edit')
@login_required
@require_POST
def connect_discord(request):
if request.user.userprofileinfo.discord_id: if request.user.userprofileinfo.discord_id:
return bad_request(request, "Already connected") return bad_request(request, "Already connected")
site = Site.objects.get_current() site = Site.objects.get_current()
redirect_uri = reverse('accounts:connections-connect-discord-authorize') redirect_uri = reverse('accounts:connections-connect-discord-authorize')
redirect_uri = "https://" + site.domain + redirect_uri[3:] # remove language code redirect_uri = "https://" + site.domain + redirect_uri[3:] # remove language code
print(redirect_uri)
return oauth.discord.authorize_redirect(request, redirect_uri) return oauth.discord.authorize_redirect(request, redirect_uri)
@login_required @login_required
def authorize(request): def authorize_discord(request):
if request.user.userprofileinfo.discord_id: if request.user.userprofileinfo.discord_id:
print("Already")
return bad_request(request, "Already connected") return bad_request(request, "Already connected")
try: try:
token = oauth.discord.authorize_access_token(request) token = oauth.discord.authorize_access_token(request)
@ -47,7 +96,7 @@ def authorize(request):
@login_required @login_required
@require_POST @require_POST
def disconnect(request): def disconnect_discord(request):
if not request.user.userprofileinfo.discord_id: if not request.user.userprofileinfo.discord_id:
return bad_request(request, "Already disconnected") return bad_request(request, "Already disconnected")
request.user.userprofileinfo.discord_id = None request.user.userprofileinfo.discord_id = None

@ -1 +1 @@
Subproject commit 18fac3978d21dc824bcffa2bc960aa2bf6b4abd9 Subproject commit 5c7b5995fe12c0ed1bb10f97e56ec89377c98b54

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-13 18:04+0100\n" "POT-Creation-Date: 2022-03-29 16:42+0200\n"
"PO-Revision-Date: 2022-02-10 19:50+0100\n" "PO-Revision-Date: 2022-02-10 19:50+0100\n"
"Last-Translator: Clément Hamada <clementhamada@pm.me>\n" "Last-Translator: Clément Hamada <clementhamada@pm.me>\n"
"Language-Team: \n" "Language-Team: \n"
@ -87,7 +87,15 @@ msgstr ""
msgid "Connect Discord" msgid "Connect Discord"
msgstr "" msgstr ""
#: accounts/templates/accounts/edit.html:70 #: accounts/templates/accounts/edit.html:68
msgid "Disconnect 42"
msgstr ""
#: accounts/templates/accounts/edit.html:74
msgid "Connect 42"
msgstr ""
#: accounts/templates/accounts/edit.html:85
#: accounts/templates/accounts/profile.html:46 #: accounts/templates/accounts/profile.html:46
#: ctfs/templates/ctfs/ctf_info.html:65 ctfs/templates/ctfs/ctfs_list.html:13 #: ctfs/templates/ctfs/ctf_info.html:65 ctfs/templates/ctfs/ctfs_list.html:13
#: events/templates/events/event_info.html:66 #: events/templates/events/event_info.html:66
@ -98,12 +106,12 @@ msgstr ""
msgid "Score" msgid "Score"
msgstr "Punktzahl" msgstr "Punktzahl"
#: accounts/templates/accounts/edit.html:78 #: accounts/templates/accounts/edit.html:93
#: accounts/templates/accounts/profile.html:60 #: accounts/templates/accounts/profile.html:60
msgid "Registered since" msgid "Registered since"
msgstr "Registriert seit" msgstr "Registriert seit"
#: accounts/templates/accounts/edit.html:84 #: accounts/templates/accounts/edit.html:99
#, fuzzy #, fuzzy
#| msgid "Delete my account" #| msgid "Delete my account"
msgid " Delete my account" msgid " Delete my account"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-13 18:04+0100\n" "POT-Creation-Date: 2022-03-29 16:42+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -84,7 +84,15 @@ msgstr ""
msgid "Connect Discord" msgid "Connect Discord"
msgstr "" msgstr ""
#: accounts/templates/accounts/edit.html:70 #: accounts/templates/accounts/edit.html:68
msgid "Disconnect 42"
msgstr ""
#: accounts/templates/accounts/edit.html:74
msgid "Connect 42"
msgstr ""
#: accounts/templates/accounts/edit.html:85
#: accounts/templates/accounts/profile.html:46 #: accounts/templates/accounts/profile.html:46
#: ctfs/templates/ctfs/ctf_info.html:65 ctfs/templates/ctfs/ctfs_list.html:13 #: ctfs/templates/ctfs/ctf_info.html:65 ctfs/templates/ctfs/ctfs_list.html:13
#: events/templates/events/event_info.html:66 #: events/templates/events/event_info.html:66
@ -95,12 +103,12 @@ msgstr ""
msgid "Score" msgid "Score"
msgstr "" msgstr ""
#: accounts/templates/accounts/edit.html:78 #: accounts/templates/accounts/edit.html:93
#: accounts/templates/accounts/profile.html:60 #: accounts/templates/accounts/profile.html:60
msgid "Registered since" msgid "Registered since"
msgstr "" msgstr ""
#: accounts/templates/accounts/edit.html:84 #: accounts/templates/accounts/edit.html:99
msgid " Delete my account" msgid " Delete my account"
msgstr "" msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-13 18:04+0100\n" "POT-Creation-Date: 2022-03-29 16:42+0200\n"
"PO-Revision-Date: 2022-02-09 10:55+0100\n" "PO-Revision-Date: 2022-02-09 10:55+0100\n"
"Last-Translator: Javier Uhagón (uhagontorralvojavier@gmail.com)\n" "Last-Translator: Javier Uhagón (uhagontorralvojavier@gmail.com)\n"
"Language-Team: \n" "Language-Team: \n"
@ -88,7 +88,15 @@ msgstr ""
msgid "Connect Discord" msgid "Connect Discord"
msgstr "" msgstr ""
#: accounts/templates/accounts/edit.html:70 #: accounts/templates/accounts/edit.html:68
msgid "Disconnect 42"
msgstr ""
#: accounts/templates/accounts/edit.html:74
msgid "Connect 42"
msgstr ""
#: accounts/templates/accounts/edit.html:85
#: accounts/templates/accounts/profile.html:46 #: accounts/templates/accounts/profile.html:46
#: ctfs/templates/ctfs/ctf_info.html:65 ctfs/templates/ctfs/ctfs_list.html:13 #: ctfs/templates/ctfs/ctf_info.html:65 ctfs/templates/ctfs/ctfs_list.html:13
#: events/templates/events/event_info.html:66 #: events/templates/events/event_info.html:66
@ -99,12 +107,12 @@ msgstr ""
msgid "Score" msgid "Score"
msgstr "Puntuación" msgstr "Puntuación"
#: accounts/templates/accounts/edit.html:78 #: accounts/templates/accounts/edit.html:93
#: accounts/templates/accounts/profile.html:60 #: accounts/templates/accounts/profile.html:60
msgid "Registered since" msgid "Registered since"
msgstr "Registrado desde" msgstr "Registrado desde"
#: accounts/templates/accounts/edit.html:84 #: accounts/templates/accounts/edit.html:99
#, fuzzy #, fuzzy
#| msgid "Delete my account" #| msgid "Delete my account"
msgid " Delete my account" msgid " Delete my account"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-13 18:04+0100\n" "POT-Creation-Date: 2022-03-29 16:42+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -92,7 +92,19 @@ msgstr "Déconnecter Discord"
msgid "Connect Discord" msgid "Connect Discord"
msgstr "Connecter Discord" msgstr "Connecter Discord"
#: accounts/templates/accounts/edit.html:70 #: accounts/templates/accounts/edit.html:68
#, fuzzy
#| msgid "Disconnect Discord"
msgid "Disconnect 42"
msgstr "Déconnecter Discord"
#: accounts/templates/accounts/edit.html:74
#, fuzzy
#| msgid "Connect Discord"
msgid "Connect 42"
msgstr "Connecter Discord"
#: accounts/templates/accounts/edit.html:85
#: accounts/templates/accounts/profile.html:46 #: accounts/templates/accounts/profile.html:46
#: ctfs/templates/ctfs/ctf_info.html:65 ctfs/templates/ctfs/ctfs_list.html:13 #: ctfs/templates/ctfs/ctf_info.html:65 ctfs/templates/ctfs/ctfs_list.html:13
#: events/templates/events/event_info.html:66 #: events/templates/events/event_info.html:66
@ -103,12 +115,12 @@ msgstr "Connecter Discord"
msgid "Score" msgid "Score"
msgstr "Score" msgstr "Score"
#: accounts/templates/accounts/edit.html:78 #: accounts/templates/accounts/edit.html:93
#: accounts/templates/accounts/profile.html:60 #: accounts/templates/accounts/profile.html:60
msgid "Registered since" msgid "Registered since"
msgstr "Inscrit depuis" msgstr "Inscrit depuis"
#: accounts/templates/accounts/edit.html:84 #: accounts/templates/accounts/edit.html:99
#, fuzzy #, fuzzy
#| msgid "Connected accounts" #| msgid "Connected accounts"
msgid " Delete my account" msgid " Delete my account"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-13 18:04+0100\n" "POT-Creation-Date: 2022-03-29 16:42+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -88,7 +88,15 @@ msgstr ""
msgid "Connect Discord" msgid "Connect Discord"
msgstr "" msgstr ""
#: accounts/templates/accounts/edit.html:70 #: accounts/templates/accounts/edit.html:68
msgid "Disconnect 42"
msgstr ""
#: accounts/templates/accounts/edit.html:74
msgid "Connect 42"
msgstr ""
#: accounts/templates/accounts/edit.html:85
#: accounts/templates/accounts/profile.html:46 #: accounts/templates/accounts/profile.html:46
#: ctfs/templates/ctfs/ctf_info.html:65 ctfs/templates/ctfs/ctfs_list.html:13 #: ctfs/templates/ctfs/ctf_info.html:65 ctfs/templates/ctfs/ctfs_list.html:13
#: events/templates/events/event_info.html:66 #: events/templates/events/event_info.html:66
@ -99,12 +107,12 @@ msgstr ""
msgid "Score" msgid "Score"
msgstr "スコア" msgstr "スコア"
#: accounts/templates/accounts/edit.html:78 #: accounts/templates/accounts/edit.html:93
#: accounts/templates/accounts/profile.html:60 #: accounts/templates/accounts/profile.html:60
msgid "Registered since" msgid "Registered since"
msgstr "登録日" msgstr "登録日"
#: accounts/templates/accounts/edit.html:84 #: accounts/templates/accounts/edit.html:99
#, fuzzy #, fuzzy
#| msgid "Delete my account" #| msgid "Delete my account"
msgid " Delete my account" msgid " Delete my account"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-13 18:04+0100\n" "POT-Creation-Date: 2022-03-29 16:42+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -86,7 +86,19 @@ msgstr "Отключить Discord"
msgid "Connect Discord" msgid "Connect Discord"
msgstr "Подключить Discord" msgstr "Подключить Discord"
#: accounts/templates/accounts/edit.html:70 #: accounts/templates/accounts/edit.html:68
#, fuzzy
#| msgid "Disconnect Discord"
msgid "Disconnect 42"
msgstr "Отключить Discord"
#: accounts/templates/accounts/edit.html:74
#, fuzzy
#| msgid "Connect Discord"
msgid "Connect 42"
msgstr "Подключить Discord"
#: accounts/templates/accounts/edit.html:85
#: accounts/templates/accounts/profile.html:46 #: accounts/templates/accounts/profile.html:46
#: ctfs/templates/ctfs/ctf_info.html:65 ctfs/templates/ctfs/ctfs_list.html:13 #: ctfs/templates/ctfs/ctf_info.html:65 ctfs/templates/ctfs/ctfs_list.html:13
#: events/templates/events/event_info.html:66 #: events/templates/events/event_info.html:66
@ -97,12 +109,12 @@ msgstr "Подключить Discord"
msgid "Score" msgid "Score"
msgstr "Счет" msgstr "Счет"
#: accounts/templates/accounts/edit.html:78 #: accounts/templates/accounts/edit.html:93
#: accounts/templates/accounts/profile.html:60 #: accounts/templates/accounts/profile.html:60
msgid "Registered since" msgid "Registered since"
msgstr "Зарегистрирован с" msgstr "Зарегистрирован с"
#: accounts/templates/accounts/edit.html:84 #: accounts/templates/accounts/edit.html:99
msgid " Delete my account" msgid " Delete my account"
msgstr " Удалить мой аккаунт" msgstr " Удалить мой аккаунт"
@ -381,7 +393,8 @@ msgstr "Событие"
msgid "" msgid ""
"No translation available. Please try another language (English or French)." "No translation available. Please try another language (English or French)."
msgstr "" msgstr ""
"Перевод недоступен. Пожалуйста, попобуй другой язык (английский или французский)." "Перевод недоступен. Пожалуйста, попобуй другой язык (английский или "
"французский)."
#: events/templates/events/ctf_info.html:28 #: events/templates/events/ctf_info.html:28
#: events/templates/events/event_info.html:18 #: events/templates/events/event_info.html:18
@ -400,7 +413,8 @@ msgstr "Перед вводом флагов необходимо зарегис
msgid "" msgid ""
"This is a team event, please create or join a team before submitting flags." "This is a team event, please create or join a team before submitting flags."
msgstr "" msgstr ""
"Это командное соревнование, пожалуйста, создай или вступи в команду перед тем как отправить флаги." "Это командное соревнование, пожалуйста, создай или вступи в команду перед "
"тем как отправить флаги."
#: events/templates/events/event_info.html:9 #: events/templates/events/event_info.html:9
msgid "Subscriptions is over." msgid "Subscriptions is over."
@ -635,8 +649,8 @@ msgid ""
"We've emailed you instructions for setting your password. You should receive " "We've emailed you instructions for setting your password. You should receive "
"the email shortly!" "the email shortly!"
msgstr "" msgstr ""
"Мы отправили тебе по электронной почте инструкции по установке пароля." "Мы отправили тебе по электронной почте инструкции по установке пароля.Письмо "
"Письмо будет получено совсем скоро!" "будет получено совсем скоро!"
#: templates/registration/password_reset_form.html:16 #: templates/registration/password_reset_form.html:16
msgid "Reset" msgid "Reset"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-13 18:04+0100\n" "POT-Creation-Date: 2022-03-29 16:42+0200\n"
"PO-Revision-Date: 2022-02-10 19:27+0100\n" "PO-Revision-Date: 2022-02-10 19:27+0100\n"
"Last-Translator: Clément Hamada <clementhamada@pm.me>\n" "Last-Translator: Clément Hamada <clementhamada@pm.me>\n"
"Language-Team: \n" "Language-Team: \n"
@ -255,11 +255,13 @@ msgid "What will we do with your money ?"
msgstr "" msgstr ""
#: resources/templates/resources/donate.html:51 #: resources/templates/resources/donate.html:51
#, python-format
msgid "" msgid ""
"Hosting a website - and especially a CTF platform - costs money:\n" "Hosting a website - and especially a CTF platform - costs money:\n"
" more precisely, it costs us <b>50 euros per month</b>.<br>\n" " more precisely, it costs us <b>50 euros per month</b>.<br>\n"
" If we had <b>40 members</b> each year, it would be enough to " " If we had <b>40 members</b> each year, it would be enough to "
"cover the hosting of 42CTF.<br>\n" "cover the hosting of 42CTF.<br>\n"
" We currently have %(nb_members)s members. <br>\n"
" With the additional money, we could for example offer prizes " " With the additional money, we could for example offer prizes "
"for limited-time events, but we will update this page as soon as we reach " "for limited-time events, but we will update this page as soon as we reach "
"this threshold :)" "this threshold :)"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-13 18:04+0100\n" "POT-Creation-Date: 2022-03-29 16:42+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -210,11 +210,13 @@ msgid "What will we do with your money ?"
msgstr "" msgstr ""
#: resources/templates/resources/donate.html:51 #: resources/templates/resources/donate.html:51
#, python-format
msgid "" msgid ""
"Hosting a website - and especially a CTF platform - costs money:\n" "Hosting a website - and especially a CTF platform - costs money:\n"
" more precisely, it costs us <b>50 euros per month</b>.<br>\n" " more precisely, it costs us <b>50 euros per month</b>.<br>\n"
" If we had <b>40 members</b> each year, it would be enough to " " If we had <b>40 members</b> each year, it would be enough to "
"cover the hosting of 42CTF.<br>\n" "cover the hosting of 42CTF.<br>\n"
" We currently have %(nb_members)s members. <br>\n"
" With the additional money, we could for example offer prizes " " With the additional money, we could for example offer prizes "
"for limited-time events, but we will update this page as soon as we reach " "for limited-time events, but we will update this page as soon as we reach "
"this threshold :)" "this threshold :)"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-13 18:04+0100\n" "POT-Creation-Date: 2022-03-29 16:42+0200\n"
"PO-Revision-Date: 2022-02-09 10:55+0100\n" "PO-Revision-Date: 2022-02-09 10:55+0100\n"
"Last-Translator: Javier Uhagón (uhagontorralvojavier@gmail.com)\n" "Last-Translator: Javier Uhagón (uhagontorralvojavier@gmail.com)\n"
"Language-Team: \n" "Language-Team: \n"
@ -244,11 +244,13 @@ msgid "What will we do with your money ?"
msgstr "" msgstr ""
#: resources/templates/resources/donate.html:51 #: resources/templates/resources/donate.html:51
#, python-format
msgid "" msgid ""
"Hosting a website - and especially a CTF platform - costs money:\n" "Hosting a website - and especially a CTF platform - costs money:\n"
" more precisely, it costs us <b>50 euros per month</b>.<br>\n" " more precisely, it costs us <b>50 euros per month</b>.<br>\n"
" If we had <b>40 members</b> each year, it would be enough to " " If we had <b>40 members</b> each year, it would be enough to "
"cover the hosting of 42CTF.<br>\n" "cover the hosting of 42CTF.<br>\n"
" We currently have %(nb_members)s members. <br>\n"
" With the additional money, we could for example offer prizes " " With the additional money, we could for example offer prizes "
"for limited-time events, but we will update this page as soon as we reach " "for limited-time events, but we will update this page as soon as we reach "
"this threshold :)" "this threshold :)"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-13 18:04+0100\n" "POT-Creation-Date: 2022-03-29 16:42+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -254,11 +254,13 @@ msgid "What will we do with your money ?"
msgstr "" msgstr ""
#: resources/templates/resources/donate.html:51 #: resources/templates/resources/donate.html:51
#, python-format
msgid "" msgid ""
"Hosting a website - and especially a CTF platform - costs money:\n" "Hosting a website - and especially a CTF platform - costs money:\n"
" more precisely, it costs us <b>50 euros per month</b>.<br>\n" " more precisely, it costs us <b>50 euros per month</b>.<br>\n"
" If we had <b>40 members</b> each year, it would be enough to " " If we had <b>40 members</b> each year, it would be enough to "
"cover the hosting of 42CTF.<br>\n" "cover the hosting of 42CTF.<br>\n"
" We currently have %(nb_members)s members. <br>\n"
" With the additional money, we could for example offer prizes " " With the additional money, we could for example offer prizes "
"for limited-time events, but we will update this page as soon as we reach " "for limited-time events, but we will update this page as soon as we reach "
"this threshold :)" "this threshold :)"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-13 18:04+0100\n" "POT-Creation-Date: 2022-03-29 16:42+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -248,11 +248,13 @@ msgid "What will we do with your money ?"
msgstr "" msgstr ""
#: resources/templates/resources/donate.html:51 #: resources/templates/resources/donate.html:51
#, python-format
msgid "" msgid ""
"Hosting a website - and especially a CTF platform - costs money:\n" "Hosting a website - and especially a CTF platform - costs money:\n"
" more precisely, it costs us <b>50 euros per month</b>.<br>\n" " more precisely, it costs us <b>50 euros per month</b>.<br>\n"
" If we had <b>40 members</b> each year, it would be enough to " " If we had <b>40 members</b> each year, it would be enough to "
"cover the hosting of 42CTF.<br>\n" "cover the hosting of 42CTF.<br>\n"
" We currently have %(nb_members)s members. <br>\n"
" With the additional money, we could for example offer prizes " " With the additional money, we could for example offer prizes "
"for limited-time events, but we will update this page as soon as we reach " "for limited-time events, but we will update this page as soon as we reach "
"this threshold :)" "this threshold :)"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-13 18:04+0100\n" "POT-Creation-Date: 2022-03-29 16:42+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -212,11 +212,13 @@ msgid "What will we do with your money ?"
msgstr "" msgstr ""
#: resources/templates/resources/donate.html:51 #: resources/templates/resources/donate.html:51
#, python-format
msgid "" msgid ""
"Hosting a website - and especially a CTF platform - costs money:\n" "Hosting a website - and especially a CTF platform - costs money:\n"
" more precisely, it costs us <b>50 euros per month</b>.<br>\n" " more precisely, it costs us <b>50 euros per month</b>.<br>\n"
" If we had <b>40 members</b> each year, it would be enough to " " If we had <b>40 members</b> each year, it would be enough to "
"cover the hosting of 42CTF.<br>\n" "cover the hosting of 42CTF.<br>\n"
" We currently have %(nb_members)s members. <br>\n"
" With the additional money, we could for example offer prizes " " With the additional money, we could for example offer prizes "
"for limited-time events, but we will update this page as soon as we reach " "for limited-time events, but we will update this page as soon as we reach "
"this threshold :)" "this threshold :)"

View File

@ -12,6 +12,7 @@
<th scope="col">{% trans "Rank" %}</th> <th scope="col">{% trans "Rank" %}</th>
<th scope="col">{% trans "Username" %}</th> <th scope="col">{% trans "Username" %}</th>
<th scope="col">{% trans "Website" %}</th> <th scope="col">{% trans "Website" %}</th>
<th scope="col">{% trans "Campus" %}</th>
<th scope="col">{% trans "Score" %}</th> <th scope="col">{% trans "Score" %}</th>
</tr> </tr>
</thead> </thead>
@ -26,6 +27,13 @@
<a href="{{ s.user.userprofileinfo.portfolio_site }}" target="_blank">{{ s.user.userprofileinfo.portfolio_site }}</a> <a href="{{ s.user.userprofileinfo.portfolio_site }}" target="_blank">{{ s.user.userprofileinfo.portfolio_site }}</a>
{% endif %} {% endif %}
</td> </td>
<td>
{% if s.user.userprofileinfo.intra42_campus %}
<a href="{% url 'scoreboard:campus' campus=s.user.userprofileinfo.intra42_campus %}">
{{ s.user.userprofileinfo.intra42_campus }}
</a>
{% endif %}
</td>
<td>{{ s.user.userprofileinfo.score }}</td> <td>{{ s.user.userprofileinfo.score }}</td>
</tr> </tr>
{% endfor %} {% endfor %}

View File

@ -4,5 +4,6 @@ from . import views
app_name = "scoreboard" app_name = "scoreboard"
urlpatterns = [ urlpatterns = [
path('', views.scoreboard, name='scoreboard') path('', views.scoreboard, name='scoreboard'),
path('campus/<str:campus>', views.campus, name='campus')
] ]

View File

@ -8,5 +8,12 @@ def scoreboard(request):
page = request.GET.get('page') page = request.GET.get('page')
scores_p = paginator.get_page(page) scores_p = paginator.get_page(page)
return render(request, 'scoreboard/scoreboard.html', {'scores':scores_p}) return render(request, 'scoreboard/scoreboard.html', {'scores':scores_p})
def campus(request, campus):
scores = UserProfileInfo.objects.filter(score__gt=0, intra42_campus__exact=campus).select_related().order_by('-score', 'last_submission_date', 'user__username')
paginator = Paginator(scores, 20)
page = request.GET.get('page')
scores_p = paginator.get_page(page)
return render(request, 'scoreboard/scoreboard.html', {'scores':scores_p})
# Create your views here. # Create your views here.