Пример #1
0
    def save(self, data):

        broken = self.separate_broken_data()[1]
        working = utils.additional_data_dictionary(data, self.fti)

        if broken:
            self.additional_data = utils.merge_data_dictionaries(broken, working)
        else:
            self.additional_data = working

        def save():
            if self.reservation.email != data["email"]:
                self.scheduler.change_email(self.token, data["email"])

            self.scheduler.change_reservation_data(self.token, self.additional_data)
            self.flash(_(u"Formdata updated"))

        utils.handle_action(action=save, success=self.redirect_to_context)
Пример #2
0
    def save(self, data):

        broken = self.separate_broken_data()[1]
        working = utils.additional_data_dictionary(data, self.fti)

        if broken:
            self.additional_data = utils.merge_data_dictionaries(
                broken, working)
        else:
            self.additional_data = working

        def save():
            if self.reservation.email != data['email']:
                self.scheduler.change_email(self.token, data['email'])

            self.scheduler.change_reservation_data(self.token,
                                                   self.additional_data)
            self.flash(_(u'Formdata updated'))

        utils.handle_action(action=save, success=self.redirect_to_context)
Пример #3
0
    def test_merge_additional_data(self):
        base, extra = {}, {}

        self.assertEqual(utils.merge_data_dictionaries(base, extra), {})

        base = {
            'form': {
                'desc': "Base Description",
                'interface': "Base Interface",
                'values': [
                    {
                        'key': "one",
                        'value': "eins",
                        'desc': "one == eins"
                    },
                    {
                        'key': "two",
                        'value': "zwei",
                        'desc': "two == zwei"
                    },
                ]
            }
        }

        extra = {
            'form': {
                'desc': "Extra Description",
                'interface': "Extra Interface",
                'values': [
                    {
                        'key': "two",
                        'value': "deux",
                        'desc': "two == deux"
                    },
                    {
                        'key': "three",
                        'value': "drei",
                        'desc': "three == drei"
                    },
                ]
            },
            'another_form': {}
        }

        merged = {
            'form': {
                'desc': "Extra Description",
                'interface': "Extra Interface",
                'values': [
                    {
                        'key': "one",
                        'value': "eins",
                        'desc': "one == eins"
                    },
                    {
                        'key': "two",
                        'value': "deux",
                        'desc': "two == deux"
                    },
                    {
                        'key': "three",
                        'value': "drei",
                        'desc': "three == drei"
                    },
                ]
            },
            'another_form': {}
        }

        self.maxDiff = None
        actual_merged = utils.merge_data_dictionaries(base, extra)

        self.assertEqual(merged.keys(), actual_merged.keys())
        self.assertEqual(
            merged['form']['values'], actual_merged['form']['values']
        )
        self.assertEqual(merged['form'], actual_merged['form'])
Пример #4
0
    def test_merge_additional_data(self):
        base, extra = {}, {}

        self.assertEqual(utils.merge_data_dictionaries(base, extra), {})

        base = {
            'form': {
                'desc':
                "Base Description",
                'interface':
                "Base Interface",
                'values': [
                    {
                        'key': "one",
                        'value': "eins",
                        'desc': "one == eins"
                    },
                    {
                        'key': "two",
                        'value': "zwei",
                        'desc': "two == zwei"
                    },
                ]
            }
        }

        extra = {
            'form': {
                'desc':
                "Extra Description",
                'interface':
                "Extra Interface",
                'values': [
                    {
                        'key': "two",
                        'value': "deux",
                        'desc': "two == deux"
                    },
                    {
                        'key': "three",
                        'value': "drei",
                        'desc': "three == drei"
                    },
                ]
            },
            'another_form': {}
        }

        merged = {
            'form': {
                'desc':
                "Extra Description",
                'interface':
                "Extra Interface",
                'values': [
                    {
                        'key': "one",
                        'value': "eins",
                        'desc': "one == eins"
                    },
                    {
                        'key': "two",
                        'value': "deux",
                        'desc': "two == deux"
                    },
                    {
                        'key': "three",
                        'value': "drei",
                        'desc': "three == drei"
                    },
                ]
            },
            'another_form': {}
        }

        self.maxDiff = None
        actual_merged = utils.merge_data_dictionaries(base, extra)

        self.assertEqual(merged.keys(), actual_merged.keys())
        self.assertEqual(merged['form']['values'],
                         actual_merged['form']['values'])
        self.assertEqual(merged['form'], actual_merged['form'])