예제 #1
0
    def clean(self):
        cleaned_data = super(UserForm, self).clean()

        if 'declined_bill' not in cleaned_data or not resource_exchange_storage.get_exchange_for_bill_id(cleaned_data['declined_bill']):
            raise ValidationError(u'Закон уже не действует или не может быть отменён')

        return cleaned_data
예제 #2
0
    def clean(self):
        cleaned_data = super(UserForm, self).clean()

        if 'declined_bill' not in cleaned_data or not resource_exchange_storage.get_exchange_for_bill_id(cleaned_data['declined_bill']):
            raise ValidationError(u'Закон уже не действует или не может быть отменён')

        return cleaned_data
예제 #3
0
    def test_get_exchanges_for_bill_id__exists(self):
        from the_tale.accounts.prototypes import AccountPrototype
        from the_tale.accounts.logic import register_user

        from the_tale.forum.models import Category, SubCategory
        from the_tale.game.bills.conf import bills_settings
        from the_tale.game.bills import bills
        from the_tale.game.bills.prototypes import BillPrototype

        result, account_id, bundle_id = register_user('test_user',
                                                      '*****@*****.**',
                                                      '111111')
        account = AccountPrototype.get_by_id(account_id)

        forum_category = Category.objects.create(caption='category-1',
                                                 slug='category-1')
        SubCategory.objects.create(caption=bills_settings.FORUM_CATEGORY_UID +
                                   '-caption',
                                   uid=bills_settings.FORUM_CATEGORY_UID,
                                   category=forum_category)

        bill_data = bills.PlaceRenaming(
            place_id=self.place_1.id,
            name_forms=names.generator.get_test_name('new_name'))
        bill = BillPrototype.create(
            account,
            'bill-caption',
            'bill-rationale',
            bill_data,
            chronicle_on_accepted='chronicle-on-accepted')

        ResourceExchangePrototype.create(place_1=self.place_1,
                                         place_2=self.place_2,
                                         resource_1=self.resource_1,
                                         resource_2=self.resource_2,
                                         bill=None)

        exchange_2 = ResourceExchangePrototype.create(
            place_1=self.place_1,
            place_2=self.place_3,
            resource_1=self.resource_1,
            resource_2=self.resource_2,
            bill=bill)

        ResourceExchangePrototype.create(place_1=self.place_2,
                                         place_2=self.place_3,
                                         resource_1=self.resource_1,
                                         resource_2=self.resource_2,
                                         bill=None)

        self.assertEqual(
            exchange_2.id,
            resource_exchange_storage.get_exchange_for_bill_id(bill.id).id)
예제 #4
0
    def test_get_exchanges_for_bill_id__exists(self):
        from the_tale.accounts.prototypes import AccountPrototype
        from the_tale.accounts.logic import register_user

        from the_tale.forum.models import Category, SubCategory
        from the_tale.game.bills.conf import bills_settings
        from the_tale.game.bills import bills
        from the_tale.game.bills.prototypes import BillPrototype

        result, account_id, bundle_id = register_user('test_user', '*****@*****.**', '111111')
        account = AccountPrototype.get_by_id(account_id)

        forum_category = Category.objects.create(caption='category-1', slug='category-1')
        SubCategory.objects.create(caption=bills_settings.FORUM_CATEGORY_UID + '-caption',
                                   uid=bills_settings.FORUM_CATEGORY_UID,
                                   category=forum_category)

        bill_data = bills.PlaceRenaming(place_id=self.place_1.id, name_forms=names.generator.get_test_name('new_name'))
        bill = BillPrototype.create(account, 'bill-caption', 'bill-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')

        ResourceExchangePrototype.create(place_1=self.place_1,
                                         place_2=self.place_2,
                                         resource_1=self.resource_1,
                                         resource_2=self.resource_2,
                                         bill=None)

        exchange_2 = ResourceExchangePrototype.create(place_1=self.place_1,
                                                      place_2=self.place_3,
                                                      resource_1=self.resource_1,
                                                      resource_2=self.resource_2,
                                                      bill=bill)

        ResourceExchangePrototype.create(place_1=self.place_2,
                                         place_2=self.place_3,
                                         resource_1=self.resource_1,
                                         resource_2=self.resource_2,
                                         bill=None)

        self.assertEqual(exchange_2.id, resource_exchange_storage.get_exchange_for_bill_id(bill.id).id)
예제 #5
0
 def end(self, bill):
     exchange = resource_exchange_storage.get_exchange_for_bill_id(bill.id)
     if exchange:
         exchange.remove()
예제 #6
0
 def test_get_exchanges_for_bill_id_no(self):
     self.assertEqual(
         resource_exchange_storage.get_exchange_for_bill_id(666), None)
예제 #7
0
 def test_get_exchanges_for_bill_id_no(self):
     self.assertEqual(resource_exchange_storage.get_exchange_for_bill_id(666), None)
 def end(self, bill):
     exchange = resource_exchange_storage.get_exchange_for_bill_id(bill.id)
     if exchange:
         exchange.remove()