[func] year in template not js [refactor] remove unneeded code

This commit is contained in:
Nikola Kubiczek 2022-04-20 19:28:41 +02:00
parent 7c2d00a657
commit befa154b4e
4 changed files with 19 additions and 12 deletions

View File

@ -9,9 +9,11 @@ from django.db import transaction
from io import BytesIO
import xlsxwriter
class AnnouncementModelAdmin(SummernoteModelAdmin):
summernote_fields = ['content']
class EditionModelAdmin(admin.ModelAdmin):
list_display = ('__str__', 'active')
ordering = ('-active', '-year')
@ -90,6 +92,7 @@ class EditionModelAdmin(admin.ModelAdmin):
return super().response_change(request, obj)
class StudentModelAdmin(admin.ModelAdmin):
list_display = ('identifier', '__str__', 'grade')
search_fields = ('identifier', 'name', 'surname', 'grade')

View File

@ -17,7 +17,8 @@ class Edition(models.Model):
award_threshold = models.IntegerField('Próg punktowy - wyróżnienie', default=0)
laureate_threshold = models.IntegerField('Próg punktowy - tytuł laureata', default=0)
scores = models.FileField('Wyniki do wczytania', blank=True, upload_to='wyniki', help_text='Uwaga! Wyniki muszą być zawarte w pliku .csv. Kolumny po kolei to odpowiednio: identyfikator ucznia, wynik z eliminacji, wynik z finału.')
scores = models.FileField('Wyniki do wczytania', blank=True, upload_to='wyniki',
help_text='Uwaga! Wyniki muszą być zawarte w pliku .csv. Kolumny po kolei to odpowiednio: identyfikator ucznia, wynik z eliminacji, wynik z finału.')
first_test = models.FileField('Zadania eliminacyjne', blank=True, upload_to='eliminacje')
second_test = models.FileField('Zadania finałowe', blank=True, upload_to='finaly')
@ -51,7 +52,8 @@ class Student(models.Model):
school_town = models.CharField('Miejscowość', max_length=100, blank=True)
school_address = models.CharField('Adres', max_length=100, blank=True)
identifier = models.CharField('Identyfikator', max_length=100, blank=True, editable=True, help_text='UWAGA - tej wartości należy nie zmieniać')
identifier = models.CharField('Identyfikator', max_length=100, blank=True, editable=True,
help_text='UWAGA - tej wartości należy nie zmieniać')
def __str__(self):
return f'{self.surname} {self.name}'

View File

@ -75,7 +75,7 @@
</main>
<footer class="footer has-text-centered" style="background-color: transparent !important;">
<span class="has-text-weight-light is-italic">
&copy; 1998-<script>document.write(new Date().getFullYear());</script>
&copy; 1998-{% now "Y" %}
V Liceum Ogólnokształcące w Bielsku-Białej & Mikołaj Kubiczek
</span>
</footer>

View File

@ -42,7 +42,8 @@ def SubmitStudentsView(request):
}
if edition.submissions is not True:
queryset = Student.objects.filter(identifier__startswith=f'{edition.year}-{request.user.id}-').order_by('identifier')
queryset = Student.objects.filter(
identifier__startswith=f'{edition.year}-{request.user.id}-').order_by('identifier')
return render(request, 'user/submission.html', {'students': queryset, **context})
@ -57,7 +58,8 @@ def SubmitStudentsView(request):
students = filter(lambda x: x != {}, formset.cleaned_data)
for index, data in enumerate(students):
Student.objects.update_or_create(identifier=f'{edition.year}-{request.user.id}-{index + 1}', defaults=data)
Student.objects.update_or_create(
identifier=f'{edition.year}-{request.user.id}-{index + 1}', defaults=data)
else:
formset = ArticleFormSet(initial=list(map(lambda x: x.__dict__, queryset)))
@ -102,7 +104,7 @@ class TestsView(TemplateView):
return context
def ScoresView(request, year = None):
def ScoresView(request, year=None):
if year is not None:
edition = get_object_or_404(Edition, year=year)
else:
@ -129,12 +131,12 @@ def ScoresView(request, year = None):
}, students)
schools = list({school['id']: school for school in schools}.values())
individual = map(lambda x: {
individual = filter(lambda x: x['score'] >= edition.award_threshold,
map(lambda x: {
**x.__dict__,
'score': x.score_first * x.score_second,
'title': 'Laureat' if x.score_first * x.score_second >= edition.laureate_threshold else 'Wyróżnienie'
}, students.filter(score_first__gte=edition.entry_threshold))
individual = filter(lambda x: x['score'] >= edition.award_threshold, individual)
}, students.filter(score_first__gte=edition.entry_threshold)))
teams = []
for school in schools: