Esempio n. 1
0
    def save(self):
        basedata = dict(
            fam = self.form.fam.data,
            lang = self.form.lang.data,
            cat_from = self.form.cat_from.data,
            cat_to = self.form.cat_to.data,
            note = self.form.note.data,
            date_edited = datetime.now(),
            user_id = self.user.id
        )
        if self.user.in_group(['categorymover', 'approved']):
            basedata['status'] = STATUS.QUEUE_APPROVED
        else:
            basedata['status'] = STATUS.QUEUE_WAIT

        if self.data:
            for key in basedata:
                setattr(self.data, key, basedata[key])
            trycommit(db)
            return self.data.id
        else:
            categorymover = CategoryMover(**basedata)
            db.session.add(categorymover)
            trycommit(db)
            return categorymover.id
Esempio n. 2
0
 def changeStatus(self, mode):
     if self.data.status not in STATUS.QUEUE:
         raise IDNotFoundError
     if mode == 'reject':
         self.data.status = STATUS.DONE_REJECTED
     elif mode == 'approve':
         self.data.status = STATUS.QUEUE_APPROVED
     else:
         abort(404)
     trycommit(db)
Esempio n. 3
0
    def getUser(self):
        u = model.User.query.get(1)
        if u is None:
            u = model.User(name='#')
            db.session.add(u)
            trycommit(db)

        name = self.get_current_user()
        if name is not None:
            u = model.User.query.filter_by(name=name).first()
            if not u:
                u = model.User(name=name)
                db.session.add(u)
                trycommit(db)
        return u
Esempio n. 4
0
    def getUser(self):
        u = model.User.query.get(1)
        if u is None:
            u = model.User(name='#')
            db.session.add(u)
            trycommit(db)

        name = self.get_current_user()
        if name is not None:
            u = model.User.query.filter_by(name=name).first()
            if not u:
                u = model.User(name=name)
                db.session.add(u)
                trycommit(db)
        return u
Esempio n. 5
0
    def save(self):
        wikify = None
        basedata = dict(
            date_edited = datetime.now()
        )
        fieldlist = []

        if self.action == 'translate':
            fieldlist = ['pid', 'user_translator', 'lang', 'fam',
                         'title_untranslated', 'title_translated',
                         'content_translated', 'email']
            if self.form.wikiuser.data:
                wikify = 'user_translator'
        elif self.action == 'format':
            if self.mode == 'reserve':
                basedata['user_formatter_id'] = self.user.id
                basedata['status'] = STATUS.RESERVED
            else:
                fieldlist = ['title_translated', 'content_formatted']
                basedata['status'] = STATUS.FORMATTED
        elif self.action == 'organize':
            if self.mode == 'submit':
                fieldlist = ['title_translated', 'content_formatted']
                basedata['status'] = STATUS.DONE
            else:
                return self.data.id

        for field in fieldlist:
            basedata[field] = getattr(self.form, field).data

        if wikify:
            basedata[wikify] = u'[[User:{}]]'.format(basedata[wikify])

        if self.data:
            for key in basedata:
                setattr(self.data, key, basedata[key])
            trycommit(db)
            return self.data.id
        else:
            letstranslate = LetsTranslate(**basedata)
            db.session.add(letstranslate)
            trycommit(db)
            return letstranslate.id
Esempio n. 6
0
    def save(self):
        wikify = None
        basedata = dict(date_edited=datetime.now())
        fieldlist = []

        if self.action == 'translate':
            fieldlist = [
                'pid', 'user_translator', 'lang', 'fam', 'title_untranslated',
                'title_translated', 'content_translated', 'email'
            ]
            if self.form.wikiuser.data:
                wikify = 'user_translator'
        elif self.action == 'format':
            if self.mode == 'reserve':
                basedata['user_formatter_id'] = self.user.id
                basedata['status'] = STATUS.RESERVED
            else:
                fieldlist = ['title_translated', 'content_formatted']
                basedata['status'] = STATUS.FORMATTED
        elif self.action == 'organize':
            if self.mode == 'submit':
                fieldlist = ['title_translated', 'content_formatted']
                basedata['status'] = STATUS.DONE
            else:
                return self.data.id

        for field in fieldlist:
            basedata[field] = getattr(self.form, field).data

        if wikify:
            basedata[wikify] = u'[[User:{}]]'.format(basedata[wikify])

        if self.data:
            for key in basedata:
                setattr(self.data, key, basedata[key])
            trycommit(db)
            return self.data.id
        else:
            letstranslate = LetsTranslate(**basedata)
            db.session.add(letstranslate)
            trycommit(db)
            return letstranslate.id
Esempio n. 7
0
 def recover(self):
     self.data.status = STATUS.TRANSLATED
     trycommit(db)
Esempio n. 8
0
 def reject(self):
     self.data.status = STATUS.REJECTED
     trycommit(db)
Esempio n. 9
0
 def recover(self):
     self.data.status = STATUS.TRANSLATED
     trycommit(db)
Esempio n. 10
0
 def reject(self):
     self.data.status = STATUS.REJECTED
     trycommit(db)