|
|
@@ -29,18 +29,3 @@ class NewPin(CreateView): |
|
|
|
def form_invalid(self, form): |
|
|
|
messages.error(self.request, 'Pin did not pass validation!') |
|
|
|
return super(NewPin, self).form_invalid(form) |
|
|
|
|
|
|
|
|
|
|
|
def delete_pin(request, pin_id): |
|
|
|
try: |
|
|
|
pin = Pin.objects.get(id=pin_id) |
|
|
|
if pin.submitter == request.user: |
|
|
|
pin.delete() |
|
|
|
messages.success(request, 'Pin successfully deleted.') |
|
|
|
else: |
|
|
|
messages.error(request, 'You are not the submitter and can not ' |
|
|
|
'delete this pin.') |
|
|
|
except Pin.DoesNotExist: |
|
|
|
messages.error(request, 'Pin with the given id does not exist.') |
|
|
|
|
|
|
|
return HttpResponseRedirect(reverse('pins:recent-pins')) |