Skip to content

Commit

Permalink
Merge pull request #11 from CHT-OJ/hotfix_for_moss
Browse files Browse the repository at this point in the history
Hotfix for moss
  • Loading branch information
iotran207 authored Aug 15, 2024
2 parents 5fa5f94 + 57ea9eb commit c9e657b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion judge/admin/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def has_add_permission(self, request, obj=None):
class ProfileAdmin(NoBatchDeleteMixin, VersionAdmin):
fields = ('user', 'display_rank', 'badges', 'display_badge', 'about', 'organizations', 'vnoj_points', 'timezone',
'language', 'ace_theme', 'math_engine', 'last_access', 'ip', 'mute', 'is_unlisted', 'allow_tagging',
'notes', 'username_display_override', 'ban_reason', 'is_totp_enabled', 'user_script', 'current_contest')
'notes', 'username_display_override', 'ban_reason', 'is_totp_enabled', 'user_script', 'current_contest','warn','last_warned')
readonly_fields = ('user',)
list_display = ('admin_user_admin', 'email', 'is_totp_enabled', 'timezone_full',
'date_joined', 'last_access', 'ip', 'show_public')
Expand Down
11 changes: 7 additions & 4 deletions judge/views/contests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,9 +1249,10 @@ def post(self, request, *args, **kwargs):
data = json.loads(self.request.body)
workbook = Workbook()
workbook.remove(workbook['Sheet'])

user_list = []
lang = ['c','cpp','java','pascal','python']
for problem in data:
user_list.clear()
workbook.create_sheet(problem['problem'])
sheet = workbook[problem['problem']]
sheet.append(("TÊN NGƯỜI DÙNG","% MOSS"))
Expand All @@ -1265,7 +1266,9 @@ def post(self, request, *args, **kwargs):
for i in data_tds:
data_split = i.text.split()
number = ''.join(filter(str.isdigit,data_split[1]))
sheet.append((data_split[0],number))
if(data_split[0] not in user_list):
sheet.append((data_split[0],number))
user_list.append(data_split[0])

for row in range(2,sheet.max_row+1):
cell = sheet.cell(row=row,column=2)
Expand All @@ -1274,8 +1277,8 @@ def post(self, request, *args, **kwargs):
else:
cell.fill = PatternFill(start_color="34eb43", end_color="34eb43", fill_type="solid")

workbook.save(f"{settings.MOSS_RESULTS_FOLDER}/{contest_name}.xlsx")
return JsonResponse({'Result':f'{contest_name}.xlsx'})
workbook.save(f"{settings.MOSS_RESULTS_FOLDER}/{contest_name}.xlsx")
return JsonResponse({'Result':f'{contest_name}.xlsx'})

class ContestTagDetailAjax(DetailView):
model = ContestTag
Expand Down
2 changes: 1 addition & 1 deletion templates/contest/moss.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
data.push(rowData);
});
var csrftoken = '{{ csrf_token }}';
fetch(`moss/calcutlate`, {
fetch(`moss/calculate`, {
method: 'POST',
headers: {
'X-CSRFToken': csrftoken,
Expand Down

0 comments on commit c9e657b

Please sign in to comment.