Exemple #1
0
    def POST(self, refId):
        form = self.form

        if not form.validates():
            return render.view(form)
        model.new_post(form.d.title, form.d.content, auth.getUser().user_id, refId)
        raise web.seeother("/")
Exemple #2
0
 def POST(self):
     bdurl = str(web.input().tiebaurl)
     worm = model.NetWorm_baidu(bdurl)
     worm.baidu_tieba()
     str_content = ('').join(worm.datas)
     model.new_post(worm.author, worm.title, str_content)
     raise web.seeother('/backstage')
Exemple #3
0
    def POST(self):
        form = self.form()

        if not form.validates():
            return render.form(form, self.title)
        model.new_post(form.d.title, form.d.content, auth.getUser().user_id)
        raise web.seeother("/")
Exemple #4
0
 def POST(self):
     form = self.form()
     if not form.validates():
         return render.new(form)
     model.new_post(form.d.producto, form.d.descripcion, form.d.existencias,
                    form.d.precio_compra, form.d.precio_venta)
     raise web.seeother('/')
Exemple #5
0
 def POST(self):
     form = self.form()
     # TODO dynamic member.
     if not form.validates():
         return render.new(form)
     model.new_post(form.d.title, form.d.content)
     raise web.seeother("/")
Exemple #6
0
	def POST(self):
		form = self.form()
		if not form.validates():
			return render.new(form)

		model.new_post(form.d.title,form.d.content,form.d.class_id)
		raise web.seeother('/')
Exemple #7
0
 def POST(self):
     form = self.form()
     log.logd('New','post...')
     if not form.validates():
         log.logd('New','not validates()...')
         return render.new(form)
     model.new_post(form.d.title,form.d.content)
     raise web.seeother('/')
Exemple #8
0
 def POST(self):
     form = self.form
     if not web.cookies().get('username'):
         web.seeother('/')
     if not form.validates():
         return render.new(form)
     model.new_post(form.d.title, form.d.content)
     raise web.seeother('/')
Exemple #9
0
 def POST(self):
     form = self.form()
     if not form.validates():
         return render.new(form)
     title = form.d.title
     content = form.d.content
     model.new_post(title, content)
     raise web.seeother('/')
Exemple #10
0
def new_post():
        # Create a new article
        # GET generates the form
        # POST creates it in DB
	if request.method=='GET':
		return render_template('new.html')
	elif request.method=='POST':
		model.new_post(request.form['title'], request.form['abstract'], request.form['text'],request.form['tags'])
	return redirect(url_for('index'))
Exemple #11
0
 def POST(self):
     form = self.form()
     if not form.validates():
         return render.new(form)
     if str(form.d.password) == '123':
         model.new_post(form.d.title, form.d.content, form.d.link, form.d.link_name)
         raise web.seeother('/')
     else:
         return render.new(form)
Exemple #12
0
	def POST(self):
		form = self.form()
		if not session.get('logged_in', False):
			raise web.seeother('/login')
		else:
			if not form.validates():
				posts = model.get_posts()
				return render.index(posts, form)
			model.new_post(form.d.title, form.d.content, str(date.today()))
			raise web.seeother('/')
Exemple #13
0
def new_post():
    # Create a new article
    # GET generates the form
    # POST creates it in DB
    if request.method == 'GET':
        return render_template('new.html')
    elif request.method == 'POST':
        model.new_post(request.form['title'], request.form['abstract'],
                       request.form['text'], request.form['tags'])
    return redirect(url_for('index'))
Exemple #14
0
 def POST(self):
     print "New:POST"
     form = self.form()
     if not form.validates():
         return render.new(form)
     print "Post2"
     print form.d.title
     print form.d.content
     model.new_post(form.d.title, form.d.content)
     raise web.seeother('/')
Exemple #15
0
 def POST(self):
     form = self.form()
     imagen = web.input(imagen_producto={})
     filedir = 'static/imagen'
     filepath = imagen.imagen_producto.filename.replace('\\','/')
     filename = filepath.split('/')[-1]
     fout= open(filedir+'/'+filename,'w')
     fout.write(imagen.imagen_producto.file.read())
     fout.close()
     imagen_producto = filename
     if not form.validates():
         return render.new(form)
     model.new_post(form.d.nombre, form.d.descripcion,form.d.existencias, form.d.precio_compra, form.d.precio_venta, imagen)
     raise web.seeother('/')
Exemple #16
0
def create_post():
    if 'username' in session:
        username = session['username']
        current_user = model.get_user(username)

    if request.method == 'GET':
        return render_template('create_post.html', current_user=current_user)

    new_content = html.escape(request.form['content'])
    type = html.escape(request.form['type'])

    logging.debug("create_post: Trying (%s, %s, %s)" %
                  (username, new_content, type))

    if not new_content:
        flash("You need to introduce some content.", 'error')
        return render_template('create_post.html', current_user=current_user)

    try:
        new_post = model.new_post(username, new_content, type)
    except Exception as e:
        logging.debug("create_post: Found exception(%s)" % e)
        return error(e)

    if new_post:
        flash("Succesfully created new post", )
        logging.debug("create_post: Succesful (%s)" % (username))
    else:
        flash("Could not create new post", )

    return redirect(url_for('home'))
Exemple #17
0
 def POST(self):
     if not session.admin:
         authorization_error()
     form = self.form()
     if not form.validates():
         return render.new(form)
     post_id = model.new_post(form.d.title, form.d.details, session.userId)
     raise web.seeother('/view/%d' % post_id)
Exemple #18
0
 def POST(self):
     x = web.input(addOther={})
     filedir = 'https://www.xn--r35a.tech/lingxi_images/'
     if 'addOther' in x: # to check if the file-object is created
         filepath=x.addOther.filename.replace('\\','/') # replaces the windows-style slashes with linux ones.
         filename=filepath.split('/')[-1] # splits the and chooses the last part (the filename with extension)
         if filename:
             fullFileName = filedir + filename
             fout = open('/root/images/' + filename,'wb') # creates the file where the uploaded file should be stored
             fout.write(x.addOther.file.read()) # writes the uploaded file to the newly created file.
             fout.close() # closes the file, upload complete.
             model.new_post(x.title, x.content, fullFileName)
         else:
             model.new_post(x.title, x.content, None)
     #raise web.seeother("/")
     posts = model.get_posts()
     return render.index(posts)
Exemple #19
0
 def POST(self):
     if not session.admin:
         authorization_error()
     form = self.form()
     if not form.validates():
         return render.new(form)
     post_id = model.new_post(form.d.title, form.d.details, session.userId)
     raise web.seeother('/view/%d' % post_id)
Exemple #20
0
 def POST(self):
     form = self.form()
     imagen = web.input(imagen_usuario={})
     filedir = 'static/images'
     filepath = imagen.imagen_usuario.filename.replace('\\', '/')
     filename = filepath.split('/')[-1]
     #copiar archivo al servidor
     fout = open(filedir + '/' + filename, 'w')
     fout.write(imagen.imagen_usuario.file.read())
     fout.close()
     imagen_producto = filename
     if not form.validates():
         return render.new(form)
     model.new_post(form.d.name, form.d.ap_paterno, form.d.ap_materno,
                    form.d.account_name, form.d.age, form.d.email,
                    form.d.password, imagen_usuario)
     raise web.seeother('/')
Exemple #21
0
 def POST(self):
     f = form.post_add_form()
     if not f.validates():
         return render().add(f)
     else:
         post_id = model.new_post(f.d.username, f.d.password, f.d.title, f.d.content)
         if post_id:
             return web.redirect("/view/%d" % post_id)
         else:
             return render().failed()
Exemple #22
0
def get_post(subject):
    if request.get_cookie("username", secret='m14AGroup6'):
        title = html.escape(request.forms.get('title'))
        if len(title) > 100:
            return model.error("Length Error")
        content = html.escape(request.forms.get('content'))
        print(content)
        if len(content) > 250:
            return model.error("Length Error")
        username = request.get_cookie("username", secret='m14AGroup6')
        return model.new_post(subject, title, content, username)
    else:
        return model.login()
    def POST(self):
        if session.user == 'admin':
            f = form.post_add_form()
            if not f.validates():
                return render({'title': settings.SITE_NAME}).add(f)
            else:
                post_id = model.new_post(f.d.name, f.d.address, f.d.username, f.d.password, f.d.tag)
                if post_id:
                    return web.redirect("/view/%d" % post_id)
                else:
                    return render({'title': settings.SITE_NAME}).failed()
        else:
	    return render({'title': settings.SITE_NAME}).notauth()
 def POST(self):
     if session.user == 'admin':
         f = form.post_add_form()
         if not f.validates():
             return render({'title': settings.SITE_NAME}).add(f)
         else:
             post_id = model.new_post(f.d.name, f.d.address, f.d.username,
                                      f.d.password, f.d.tag)
             if post_id:
                 return web.redirect("/view/%d" % post_id)
             else:
                 return render({'title': settings.SITE_NAME}).failed()
     else:
         return render({'title': settings.SITE_NAME}).notauth()
Exemple #25
0
    def post(self):
        if not self.user:
            self.redirect('/login?from_path=/newpost')
        #TBD: be sure that the code below will not run after redirect
        subject = self.get_from_request('subject')
        content = self.get_from_request('content')

        if subject and content:
            post = model.new_post(subject = subject, content = content,
                                  author = self.user.username)
            self.redirect('posts/%s' % post)
        else:
            error = 'We need both the content and title of the post'
            self.render('newpost.html', error = error, 
                                        subject = subject, 
                                        content = content)
Exemple #26
0
	def POST(self): 
		i = web.input(author_id=None, title=None, 
					  content=None, excerpt=None, 
					  slug=None, post_type='blog', 
					  comment_status='open', post_status='published', 
					  tags=[], categories=[])
	
		#TODO author id	
		#TODO slug 
		if i.slug == '': i.slug = None
		i.author_id = 1
		if i.title and i.content: # and i.author_id:
			insert_id = model.new_post(i.author_id, i.title, 
									   i.content, i.excerpt,
									   i.slug, i.post_type, 
									   i.comment_status, i.post_status, 
									   i.tags, i.categories)
			if insert_id:
				raise web.seeother("/admin/edit-post/%d?message=%s" % (insert_id, MESSAGE_NEW_POST_DONE))
			else:
				return admin_render.post(None, i, MESSAGE_NEW_POST_ERROR)
		else:
			return admin_render.post(None, i, MESSAGE_NEED_TITLE_OR_CONTENT)
Exemple #27
0
def create_post():
    username = None
    user = None
    if 'username' in session:
        username = session['username']
        user = model.get_user(username)

    safe = model.check_location(username)
    if request.method == 'GET':
        return render_template('create_post.html', current_user=user, safe=safe)

    new_content = request.form['content']
    type = request.form['type']

    logging.debug("create_post: Trying (%s, %s, %s)" % (username, new_content, type))

    if not new_content:
        flash("You need to introduce some content.", 'error')
        if type == "Secret" and not safe:
            return error("User is not in safe location")
        return render_template('create_post.html', current_user=user, safe=safe)

    try:
        if type == "Secret" and not safe:
            return error("User is not in safe location")
        new_post = model.new_post(username, new_content, type)
    except Exception as e:
        logging.debug("create_post: Found exception(%s)" % e)
        return error("Error: Could not create the post")

    if new_post:
        flash("Succesfully created new post",)
        logging.debug("create_post: Succesful (%s)" % (username))
    else:
        flash("Could not create new post",)

    return redirect(url_for('home'))
Exemple #28
0
 def POST(self):
     model.new_post(web.cookies().get('username'),
                    web.input().post_title,
                    web.input().post_text)
     raise web.seeother('/')
Exemple #29
0
 def POST(self):
     form = self.form()
     if not form.validates():
         return render.new(form)
     model.new_post(form.d.title, form.d.content)
     raise web.seeother("/")
Exemple #30
0
import model
"""
now its just in smoke test level.
"""

if __name__ == '__main__':
	#clear data
	for i in range(1,100):
		model.delete_post(i)
	for j in range(3, 100):
		model.delete_category(j)

	post_id = model.new_post(1, 'title', 'content', None, None, 'blog', 'open', 'published', None, None)
	assert(post_id)
	
	post = model.get_post(post_id)

	assert(post.author_id == 1 and post.title == 'title' and post.content == 'content' and post.excerpt== None and post.slug == None and post.post_type=='blog' and post.comment_status=='open' and post.post_status=='published')

	c = model.get_post_categories(post_id)
	assert(len(c) == 1 and c[0].name == 'uncategorized' and c[0].parent_id == 0 and c[0].id == 1 and c[0].description == '' and c[0].type=='post_category')
	
	# test tag. TODO.
	assert(model.update_post(post_id, author_id=2, title='new title', content='new content', comment_status='close', post_status='saved'))
	
	post = model.get_post(post_id)
	assert(post.author_id == 2 and post.title == 'new title' and post.content == 'new content' and post.excerpt== None and post.slug == None and post.post_type=='blog' and post.comment_status=='close' and post.post_status=='saved')
	
	assert(model.update_post(post_id, author_id=1, title='title', content='content', comment_status='open', post_status='published'))

	another_post_id = model.new_post(1, 'title', 'content', None, None, 'blog', 'open', 'published', None, None)
    def POST(self):
        form = self.form()
        if not form.validates():
            return render.createPoll(form)
	model.new_post(form.d.title,form.d.content);
	raise web.seeother('/createPoll')
Exemple #32
0
def get_post(subject):
    title = request.forms.get('title')
    content = request.forms.get('content')
    return model.new_post(subject, title, content)
Exemple #33
0
	def POST(self):
		mood_data = web.input()
		model.new_post(mood_data.mood_content)
		raise web.seeother('/')
Exemple #34
0
 def POST(self):               #post提交
     form = self.form()                 #类的实例化
     if not form.validates():
         return render.new(form)                          #渲染到new的html页面,渲染form
     model.new_post(form.d.title, form.d.content)                    #数据处理模块model下new_post函数方法
     raise web.seeother('/')              #跳转到根目录,raise用于引发异常,可以去掉 raise