def new(request): if not request.user.payment.status['is_paid']: return render(request, 'central/fjelltreffen/payment_required.html') other_active_annonse_exists = Annonse.get_active().filter(user=request.user, hidden=False).exists() context = { 'counties': County.typical_objects(), 'annonse_retention_days': settings.FJELLTREFFEN_ANNONSE_RETENTION_DAYS, 'obscured_age': Annonse.obscure_age(request.user.get_age()), 'other_active_annonse_exists': other_active_annonse_exists } return render(request, 'central/fjelltreffen/edit.html', context)
def edit(request, id): try: annonse = Annonse.objects.get(id=id) # checks if the user is the owner if annonse.user != request.user: raise PermissionDenied except Annonse.DoesNotExist: return render(request, 'central/fjelltreffen/edit_not_found.html') other_active_annonse_exists = Annonse.get_active().exclude(id=annonse.id).filter(user=request.user).exists() context = { 'annonse': annonse, 'counties': County.typical_objects(), 'annonse_retention_days': settings.FJELLTREFFEN_ANNONSE_RETENTION_DAYS, 'obscured_age': Annonse.obscure_age(request.user.get_age()), 'other_active_annonse_exists': other_active_annonse_exists } return render(request, 'central/fjelltreffen/edit.html', context)