@require_POST
@login_required
def lock_question(request, question_id):
 question = get_object_or_404(Question, pk=question_id)
 if (not question.allows_lock(request.user)):
  raise PermissionDenied
 question.is_locked = (not question.is_locked)
 log.info(('User %s set is_locked=%s on question with id=%s ' % (request.user, question.is_locked, question.id)))
 question.save()
 if question.is_locked:
  statsd.incr('questions.lock')
 else:
  statsd.incr('questions.unlock')
 return HttpResponseRedirect(question.get_absolute_url())

@ require_POST @ login_required def lock_question ( request , question_id ) : question = get_object_or_404 ( Question , pk = question_id ) if ( not question . allows_lock ( request . user ) ) : raise PermissionDenied question . is_locked = ( not question . is_locked ) log . info ( ( 'User %s set is_locked=%s on question with id=%s ' % ( request . user , question . is_locked , question . id ) ) ) question . save ( ) if question . is_locked : statsd . incr ( 'questions.lock' ) else : statsd . incr ( 'questions.unlock' ) return HttpResponseRedirect ( question . get_absolute_url ( ) )
lock or unlock a question .