コード例 #1
0
ファイル: update_22_23.py プロジェクト: nsfw/GlobaLeaks
    def migrate_FieldOption(self):
        print "%s FieldOption migration assistant" % self.std_fancy

        old_objs = self.store_old.find(self.get_right_model("FieldOption", 22))

        for old_obj in old_objs:
            skip_add = False
            new_obj = self.get_right_model("FieldOption", 23)()
            for _, v in new_obj._storm_columns.iteritems():
                if v.name == 'score_points':
                    new_obj.score_points = 0
                    continue

                if v.name == 'label':
                    if 'name' in old_obj.attrs:
                        new_obj.label = old_obj.attrs['name']
                        continue
                    if 'clause' in old_obj.attrs:
                        db_update_fieldattr(self.store_new, old_obj.field_id, {'name': u'clause', 'type': u'localized', 'value': old_obj.attrs['clause']})
                        skip_add = True
                    if 'agreement_statement' in old_obj.attrs:
                        db_update_fieldattr(self.store_new, old_obj.field_id, {'name': u'agreement_statement', 'type': u'localized', 'value': old_obj.attrs['agreement_statement']})
                        skip_add = True
                    continue

                setattr(new_obj, v.name, getattr(old_obj, v.name))

            if not skip_add:
                self.store_new.add(new_obj)

        self.store_new.commit()
コード例 #2
0
ファイル: update_22_23.py プロジェクト: nsfw/GlobaLeaks
    def migrate_Field(self):
        print "%s Field migration assistant" % self.std_fancy

        old_objs = self.store_old.find(self.get_right_model("Field", 22))

        for old_obj in old_objs:
            new_obj = self.get_right_model("Field", 23)()

            if old_obj.type == 'inputbox' or old_obj.type == 'textarea':
                db_update_fieldattr(self.store_new, old_obj.id, {'name': u'min_len', 'type': u'int', 'value':'0'})
                db_update_fieldattr(self.store_new, old_obj.id, {'name': u'max_len', 'type': u'int', 'value':'-1'})
                db_update_fieldattr(self.store_new, old_obj.id, {'name': u'regexp', 'type': u'unicode', 'value':''})

            if old_obj.type == 'tos':
                db_update_fieldattr(self.store_new, old_obj.id, {'name': u'clause', 'type': u'localized', 'value': '{"en": ""}'})
                db_update_fieldattr(self.store_new, old_obj.id, {'name': u'agreement_statement', 'type':u'localized', 'value':'{"en": ""}'})

            for _, v in new_obj._storm_columns.iteritems():
                if v.name == 'template_id':
                    # simply skip so to inizialize to NULL
                    continue

                if v.name == 'width':
                    new_obj.width = 0
                    continue

                if v.name == 'multi_entry_hint':
                    new_obj.multi_entry_hint = {'en': ''}
                    continue

                setattr(new_obj, v.name, getattr(old_obj, v.name))

            self.store_new.add(new_obj)

        self.store_new.commit()
コード例 #3
0
ファイル: update_22_23.py プロジェクト: nsfw/GlobaLeaks
    def migrate_Field(self):
        print "%s Field migration assistant" % self.std_fancy

        old_objs = self.store_old.find(self.get_right_model("Field", 22))

        for old_obj in old_objs:
            new_obj = self.get_right_model("Field", 23)()

            if old_obj.type == 'inputbox' or old_obj.type == 'textarea':
                db_update_fieldattr(self.store_new, old_obj.id, {
                    'name': u'min_len',
                    'type': u'int',
                    'value': '0'
                })
                db_update_fieldattr(self.store_new, old_obj.id, {
                    'name': u'max_len',
                    'type': u'int',
                    'value': '-1'
                })
                db_update_fieldattr(self.store_new, old_obj.id, {
                    'name': u'regexp',
                    'type': u'unicode',
                    'value': ''
                })

            if old_obj.type == 'tos':
                db_update_fieldattr(self.store_new, old_obj.id, {
                    'name': u'clause',
                    'type': u'localized',
                    'value': '{"en": ""}'
                })
                db_update_fieldattr(
                    self.store_new, old_obj.id, {
                        'name': u'agreement_statement',
                        'type': u'localized',
                        'value': '{"en": ""}'
                    })

            for _, v in new_obj._storm_columns.iteritems():
                if v.name == 'template_id':
                    # simply skip so to inizialize to NULL
                    continue

                if v.name == 'width':
                    new_obj.width = 0
                    continue

                if v.name == 'multi_entry_hint':
                    new_obj.multi_entry_hint = {'en': ''}
                    continue

                setattr(new_obj, v.name, getattr(old_obj, v.name))

            self.store_new.add(new_obj)

        self.store_new.commit()
コード例 #4
0
    def migrate_FieldOption(self):
        old_node = self.store_old.find(self.model_from['Node']).one()

        old_objs = self.store_old.find(self.model_from['FieldOption'])
        for old_obj in old_objs:
            skip_add = False
            new_obj = self.model_to['FieldOption']()
            for _, v in new_obj._storm_columns.items():
                if v.name == 'score_points':
                    new_obj.score_points = 0
                    continue

                try:
                    field = self.store_old.find(self.model_from['Field'],
                                                id=old_obj.field_id).one()
                    if v.name == 'label':
                        if 'name' in old_obj.attrs:
                            new_obj.label = old_obj.attrs['name']
                            continue
                        if 'clause' in old_obj.attrs:
                            value = old_obj.attrs['clause'].get(
                                old_node.default_language, '')
                            db_update_fieldattr(
                                self.store_new, field, u'clause', {
                                    'name': u'clause',
                                    'type': u'localized',
                                    'value': value
                                }, old_node.default_language)
                            skip_add = True
                        if 'agreement_statement' in old_obj.attrs:
                            value = old_obj.attrs['agreement_statement'].get(
                                old_node.default_language, '')
                            db_update_fieldattr(
                                self.store_new, field, u'agreement_statement',
                                {
                                    'name': u'agreement_statement',
                                    'type': u'localized',
                                    'value': value
                                }, old_node.default_language)
                            skip_add = True
                        continue
                except Exception:
                    pass

                setattr(new_obj, v.name, getattr(old_obj, v.name))

            if skip_add:
                self.entries_count['FieldOption'] -= 1
                continue

            self.store_new.add(new_obj)
コード例 #5
0
ファイル: update_22_23.py プロジェクト: nsfw/GlobaLeaks
    def migrate_FieldOption(self):
        print "%s FieldOption migration assistant" % self.std_fancy

        old_objs = self.store_old.find(self.get_right_model("FieldOption", 22))

        for old_obj in old_objs:
            skip_add = False
            new_obj = self.get_right_model("FieldOption", 23)()
            for _, v in new_obj._storm_columns.iteritems():
                if v.name == 'score_points':
                    new_obj.score_points = 0
                    continue

                if v.name == 'label':
                    if 'name' in old_obj.attrs:
                        new_obj.label = old_obj.attrs['name']
                        continue
                    if 'clause' in old_obj.attrs:
                        db_update_fieldattr(
                            self.store_new, old_obj.field_id, {
                                'name': u'clause',
                                'type': u'localized',
                                'value': old_obj.attrs['clause']
                            })
                        skip_add = True
                    if 'agreement_statement' in old_obj.attrs:
                        db_update_fieldattr(
                            self.store_new, old_obj.field_id, {
                                'name': u'agreement_statement',
                                'type': u'localized',
                                'value': old_obj.attrs['agreement_statement']
                            })
                        skip_add = True
                    continue

                setattr(new_obj, v.name, getattr(old_obj, v.name))

            if not skip_add:
                self.store_new.add(new_obj)

        self.store_new.commit()
コード例 #6
0
ファイル: __init__.py プロジェクト: br1n0/GlobaLeaks
    def migrate_Field(self):
        old_objs = self.store_old.find(self.model_from['Field'])
        for old_obj in old_objs:
            new_obj = self.model_to['Field']()

            if old_obj.type == 'inputbox' or old_obj.type == 'textarea':
                db_update_fieldattr(self.store_new, old_obj.id, u'min_len', {'name': u'min_len', 'type': u'int', 'value':'0'}, 'en')
                db_update_fieldattr(self.store_new, old_obj.id, u'max_len', {'name': u'max_len', 'type': u'int', 'value':'-1'}, 'en')
                db_update_fieldattr(self.store_new, old_obj.id, u'regex', {'name': u'regexp', 'type': u'unicode', 'value':''}, 'en')

            for _, v in new_obj._storm_columns.iteritems():
                if v.name == 'template_id':
                    # simply skip so to inizialize to NULL
                    continue

                if v.name == 'width':
                    new_obj.width = 0
                    continue

                if v.name == 'multi_entry_hint':
                    new_obj.multi_entry_hint = {'en': ''}
                    continue

                setattr(new_obj, v.name, getattr(old_obj, v.name))

            self.store_new.add(new_obj)
コード例 #7
0
ファイル: __init__.py プロジェクト: jpobley/GlobaLeaks
    def migrate_Field(self):
        old_objs = self.store_old.find(self.model_from['Field'])
        for old_obj in old_objs:
            new_obj = self.model_to['Field']()

            if old_obj.type == 'inputbox' or old_obj.type == 'textarea':
                db_update_fieldattr(self.store_new, old_obj.id, u'min_len', {'name': u'min_len', 'type': u'int', 'value':'0'}, 'en')
                db_update_fieldattr(self.store_new, old_obj.id, u'max_len', {'name': u'max_len', 'type': u'int', 'value':'-1'}, 'en')
                db_update_fieldattr(self.store_new, old_obj.id, u'regex', {'name': u'regexp', 'type': u'unicode', 'value':''}, 'en')

            for _, v in new_obj._storm_columns.iteritems():
                if v.name == 'template_id':
                    # simply skip so to inizialize to NULL
                    continue

                if v.name == 'width':
                    new_obj.width = 0
                    continue

                if v.name == 'multi_entry_hint':
                    new_obj.multi_entry_hint = {'en': ''}
                    continue

                setattr(new_obj, v.name, getattr(old_obj, v.name))

            self.store_new.add(new_obj)
コード例 #8
0
ファイル: __init__.py プロジェクト: br1n0/GlobaLeaks
    def migrate_FieldOption(self):
        old_node = self.store_old.find(self.model_from['Node']).one()

        old_objs = self.store_old.find(self.model_from['FieldOption'])
        for old_obj in old_objs:
            skip_add = False
            new_obj = self.model_to['FieldOption']()
            for _, v in new_obj._storm_columns.iteritems():
                if v.name == 'score_points':
                    new_obj.score_points = 0
                    continue

                try:
                    if v.name == 'label':
                        if 'name' in old_obj.attrs:
                            new_obj.label = old_obj.attrs['name']
                            continue
                        if 'clause' in old_obj.attrs:
                            value = old_obj.attrs['clause'].get(old_node.default_language, '')
                            db_update_fieldattr(self.store_new, old_obj.field_id, u'clause', {'name': u'clause', 'type': u'localized', 'value': value}, old_node.default_language)
                            skip_add = True
                        if 'agreement_statement' in old_obj.attrs:
                            value = old_obj.attrs['agreement_statement'].get(old_node.default_language, '')
                            db_update_fieldattr(self.store_new, old_obj.field_id, u'agreement_statement', {'name': u'agreement_statement', 'type': u'localized', 'value': value}, old_node.default_language)
                            skip_add = True
                        continue
                except Exception:
                    pass

                setattr(new_obj, v.name, getattr(old_obj, v.name))

            if skip_add:
                self.entries_count['FieldOption'] -= 1
                continue

            self.store_new.add(new_obj)