Skip to content

Commit

Permalink
remove debug + add some semi colons to js
Browse files Browse the repository at this point in the history
  • Loading branch information
lakshy-gupta committed Sep 13, 2021
1 parent daeb26e commit 3931912
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
7 changes: 0 additions & 7 deletions judge/models/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,29 +443,22 @@ def save(self, *args, **kwargs):
save.alters_data = True

def can_vote(self, user):
print('user')
print('\tauthed', user.is_authenticated)
if not user.is_authenticated:
return False

# If the user is in contest, nothing should be shown.
print('\tcontest', user.profile.current_contest)
if user.profile.current_contest:
return False

# If the user is not allowed to vote
print('\tunlisted', user.profile.is_unlisted)
print('\tbanned from voting', user.profile.is_banned_problem_voting)
if user.profile.is_unlisted or user.profile.is_banned_problem_voting:
return False

# If the user is banned from submitting to the problem.
print('\tbanned from problem', self.banned_users.filter(pk=user.pk), self.banned_users.filter(pk=user.pk).exists())
if self.banned_users.filter(pk=user.pk).exists():
return False

# If the user has a full AC submission to the problem (solved the problem).
print('\tac problem',self.submission_set.filter(user=user.profile, result='AC', points=F('problem__points')), self.submission_set.filter(user=user.profile, result='AC', points=F('problem__points')).exists())
return self.submission_set.filter(user=user.profile, result='AC', points=F('problem__points')).exists()

class Meta:
Expand Down
10 changes: 3 additions & 7 deletions templates/problem/voting-controls.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
if (has_voted) voteUpdate();
else deleteVoteUpdate();

$('#id_vote_form').on('submit', e => e.preventDefault());
$('#id_delete_vote_form').on('submit', e => e.preventDefault());
$('#id_delete_vote_form_submit_button').on('click', e => {
e.preventDefault();
$.ajax({
Expand All @@ -168,15 +168,13 @@

$('#id_vote_form').on('submit', e => e.preventDefault());
$('#id_vote_form_submit_button').on('click', e => {
e.preventDefault()
console.log('sending');
e.preventDefault();
$.ajax({
url: '{{ url('vote', object.code) }}',
type: 'POST',
data: $('#id_vote_form').serialize(),
success: data => {
console.log('worked');
updateUserVote(voted_points, data.points)
updateUserVote(voted_points, data.points);
voted_note = data.note;
voted_points = data.points;
voteUpdate();
Expand All @@ -185,8 +183,6 @@
closeLightbox('id_voting_lightbox');
},
error: data => {
console.log('didnt work');
console.log(data);
let errors = data.responseJSON;
if('points' in errors){
$('#id_points_error_box').show();
Expand Down

0 comments on commit 3931912

Please # to comment.