Beispiel #1
0
    def post_edit_statement(self, id):
        if not c.user:
            # should not happen therefore no c.returnTo
            redirect(url(controller='login', action='signin', id=id))

        query = meta.Session.query(model.Statement)
        thesis = query.filter_by(id=id).first().attachTrueFalseCount()

        if not c.user.allow_edit(thesis):
            raise Exception('no you dont')
            
        newMsg = request.params.get('msg')
        
        if len(stripMarkup(newMsg)) > int(statement_length):
            h.flash(_("Error: Only %s characters are allowed!") % statement_length)
            c.previousMessage = newMsg
            return self.edit_statement(id)        
        
        thesis.message = newMsg
        
        meta.Session.commit()
        search.update_index(thesis)
        
        

        redirect(url(controller, 'statements', action='show', id=id))
Beispiel #2
0
 def set(self, id):
     if id == 'de':
         session['lang'] = id
     elif id == 'en':
         if 'lang' in session:
             del session['lang']
     else:
         h.flash("Unknown language '" + id + "'")
         return redirect_to(controller='statements', action='index', id=None)
     
     session.save()
     self.index()
     
Beispiel #3
0
    def createNew(self):
        if not c.user:
            redirect(url(controller='login', action='signin'))
                
        message = request.params.get('msg', None)
        
        if not message:
            abort(500)
        
        parentId = request.params.get('parentid', None)
        isTrue = request.params.get('argistrue', None)
        
        if len(stripMarkup(message)) > int(statement_length):
            h.flash(_("Error: Only %s characters are allowed!") % statement_length)

            c.previousMessage = message
            
            if isTrue: 
                if isTrue == True:
                    isTrueString = "pro"
                else:
                    isTrueString = "contra"
                
                return self.newArgument(parentId, isTrueString)
            else:
                return self.newThesis()
        
        rant = model.Statement()
        rant.message = message
        rant.userid = c.user.id
        rant.votes = 0
        rant.created = datetime.now()
        rant.updated = datetime.now()
        
        
        if parentId and isTrue :
            rant.parentid=parentId
    
            if isTrue == 'True':
                rant.istrue = 1
            elif isTrue == 'False':
                rant.istrue = 0
            else: 
                log.error("unknown value for isTrue: " + isTrue)
                abort(500)
        
        meta.Session.add(rant)
        meta.Session.commit()
        
        search.add_to_index_and_commit(rant)
        

        if request.params.get('parentid', None):
            h.flash(_('You have posted a new thesis. <strong>Please vote it</strong> up if you think it\'s true or down if you think its not.'))
            redirect(url(controller='statements', action='show', id=rant.parentid))
        else:
            if isTrue == 'True':
                h.flash(_('You have posted a new pro argument. <strong>Please vote it</strong> up if you think it\'s true or down if you think its not.'))
            elif isTrue == 'False':
                h.flash(_('You have posted a new contra argument. <strong>Please vote it</strong> up if you think it\'s true or down if you think its not.'))
            redirect(url(controller='statements', action='show', id=rant.id))