Exemplo n.º 1
0
    def make_ship(self, ship_type):
        if ship_type == Constant.SHIP_TYPE_CARRIER:
            make_ship = Carrier()
        elif ship_type == Constant.SHIP_TYPE_BATTLE_SHIP:
            make_ship = Battleship()
        elif ship_type == Constant.SHIP_TYPE_CRUISER:
            make_ship = Cruiser()
        elif ship_type == Constant.SHIP_TYPE_DESTROYER:
            make_ship = Destroyer()
        elif ship_type == Constant.SHIP_TYPE_OIL_RIG:
            make_ship = Oilrig()
        else:
            make_ship = Carrier()

        return make_ship
Exemplo n.º 2
0
def carriers():
    '''Renders and handles carriers the user adds.'''
    # Checks if user has been autherized prior to allowing entrance to route.
    if 'user_id' not in session:
        flash('You must be logged to access', 'alert-danger')
        return redirect('/')
    form = DCCarrierForm()
    # Grabs all the carrier information.
    carriers = Carrier.get_carrier_by_user(user_id=session['user_id'])
    if form.validate_on_submit():
        name = form.name.data
        address = form.address.data
        city = form.city.data
        state = form.state.data
        zip = form.zip.data
        phone = form.phone.data
        # Creates a carrier.
        carrier = Carrier(name=name,
                          address=address,
                          city=city,
                          state=state,
                          zip=zip,
                          phone=phone,
                          user_id=session['user_id'])
        # If carrier was created we commit it.
        if carrier:
            db.session.add(carrier)
            return try_commit_rollback(
                success='Carrier created!',
                fail=
                'Something went wrong, please try again later. If this continues please email [email protected].',
                route='/carriers')
    return render_template('user/carriers.html', form=form, carriers=carriers)
Exemplo n.º 3
0
 def setUp(self):
     self.carrier = Carrier(name="pricing", active=True)
     self.carrier.save()
     t = ShippingTier(carrier=self.carrier, 
         min_total=Decimal("0.00"),
         price=Decimal("10.00"),
         )
     t.save()
Exemplo n.º 4
0
 def testCreate(self):
     c = Carrier(key="test", active=True)
     c.save()
     t = ShippingTier(carrier=c, 
         min_total=Decimal("0.00"),
         price=Decimal("10.00"),
         )
     t.save()
     
     self.assertEqual(c.price(Decimal("0.00")), Decimal("10.00"))
Exemplo n.º 5
0
 def setUp(self):
     self.carrier = Carrier(name="pricing", active=True)
     self.carrier.save()
     t = QuantityTier(
         carrier=self.carrier,
         quantity=Decimal('1'),
         handling=Decimal("10.00"),
         price=Decimal("0.00"),
     )
     t.save()
Exemplo n.º 6
0
 def setUp(self):
     self.carrier = Carrier(name="pricing", active=True)
     self.carrier.save()
     self.product = Product.objects.get(slug='dj-rocks')
     t = ProductShippingPrice(
         carrier=self.carrier,
         product=self.product,
         price=Decimal("10.00"),
     )
     t.save()
Exemplo n.º 7
0
    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()

        base_prices = (
            (0, 10),
            (20, 15),
            (30, 16),
            (40, 17)
        )
        make_tiers(self.carrier, base_prices)
Exemplo n.º 8
0
    def test2Prices(self):
        c2 = Carrier(name="test2", active=True)
        c2.save()
        t = ProductShippingPrice(
            carrier=c2,
            product=self.product,
            price=Decimal("20.00"),
        )
        t.save()

        self.assertEqual(self.carrier.price(self.product), Decimal("10.00"))
        self.assertEqual(c2.price(self.product), Decimal("20.00"))
Exemplo n.º 9
0
    def testCreate(self):
        c = Carrier(key="test", active=True)
        c.save()
        product = Product.objects.get(slug='dj-rocks')
        p = ProductShippingPrice(
            carrier=c,
            product=product,
            price=Decimal("10.00"),
        )
        p.save()

        self.assertEqual(c.price(product), Decimal("10.00"))
Exemplo n.º 10
0
    def testCreate(self):
        c = Carrier(key="test", active=True)
        c.save()
        t = QuantityTier(
            carrier=c,
            quantity=Decimal('1'),
            handling=Decimal("10.00"),
            price=Decimal("0.00"),
        )
        t.save()

        self.assertEqual(c.price(1), Decimal("10.00"))
        self.assertEqual(c.price(4), Decimal("10.00"))
Exemplo n.º 11
0
def create(app):
    with app.app_context():
        db.create_all()
        print 'tables created'

        db.session.add(Carrier('at&t', 'txt.att.net'))
        db.session.add(Carrier('Verizon', 'vtext.com'))
        db.session.add(Carrier('T-Mobile', 'tmomail.net'))
        db.session.add(Carrier('Sprint', 'messaging.sprintpcs.com'))
        db.session.add(Carrier('US Cellular', 'email.uscc.net'))
        db.session.add(Carrier('Metro PCS', 'mymetropcs.com'))
        print 'default carriers added'
        db.session.commit()
Exemplo n.º 12
0
    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()

        base_prices = ((1, 10, 0), (20, 20, 1), (30, 30, 2), (40, 40, 1))
        make_tiers(self.carrier, base_prices)
Exemplo n.º 13
0
    def _create_carrier(self, carrier_id: str, name: str) -> 'Carrier':
        """Создает экземпляр Carrier."""
        carrier = Carrier(carrier_id=carrier_id, name=name)
        self._carriers[carrier_id] = carrier

        return carrier