Esempio n. 1
0
class NewInboundMessage(NewMessage):
    body_html = StringType()
    body_plain = StringType()
Esempio n. 2
0
 class Parent(Model):
     name = StringType(required=True)
Esempio n. 3
0
 class User(Model):
     name = StringType(required=True)
     age = IntType(required=True)
Esempio n. 4
0
 class Player(Model):
     name = StringType(required=True)
Esempio n. 5
0
 class Player(Model):
     name = StringType()
Esempio n. 6
0
class Value(Model):
    amount = FloatType(required=True, min_value=0)  # Amount as a number.
    currency = StringType(
        required=True, default=u'UAH', max_length=3,
        min_length=3)  # The currency in 3-letter ISO 4217 format.
    valueAddedTaxIncluded = BooleanType(required=True, default=True)
Esempio n. 7
0
class Document(Model):
    class Options:
        roles = {
            'create':
            blacklist('id', 'datePublished', 'dateModified', 'author',
                      'download_url'),
            'edit':
            blacklist('id', 'url', 'datePublished', 'dateModified', 'author',
                      'hash', 'download_url'),
            'embedded':
            (blacklist('url', 'download_url') + schematics_embedded_role),
            'default':
            blacklist("__parent__"),
            'view': (blacklist('revisions') + schematics_default_role),
            'revisions':
            whitelist('url', 'dateModified'),
        }

    id = MD5Type(required=True, default=lambda: uuid4().hex)
    hash = HashType()
    documentType = StringType(choices=[
        'tenderNotice',
        'awardNotice',
        'contractNotice',
        'notice',
        'biddingDocuments',
        'technicalSpecifications',
        'evaluationCriteria',
        'clarifications',
        'shortlistedFirms',
        'riskProvisions',
        'billOfQuantity',
        'bidders',
        'conflictOfInterest',
        'debarments',
        'evaluationReports',
        'winningBid',
        'complaints',
        'contractSigned',
        'contractArrangements',
        'contractSchedule',
        'contractAnnexe',
        'contractGuarantees',
        'subContract',
        'eligibilityCriteria',
        'contractProforma',
        'commercialProposal',
        'qualificationDocuments',
        'eligibilityDocuments',
        'registerExtract',
    ])
    title = StringType(required=True)  # A title of the document.
    title_en = StringType()
    title_ru = StringType()
    description = StringType()  # A description of the document.
    description_en = StringType()
    description_ru = StringType()
    format = StringType(required=True, regex='^[-\w]+/[-\.\w\+]+$')
    url = StringType(required=True)  # Link to the document or attachment.
    datePublished = IsoDateTimeType(default=get_now)
    dateModified = IsoDateTimeType(
        default=get_now)  # Date that the document was last dateModified
    language = StringType()
    relatedItem = MD5Type()
    author = StringType()

    @serializable(serialized_name="url")
    def download_url(self):
        url = self.url
        if not url or '?download=' not in url:
            return url
        doc_id = parse_qs(urlparse(url).query)['download'][-1]
        root = self.__parent__
        parents = []
        while root.__parent__ is not None:
            parents[0:0] = [root]
            root = root.__parent__
        request = root.request
        if not request.registry.docservice_url:
            return url
        if 'status' in parents[0] and parents[0].status in type(
                parents[0])._options.roles:
            role = parents[0].status
            for index, obj in enumerate(parents):
                if obj.id != url.split('/')[(index - len(parents)) * 2 - 1]:
                    break
                field = url.split('/')[(index - len(parents)) * 2]
                if "_" in field:
                    field = field[0] + field.title().replace("_", "")[1:]
                roles = type(obj)._options.roles
                if roles[role if role in roles else 'default'](field, []):
                    return url
        from openprocurement.api.utils import generate_docservice_url
        if not self.hash:
            path = [
                i for i in urlparse(url).path.split('/')
                if len(i) == 32 and not set(i).difference(hexdigits)
            ]
            return generate_docservice_url(request, doc_id, False,
                                           '{}/{}'.format(path[0], path[-1]))
        return generate_docservice_url(request, doc_id, False)

    def import_data(self, raw_data, **kw):
        """
        Converts and imports the raw data into the instance of the model
        according to the fields in the model.
        :param raw_data:
            The data to be imported.
        """
        data = self.convert(raw_data, **kw)
        del_keys = [k for k in data.keys() if data[k] == getattr(self, k)]
        for k in del_keys:
            del data[k]

        self._data.update(data)
        return self
Esempio n. 8
0
class AutoScalingGroupResource(AutoScalingResource):
    cloud_service_type = StringType(default='AutoScalingGroup')
    data = ModelType(AutoScalingGroup)
    _metadata = ModelType(CloudServiceMeta,
                          default=asg_meta,
                          serialized_name='metadata')
Esempio n. 9
0
class LaunchConfigurationResource(AutoScalingResource):
    cloud_service_type = StringType(default='LaunchConfiguration')
    data = ModelType(LaunchConfiguration)
    _metadata = ModelType(CloudServiceMeta,
                          default=lc_meta,
                          serialized_name='metadata')
class Stage(Model):
    deploymentId = StringType(required=True)
    stageName = StringType(default="UNKNOWN")
    variables = DictType(StringType, default={})
    tags = DictType(StringType, default={})
Esempio n. 11
0
class AutoScalingResource(CloudServiceResource):
    cloud_service_group = StringType(default='EC2')
class Resource(Model):
    id = StringType(required=True)
    path = StringType(required=True)
    pathPart = StringType(default=None)
    resourceMethods = DictType(ModelType(ResourceMethod), default={})
 class ResourceMethodIntegration(Model):
     type = StringType(default="UNKNOWN")
     uri = StringType()
class Api(Model):
    id = StringType(required=True)
    name = StringType(default="UNKNOWN")
Esempio n. 15
0
class Solution(OSDFModel):
    networkId = StringType(required=True)
    pciSolutions = ListType(ListType(ModelType(PCISolution), min_size=1))
    anrSolutions = ListType(ListType(ModelType(ANRSolution), min_size=1))
Esempio n. 16
0
class LaunchTemplateResource(AutoScalingResource):
    cloud_service_type = StringType(default='LaunchTemplate')
    data = ModelType(LaunchTemplateDetail)
    _metadata = ModelType(CloudServiceMeta,
                          default=lt_meta,
                          serialized_name='metadata')
Esempio n. 17
0
class PCIOptimizationResponse(OSDFModel):
    transactionId = StringType(required=True)
    requestId = StringType(required=True)
    requestStatus = StringType(required=True)
    statusMessage = StringType()
    solutions = ModelType(Solution, required=True)
Esempio n. 18
0
class Auction(BaseAuction):
    """Data regarding auction process - publicly inviting prospective contractors to submit bids for evaluation and selecting a winner or winners."""
    class Options:
        roles = {
            'edit_active.tendering': (blacklist(
                'enquiryPeriod', 'tenderPeriod', 'value', 'auction_value',
                'minimalStep', 'guarantee', 'auction_guarantee') + edit_role),
        }

    awards = ListType(ModelType(Award), default=list())
    bids = ListType(ModelType(Bid), default=list(
    ))  # A list of all the companies who entered submissions for the auction.
    cancellations = ListType(ModelType(Cancellation), default=list())
    complaints = ListType(ModelType(Complaint), default=list())
    contracts = ListType(ModelType(Contract), default=list())
    documents = ListType(ModelType(Document), default=list(
    ))  # All documents and attachments related to the auction.
    enquiryPeriod = ModelType(
        Period
    )  # The period during which enquiries may be made and will be answered.
    tenderPeriod = ModelType(
        Period
    )  # The period when the auction is open for submissions. The end date is the closing date for auction submissions.
    procurementMethodType = StringType(default="dgfOtherAssets")
    procuringEntity = ModelType(ProcuringEntity, required=True)
    status = StringType(choices=[
        'draft', 'active.tendering', 'active.auction', 'active.qualification',
        'active.awarded', 'complete', 'cancelled', 'unsuccessful'
    ],
                        default='active.tendering')
    questions = ListType(ModelType(Question), default=list())
    features = ListType(
        ModelType(Feature),
        validators=[validate_features_uniq, validate_not_available])
    lots = ListType(ModelType(Lot),
                    default=list(),
                    validators=[validate_lots_uniq, validate_not_available])
    items = ListType(ModelType(Item),
                     required=True,
                     min_size=1,
                     validators=[validate_cav_group, validate_items_uniq])

    @serializable(serialized_name="tenderPeriod", type=ModelType(Period))
    def auction_tenderPeriod(self):
        if self.tenderPeriod and self.tenderPeriod.endDate:
            return self.tenderPeriod
        endDate = calculate_business_date(self.auctionPeriod.startDate,
                                          -timedelta(days=1), self)
        return Period(dict(endDate=endDate))

    def initialize(self):
        if not self.enquiryPeriod:
            self.enquiryPeriod = type(self).enquiryPeriod.model_class()
        now = get_now()
        self.tenderPeriod.startDate = self.enquiryPeriod.startDate = now
        self.enquiryPeriod.endDate = self.tenderPeriod.endDate
        self.date = now
        if self.lots:
            for lot in self.lots:
                lot.date = now

    def validate_tenderPeriod(self, data, period):
        if not (period and period.endDate) and not (
                'auctionPeriod' in data and data['auctionPeriod'].startDate):
            raise ValidationError(u'This field is required.')

    def validate_value(self, data, value):
        if value.currency != u'UAH':
            raise ValidationError(u"currency should be only UAH")

    @serializable(serialize_when_none=False)
    def next_check(self):
        now = get_now()
        checks = []
        if self.status == 'active.tendering' and self.tenderPeriod and self.tenderPeriod.endDate:
            checks.append(self.tenderPeriod.endDate.astimezone(TZ))
        elif not self.lots and self.status == 'active.auction' and self.auctionPeriod and self.auctionPeriod.startDate and not self.auctionPeriod.endDate:
            if now < self.auctionPeriod.startDate:
                checks.append(self.auctionPeriod.startDate.astimezone(TZ))
            elif now < calc_auction_end_time(
                    self.numberOfBids,
                    self.auctionPeriod.startDate).astimezone(TZ):
                checks.append(
                    calc_auction_end_time(
                        self.numberOfBids,
                        self.auctionPeriod.startDate).astimezone(TZ))
        elif self.lots and self.status == 'active.auction':
            for lot in self.lots:
                if lot.status != 'active' or not lot.auctionPeriod or not lot.auctionPeriod.startDate or lot.auctionPeriod.endDate:
                    continue
                if now < lot.auctionPeriod.startDate:
                    checks.append(lot.auctionPeriod.startDate.astimezone(TZ))
                elif now < calc_auction_end_time(
                        lot.numberOfBids,
                        lot.auctionPeriod.startDate).astimezone(TZ):
                    checks.append(
                        calc_auction_end_time(
                            lot.numberOfBids,
                            lot.auctionPeriod.startDate).astimezone(TZ))
        elif not self.lots and self.status == 'active.awarded' and not any(
            [i.status in self.block_complaint_status
             for i in self.complaints]) and not any([
                 i.status in self.block_complaint_status for a in self.awards
                 for i in a.complaints
             ]):
            standStillEnds = [
                a.complaintPeriod.endDate.astimezone(TZ) for a in self.awards
                if a.complaintPeriod.endDate
            ]

            last_award_status = self.awards[-1].status if self.awards else ''
            if standStillEnds and last_award_status == 'unsuccessful':
                checks.append(max(standStillEnds))
        elif self.lots and self.status in [
                'active.qualification', 'active.awarded'
        ] and not any([
                i.status in self.block_complaint_status
                and i.relatedLot is None for i in self.complaints
        ]):
            for lot in self.lots:
                if lot['status'] != 'active':
                    continue
                lot_awards = [i for i in self.awards if i.lotID == lot.id]
                pending_complaints = any([
                    i['status'] in self.block_complaint_status
                    and i.relatedLot == lot.id for i in self.complaints
                ])
                pending_awards_complaints = any([
                    i.status in self.block_complaint_status for a in lot_awards
                    for i in a.complaints
                ])
                standStillEnds = [
                    a.complaintPeriod.endDate.astimezone(TZ)
                    for a in lot_awards if a.complaintPeriod.endDate
                ]
                last_award_status = lot_awards[-1].status if lot_awards else ''
                if not pending_complaints and not pending_awards_complaints and standStillEnds and last_award_status == 'unsuccessful':
                    checks.append(max(standStillEnds))
        if self.status.startswith('active'):
            from openprocurement.api.utils import calculate_business_date
            for complaint in self.complaints:
                if complaint.status == 'claim' and complaint.dateSubmitted:
                    checks.append(
                        calculate_business_date(complaint.dateSubmitted,
                                                COMPLAINT_STAND_STILL_TIME,
                                                self))
                elif complaint.status == 'answered' and complaint.dateAnswered:
                    checks.append(
                        calculate_business_date(complaint.dateAnswered,
                                                COMPLAINT_STAND_STILL_TIME,
                                                self))
            for award in self.awards:
                for complaint in award.complaints:
                    if complaint.status == 'claim' and complaint.dateSubmitted:
                        checks.append(
                            calculate_business_date(
                                complaint.dateSubmitted,
                                COMPLAINT_STAND_STILL_TIME, self))
                    elif complaint.status == 'answered' and complaint.dateAnswered:
                        checks.append(
                            calculate_business_date(
                                complaint.dateAnswered,
                                COMPLAINT_STAND_STILL_TIME, self))
        return min(checks).isoformat() if checks else None
Esempio n. 19
0
class Guarantee(Model):
    amount = FloatType(required=True, min_value=0)  # Amount as a number.
    currency = StringType(
        required=True, default=u'UAH', max_length=3,
        min_length=3)  # The currency in 3-letter ISO 4217 format.
Esempio n. 20
0
class CAVClassification(Classification):
    scheme = StringType(required=True, default=u'CAV', choices=[u'CAV'])
    id = StringType(required=True, choices=CAV_CODES)
Esempio n. 21
0
class Revision(Model):
    author = StringType()
    date = IsoDateTimeType(default=get_now)
    changes = ListType(DictType(BaseType), default=list())
    rev = StringType()
Esempio n. 22
0
class Auction(DGFOtherAssets):
    """Data regarding auction process - publicly inviting prospective contractors to submit bids for evaluation and selecting a winner or winners."""
    documents = ListType(ModelType(Document), default=list(
    ))  # All documents and attachments related to the auction.
    bids = ListType(ModelType(Bid), default=list())
    procurementMethodType = StringType(default="dgfFinancialAssets")
Esempio n. 23
0
 class User(Model):
     name = StringType()
Esempio n. 24
0
class Identifier(BaseIdentifier):
    scheme = StringType(required=True, choices=ORA_CODES)
Esempio n. 25
0
 class User(Model):
     name = StringType(required=True)
     bio = StringType(required=True)
Esempio n. 26
0
class PCISolution(OSDFModel):
    cellId = StringType(required=True)
    pci = IntType(required=True)
Esempio n. 27
0
 class Child(Parent):
     bio = StringType()
Esempio n. 28
0
class ANRSolution(OSDFModel):
    cellId = StringType(required=True)
    removeableNeighbors = ListType(StringType())
Esempio n. 29
0
 class User(Model):
     name = StringType(required=True)
     age = IntType(required=True)
     account_level = IntType()
Esempio n. 30
0
def test_string_max_length_is_enforced():
    with pytest.raises(ValidationError):
        StringType(max_length=2).validate_length('foo')