def delete(self): name = self.request.matchdict['name'] blog = Blogs.get_by_name(name) user = blog.user if not blog: self.session.flash("warning; no such blog") return HTTPFound(location=self.request.route_url('blog_list')) body = '''<html><head></head><body> <p>Dear %s,<p><br> <p>Your blog post <a href="%s">%s</a> have just been deleted. This might be because of self promotion, abuse or outright violation of our good neighbor policy</p> <p>Please, you are only allowed to write articles that will help our community</p> <p>Yours sincerely,<br> The Happy Nairabricks Info Robot</p> </body> </html> ''' % (user.fullname, self.request.route_url('blog_view', name=blog.name), blog.title) #html_email_sender(self.request, # subject = "Blog Post deleted", # recipients=user.email, # body = body # ) DBSession.delete(blog) DBSession.flush() self.session.flash("success; blog_deleted") return HTTPFound(location=self.request.route_url('blog_list'))
def delete(self): id = self.request.matchdict['id'] listing = Listings.get_by_id(id) if listing: DBSession.delete(listing) DBSession.flush() return HTTPFound(location=self.request.route_url('home')) else: self.request.session.flash("warning; Listing not found") return HTTPFound(location='/')
def delete(self): prefix = self.request.matchdict['prefix'] user = Users.get_by_path(prefix) if user: DBSession.delete(user) DBSession.flush() return HTTPFound(location=self.request.route_url('home')) else: self.request.session.flash("warning; User not found") return HTTPFound(location='/')
def delete_m(self): id = self.request.matchdict['id'] user_id = self.request.matchdict['user_id'] message = Messages.get_by_id(id) if not message: self.session.flash('info; No such message') return HTTPFound(location=self.request.route_url('home')) DBSession.delete(message) DBSession.flush() return HTTPFound(location=self.request.route_url('inbox', id=user_id))
def delete_lga(request): dbsession=DBSession() lga_id = request.matchdict['lga_id'] state_id = request.matchdict['state_id'] lga = LGA.get_by_id(lga_id) if lga is None: request.session.flash('info; No such LGA') return HTTPFound(location = request.route_url("view_state",state_id=state_id)) try: dbsession.delete(lga) request.session.flash('success; LGA deleted') return HTTPFound(location = request.route_url("view_state",state_id=state_id)) except IntegrityError: transaction.abort() request.session.flash('info; operation failed') return HTTPFound(location = request.route_url("view_state",state_id=state_id))
def delete_district(request): dbsession=DBSession() district_id = request.matchdict['district_id'] lga_id = request.matchdict['lga_id'] district = District.get_by_id(district_id) if district is None: request.session.flash('info; No such area') return HTTPFound(location = request.route_url("view_district",lga_id=lga_id)) try: dbsession.delete(district) DBSession.flush() request.session.flash('success; district deleted') return HTTPFound(location = request.route_url("view_lga",lga_id=lga_id)) except IntegrityError: transaction.abort() request.session.flash('info; operation failed') return HTTPFound(location = request.route_url("view_lga",lga_id=lga_id))
def delete_listing_category(request): dbsession = DBSession() id = request.matchdict['id'] category = PropertyCategory.get_by_id(id) if category is None: request.session.flash('danger; No such category ') return HTTPFound(location=request.route_url("listing_category_list")) try: transaction.begin() dbsession.delete(category) transaction.commit() request.session.flash('success; Category deleted') return HTTPFound(location=request.route_url("listing_category_list")) except IntegrityError: transaction.abort() request.session.flash('danger; Unable to delete category') return HTTPFound(location=request.route_url("listing_category_list"))