forked from 42CTF/website
Compare commits
4 Commits
ec61f06be0
...
1ee02fc964
Author | SHA1 | Date |
---|---|---|
Danhia | 1ee02fc964 | |
Starthur | ff23250275 | |
Starthur | c449f26ad7 | |
Danhia | 42858e4342 |
|
@ -8,9 +8,9 @@ from .models import Campus
|
||||||
@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', 'intra42_campus']
|
list_display = ['user', 'score', 'last_submission_date', 'campus']
|
||||||
# search list
|
# search list
|
||||||
search_fields = ['score', 'user__username', 'intra42_campus']
|
search_fields = ['score', 'user__username', 'campus']
|
||||||
|
|
||||||
@admin.register(Campus)
|
@admin.register(Campus)
|
||||||
class campus(admin.ModelAdmin):
|
class campus(admin.ModelAdmin):
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Generated by Django 3.2.11 on 2022-08-01 20:12
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('accounts', '0011_migration_campus'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='userprofileinfo',
|
||||||
|
options={'ordering': ['-score', 'last_submission_date', 'user__username', 'campus'], 'permissions': (('view_info', 'View user info'),), 'verbose_name': 'profile', 'verbose_name_plural': 'profiles'},
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='userprofileinfo',
|
||||||
|
name='intra42_campus',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='userprofileinfo',
|
||||||
|
name='intra42_campus_id',
|
||||||
|
),
|
||||||
|
]
|
|
@ -14,15 +14,13 @@ class UserProfileInfo(models.Model):
|
||||||
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_id = models.CharField(max_length=20, null=True, blank=True, unique=True)
|
||||||
campus = models.ForeignKey('Campus', on_delete=models.DO_NOTHING, null=True, blank=True)
|
campus = models.ForeignKey('Campus', on_delete=models.DO_NOTHING, null=True, blank=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', 'intra42_campus']
|
ordering = ['-score', 'last_submission_date', 'user__username', '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"),)
|
||||||
|
|
|
@ -164,8 +164,8 @@ def submit_event_flag(request, event_slug, chall_slug):
|
||||||
|
|
||||||
if player:
|
if player:
|
||||||
if ev.team_size > 1 and player.team is None:
|
if ev.team_size > 1 and player.team is None:
|
||||||
response['Location'] += '?NoTeam=1'
|
response['Location'] += '?NoTeam=1'
|
||||||
return response
|
return response
|
||||||
if ev.team_size == 1:
|
if ev.team_size == 1:
|
||||||
if CTF_flags.objects.filter(user=request.user, ctf=ctf_info):
|
if CTF_flags.objects.filter(user=request.user, ctf=ctf_info):
|
||||||
flagged = True
|
flagged = True
|
||||||
|
|
|
@ -28,9 +28,9 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if s.user.userprofileinfo.intra42_campus %}
|
{% if s.user.userprofileinfo.campus %}
|
||||||
<a href="{% url 'scoreboard:campus' campus=s.user.userprofileinfo.intra42_campus %}">
|
<a href="{% url 'scoreboard:campus' campus=s.user.userprofileinfo.campus %}">
|
||||||
{{ s.user.userprofileinfo.intra42_campus }}
|
{{ s.user.userprofileinfo.campus }}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -10,7 +10,7 @@ def scoreboard(request):
|
||||||
return render(request, 'scoreboard/scoreboard.html', {'scores':scores_p})
|
return render(request, 'scoreboard/scoreboard.html', {'scores':scores_p})
|
||||||
|
|
||||||
def campus(request, campus):
|
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')
|
scores = UserProfileInfo.objects.filter(score__gt=0, campus__name__exact=campus).select_related().order_by('-score', 'last_submission_date', 'user__username')
|
||||||
paginator = Paginator(scores, 20)
|
paginator = Paginator(scores, 20)
|
||||||
page = request.GET.get('page')
|
page = request.GET.get('page')
|
||||||
scores_p = paginator.get_page(page)
|
scores_p = paginator.get_page(page)
|
||||||
|
|
Loading…
Reference in New Issue