def created_ad():
category = get_category()
db.ad_post.public_ad.readable = False
db.ad_post.public_ad.writable = False
db.ad_post.visit.readable = False
db.ad_post.visit.writable = False
from gluon.utils import web2py_uuid
db.ad_post.uuid.default = uuid = web2py_uuid()
if auth.user:
user = auth.user
form = SQLFORM.factory(db.ad_post, formstyle='divs')
if form.process().accepted:
id = db.ad_post.insert(**db.ad_post._filter_fields(form.vars))
db.contact.insert(index_contact=address.index_contact,
country=address.country,
region=address.region,
city=address.city,
address=address.address,
telephone=address.telephone,
email=address.email,
ad_post=id,
name_contact=auth.user.first_name + " " + auth.user.last_name)
session.flash = T('Thank you, ad completed and sent for review')
redirect(URL('list_all_ads_by_datetime'))
mail.send(to=[form.vars.email],
subject='Объявление создано в категории %(title)s' % form.vars,
message='<html><body>' + form.vars.title + '<br/>' + form.vars.body + '<br/>' + str(
form.vars.price) + '</body></html>',
encoding='utf-8')
else:
form = SQLFORM.factory(db.ad_post, db.contact, formstyle='divs', )
if form.process().accepted:
id = db.ad_post.insert(**db.ad_post._filter_fields(form.vars))
form.vars.ad_post = id
id = db.contact.insert(**db.contact._filter_fields(form.vars))
session.flash = T('Thank you, ad completed and sent for review')
redirect(URL('list_all_ads_by_datetime'))
mail.send(to=[form.vars.email],
subject='Объявление создано в категории %(title)s' % form.vars,
message='<html><body>' + form.vars.title + '<br/>' + form.vars.body + '<br/>' + str(
form.vars.price) + '</body></html>',
encoding='utf-8')
response.title = T('Создать новое объявление в категорию "%(name)s"') % dict(name=
category.name)
response.description = T('Создать новое объявление в категорию %(name)s') % dict(name=
category.name)
response.meta.keywords = T('Создать новое объявление в категорию %(name)s') % dict(name=
category.name)
return locals()