コード例 #1
0
ファイル: views.py プロジェクト: jchmura/suchary-django
def delete_joke(request, pk):
    user = request.user.groups.filter(name='Moderator')
    if user:
        joke = Joke.objects.get(pk=pk)
        joke.hidden = timezone.now()
        joke.save()
        logger.info('Joke %s removed.', joke.key)
        api_remove_joke(joke.key)
        return HttpResponse(status=200)
    else:
        return HttpResponse('User not authorised to remove joke', status=401)
コード例 #2
0
ファイル: views.py プロジェクト: jchmura/suchary-django
def duplicate_joke(request, pk, key):
    user = request.user.groups.filter(name='Moderator')
    if user:
        joke = Joke.objects.get(pk=pk)
        original = Joke.objects.get(key=key)
        joke.duplicate = original
        joke.save()
        logger.info('Joke %s marked as duplicate of %s.', joke.key, original.key)
        api_remove_joke(joke.key)
        return HttpResponse(status=200)
    else:
        return HttpResponse('User not authorised to mark joke as duplicated', status=401)