Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def payment_made_paypal(request, artist_id):
artist = get_object_or_404(Artist.objects.viewable_by(request.user), pk=artist_id)
payment = None
if request.method == "POST":
ipn_received.send(None, query=request.body)
try:
signer = Signer()
item_number = request.POST['item_number']
payment_id = signer.unsign(item_number)
payment = Payment.objects.get(id=payment_id)
except (KeyError, BadSignature, Payment.DoesNotExist):
pass
return render(request, "artshow/payment_made_paypal.html",
{"artist": artist, "payment": payment, "pr_pk": settings.ARTSHOW_PAYMENT_RECEIVED_PK})
l.save()
return HttpResponseRedirect(reverse(letter_templates))
else:
form = LetterTemplateForm()
form.fields['unit'].choices = unit_choices
page_title = 'New Letter Template'
crumb = 'New'
lt = sorted(LETTER_TAGS.iteritems())
context = {
'form': form,
'page_title' : page_title,
'crumb' : crumb,
'LETTER_TAGS' : lt
}
return render(request, 'grad/new_letter_template.html', context)
try:
room = ChatRoom.objects.get(eid=room_id)
cmsgs = ChatMessage.objects.filter(
room=room).order_by('-date')[:50]
msgs = []
for msg in reversed(cmsgs):
msgs.append(msg.to_data())
except ChatRoom.DoesNotExist:
msgs = []
context = {}
context['room_id'] = room_id
context['last_id'] = last_id
context['messages'] = msgs
context['user'] = user
return render(request, 'chat/chat.html', context)
else:
context = {}
context['room_id'] = room_id or 'default'
return render(request, 'chat/join.html', context)
except Exception as e:
logger.error(e)
try:
if attendee is not None:
Attendee.objects.delete(attendee)
if attendance_date is not None:
AttendeeAttendanceDate.objects.delete(attendance_date)
except Exception:
pass
messages.error(
request,
_(
"The attendee couldn't be registered (check form errors)"
)
)
return render(
request,
'registration/attendee/by-collaborator.html',
update_event_info(
event_slug,
event_uid,
request,
{'form': form}
)
def certexpired(request, page=None, order=None):
if(page==None):
return HttpResponsePermanentRedirect("expired/1")
page = int(page)
list_of_certs = []
paginator = Paginator(MetadataCountQuerySet(Certificate.objects.filter(not_after__lt=timezone.now()), 'number_of_expired_certs'), ITEMS_PER_PAGE)
# paginator = Paginator(Certificate.objects.filter(not_after__lt=timezone.now()), ITEMS_PER_PAGE)
if(page in paginator.page_range):
list_of_certs = paginator.page(page)
return render(request, 'observer/certs.html',
{
'list_of_certs': list_of_certs
}
continue
if type(v) is list and len(v) == 1:
v = v[0]
data[k] = v
proposal = GrantProposal(grant_id=grant.id, data=json.dumps(data))
# assume any file is image
if request.FILES:
proposal.image = request.FILES[request.FILES.keys()[0]]
proposal.save()
messages.success(request, 'We have recieved your submission. Thanks!')
return redirect('commissions_index')
return render(request, grant.template, {'grant': grant})
def add_manufacturer(request, template_name="manage/manufacturers/add_manufacturer.html"):
"""Form and logic to add a manufacturer.
"""
if request.method == "POST":
form = ManufacturerAddForm(data=request.POST)
if form.is_valid():
new_manufacturer = form.save()
return HttpResponseRedirect(
reverse("lfs_manage_manufacturer", kwargs={"manufacturer_id": new_manufacturer.id}))
else:
form = ManufacturerAddForm()
return render(request, template_name, {
"form": form,
"selectable_manufacturers_inline": selectable_manufacturers_inline(request, 0),
"came_from": (request.POST if request.method == 'POST' else request.GET).get("came_from",
reverse("lfs_manufacturer_dispatcher")),
})
max_nr = resource.relations_to.filter(predicate=__extent__).aggregate(Max('sort_order'))
sort_order = 0 if max_nr.get('sort_order__max') is None else int(max_nr.get('sort_order__max')) + 1
Relation.objects.create(**{
'source': content_region,
'target': resource,
'predicate': __extent__,
'container': resource.container,
'sort_order': sort_order,
})
if on_valid:
return HttpResponseRedirect(on_valid)
context.update({'form': form})
return render(request, 'define_resource_content_region.html', context)