Esempio n. 1
0
def emailage(request):
    camefrom = request.params.get('camefrom')
    listing = Listings.get_by_name(camefrom)
    form = Form(request, schema=MailAgentSchema)
    if 'submit' in request.POST and form.validate():

        receiver = listing.user.email
        name = form.data['fullname']
        phone = form.data['mobile']
        email = form.data['email']
        sender = "%s via nairabricks.com <*****@*****.**>" % name
        subject = "Contact Request from %s via nairabricks.com" % name
        content = "<p>I am Interested in your listing at nairabricks.com. I will like to know more about %s in %s. Please get in touch with me</p>" % (
            listing.title, listing.address)
        footer = "<small>Phone: %s</small>" % phone + "<br/>"
        msg_body = "<html><head><title>"+subject+"</title></head><body>"+\
            "Concerning listing Number %s"%listing.serial +\
            "<br/>%s <br/>%s"%(content,footer)+\
            "</body></html>"
        extra_headers = {"Reply-To": '%s <%s>' % (name, email)}
        html_email_sender(request,
                          recipients=receiver,
                          subject=subject,
                          body=msg_body,
                          sender=sender,
                          extra_headers=extra_headers)
        if request.is_xhr:
            html = """<div class="alert alert-success alert-dismissable col-xs-12">
	        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            Email Sent
            </div>"""
            return Response(html)
        request.session.flash("success; Email sent")
        return HTTPFound(
            location=request.route_url('property_view', name=camefrom))
    if request.is_xhr:
        html = """<div class="alert alert-success alert-dismissable col-xs-12">
	 <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
Email not sent
</div>"""
        return Response(html)
    request.session.flash("danger; Email not sent")
    return HTTPFound(
        location=request.route_url('property_view', name=camefrom))
Esempio n. 2
0
    def view_p(self):
        name = self.request.matchdict['name']
        listing = Listings.get_by_name(name)
        if not listing:
            self.request.session.flash('warning; Listing not found')
            return HTTPFound(location=self.request.route_url('home'))
        form = Form(self.request)
        files = listing.pictures.all()
        #city = DBSession.query(Locality).filter(Locality.state_id==listing.state_id).\
        #    filter(Locality.city_name==listing.city).first()
        category = listing.property_extra
        '''
        receiver = listing.user.email
        body = """
        <html><head></head><body>
        <p>Dear %s,<p><br>

        <p>A user at Nairabricks viewed your property <a href="%s">%s</a> just now.</p>

        <p>Yours sincerely,</p>
        <p>The Happy Nairabricks Info Robot</p>
        </body>
        </html>
        """%(listing.user.fullname,self.request.route_url('property_view',name=name),listing.serial)
        if not self.request.user==listing.user:
            html_email_sender(self.request,
            subject = "Property Clicks",
            recipients=receiver,
            body = body
        )
        '''
        view_log = Content_Stat(content_id=listing.id, views=1)
        DBSession.add(view_log)
        DBSession.flush()

        return dict(files=files,
                    title=listing.title,
                    form=FormRenderer(form),
                    category=category,
                    listing=listing
                    #, locality=city
                    )