def _dodeleted(self): to_delete = request.POST.getall('delete') for id in to_delete: Image.load(self.db, id).delete_permanently(self.db) redirect(url(controller='admin', action='deleted'))
def _doaccepted(self): to_delete = request.POST.getall('delete') # Delete them for id in to_delete: Image.load(self.db, id).delete(self.db) redirect(url(controller='admin', action='accepted'))
def _dopending(self): # These are all the images ticked with accept to_accept = request.POST.getall('accept') # Accept all of them for id in to_accept: image = Image.load(self.db, id) image.state = 'accepted' image.store(self.db) # These are the ones to delete to_delete = request.POST.getall('delete') # Delete them for id in to_delete: Image.load(self.db, id).delete(self.db) redirect(url(controller='admin', action='pending'))
def _doedit(self, id): image = Image.load(self.db, id) image.author = request.params.getone('author') image.author_email = request.params.getone('author_email') image.author_url = request.params.getone('author_url') image.text = request.params.getone('text') # "change_day" is a hidden field that indicates that the date # is exposed in the form. we don't change the day if we are # setting the image to pending, since this creates problems # when detecting if the image has changed date if ('change_day' in self.form_result) and request.params.getone('state') == 'accepted': image.day = datetime(year=int(self.form_result.get('year')), month=int(self.form_result.get('month')), day=int(self.form_result.get('day'))) image.state = self.form_result.get('state') image.store(self.db) flash('Image successfully edited') redirect(url(controller='admin', action='edit', id=id))
def edit(self, id): c.image = Image.load(self.db, id) return render('/admin/edit.mako')