Enable duplicate code detection for Python code
1 | """ |
||
2 | byceps.services.shop.order.models.sequence |
||
3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
4 | |||
5 | :Copyright: 2006-2020 Jochen Kupperschmidt |
||
6 | :License: Modified BSD, see LICENSE for details. |
||
7 | """ |
||
8 | |||
9 | from typing import Optional |
||
10 | |||
11 | from .....database import db, generate_uuid |
||
12 | from .....util.instances import ReprBuilder |
||
13 | |||
14 | from ...shop.transfer.models import ShopID |
||
15 | |||
16 | |||
17 | View Code Duplication | class OrderNumberSequence(db.Model): |
|
1 ignored issue
–
show
Duplication
introduced
by
Loading history...
|
|||
18 | """A shop-specific, unique order number sequence.""" |
||
19 | |||
20 | __tablename__ = 'shop_order_number_sequences' |
||
21 | |||
22 | id = db.Column(db.Uuid, default=generate_uuid, primary_key=True) |
||
23 | shop_id = db.Column(db.UnicodeText, db.ForeignKey('shops.id'), index=True, nullable=False) |
||
24 | prefix = db.Column(db.UnicodeText, unique=True, nullable=False) |
||
25 | value = db.Column(db.Integer, default=0, nullable=False) |
||
26 | |||
27 | def __init__( |
||
28 | self, |
||
29 | shop_id: ShopID, |
||
30 | prefix: str, |
||
31 | *, |
||
32 | value: Optional[int] = 0, |
||
33 | ) -> None: |
||
34 | if value is None: |
||
35 | value = 0 |
||
36 | |||
37 | self.shop_id = shop_id |
||
38 | self.prefix = prefix |
||
39 | self.value = value |
||
40 | |||
41 | def __repr__(self) -> str: |
||
42 | return ReprBuilder(self) \ |
||
43 | .add_with_lookup('id') \ |
||
44 | .add('shop', self.shop_id) \ |
||
45 | .add_with_lookup('prefix') \ |
||
46 | .add_with_lookup('value') \ |
||
47 | .build() |
||
48 |