Compare commits

..

No commits in common. "5ee37f61cf28b548f2145a52c231c6b83882c4ac" and "121d06aff22f7c071a81f52f017c18406a06ed52" have entirely different histories.

5 changed files with 14 additions and 37 deletions

View File

@ -8,10 +8,10 @@ from .models import Campus
@admin.register(UserProfileInfo)
class userprofile(admin.ModelAdmin):
#list display
list_display = ['user', 'score', 'last_submission_date', 'campus']
list_display = ['user', 'score', 'last_submission_date', 'intra42_campus']
# search list
search_fields = ['score', 'user__username', 'campus']
search_fields = ['score', 'user__username', 'intra42_campus']
@admin.register(Campus)
class campus(admin.ModelAdmin):
list_display = ['name']
list_display = ['name']

View File

@ -1,25 +0,0 @@
# 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',
),
]

View File

@ -14,13 +14,15 @@ class UserProfileInfo(models.Model):
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)
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_since = models.DateTimeField('Member since', default=timezone.now)
member_until = models.DateTimeField('Member until', default=timezone.now)
def __str__(self):
return self.user.username
class Meta:
ordering = ['-score', 'last_submission_date', 'user__username', 'campus']
ordering = ['-score', 'last_submission_date', 'user__username', 'intra42_campus']
verbose_name = 'profile'
verbose_name_plural = 'profiles'
permissions = (("view_info", "View user info"),)

View File

@ -28,9 +28,9 @@
{% endif %}
</td>
<td>
{% if s.user.userprofileinfo.campus %}
<a href="{% url 'scoreboard:campus' campus=s.user.userprofileinfo.campus %}">
{{ s.user.userprofileinfo.campus }}
{% 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>
@ -39,25 +39,25 @@
{% endfor %}
</tbody>
</table>
<div class="pagination">
<span class="step-links">
{% if scores.has_previous %}
<a href="?page=1">&laquo; {% trans "First" %}</a>
<a href="?page={{ scores.previous_page_number }}">{% trans "Previous" %}</a>
{% endif %}
<span class="current">
{% trans "Page "%} {{ scores.number }} / {{ scores.paginator.num_pages }}.
</span>
{% if scores.has_next %}
<a href="?page={{ scores.next_page_number }}">{% trans "Next" %}</a>
<a href="?page={{ scores.paginator.num_pages }}">{% trans "Last" %}&raquo;</a>
{% endif %}
</span>
</div>
</div>
</div>
</div>

View File

@ -10,7 +10,7 @@ def scoreboard(request):
return render(request, 'scoreboard/scoreboard.html', {'scores':scores_p})
def campus(request, campus):
scores = UserProfileInfo.objects.filter(score__gt=0, campus__name__exact=campus).select_related().order_by('-score', 'last_submission_date', 'user__username')
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)