示例#1
0
class FormDetails(jsonobject.JsonObject):
    xmlns = jsonobject.StringProperty()
    app = jsonobject.ObjectProperty(AppInfo)
    module = jsonobject.ObjectProperty(AppPart)
    form = jsonobject.ObjectProperty(AppPart)
    is_deleted = jsonobject.BooleanProperty()
    is_user_registration = jsonobject.BooleanProperty(default=False)
示例#2
0
class FieldSpec(jsonobject.StrictJsonObject):
    field = jsonobject.StringProperty()
    description = jsonobject.StringProperty()
    show_in_menu = jsonobject.BooleanProperty(default=False)
    discoverable = jsonobject.BooleanProperty(default=True)
    values_hints = jsonobject.ListProperty()
    deprecated = jsonobject.BooleanProperty(default=False)
示例#3
0
class CaseUploadJSON(jsonobject.StrictJsonObject):
    domain = jsonobject.StringProperty(required=True)
    # In user display format, e.g. Dec 08, 2016 19:19 EST
    created = jsonobject.StringProperty(required=True)
    upload_id = jsonobject.StringProperty(required=True)
    task_status = jsonobject.ObjectProperty(lambda: TaskStatus)
    user_name = jsonobject.StringProperty(required=True)
    case_type = jsonobject.StringProperty(required=True)
    comment = jsonobject.StringProperty()

    upload_file_name = jsonobject.StringProperty()
    upload_file_length = jsonobject.IntegerProperty()
    upload_file_download_allowed = jsonobject.BooleanProperty(required=True)
    upload_comment_edit_allowed = jsonobject.BooleanProperty(required=True)
示例#4
0
class ChangeMeta(jsonobject.JsonObject):
    """
    Metadata about a change. If available, this will be set on Change.metadata.

    This is only used in kafka-based pillows.
    """
    _allow_dynamic_properties = False

    document_id = DefaultProperty(required=True)

    # Only relevant for Couch documents
    document_rev = jsonobject.StringProperty()

    # 'couch' or 'sql'
    data_source_type = jsonobject.StringProperty(required=True)

    # couch database name or one of data sources listed in corehq.apps.change_feed.data_sources
    data_source_name = jsonobject.StringProperty(required=True)

    # doc_type property of doc or else the topic name
    document_type = DefaultProperty()

    document_subtype = jsonobject.StringProperty()
    domain = jsonobject.StringProperty()
    is_deletion = jsonobject.BooleanProperty()
    publish_timestamp = jsonobject.DateTimeProperty(default=datetime.utcnow)

    # track of retry attempts
    attempts = jsonobject.IntegerProperty(default=0)
示例#5
0
class ChangeMeta(jsonobject.JsonObject):
    """
    Metadata about a change. If available, this will be set on Change.metadata.

    This is only used in kafka-based pillows.
    """
    document_id = DefaultProperty(required=True)
    data_source_type = jsonobject.StringProperty(required=True)
    data_source_name = jsonobject.StringProperty(required=True)
    document_type = DefaultProperty()
    document_subtype = jsonobject.StringProperty()
    domain = jsonobject.StringProperty()
    is_deletion = jsonobject.BooleanProperty()
    _allow_dynamic_properties = False
示例#6
0
class ChangeMeta(jsonobject.JsonObject):
    """
    Metadata about a change. If available, this will be set on Change.metadata.

    This is only used in kafka-based pillows.
    """
    document_id = DefaultProperty(required=True)
    document_rev = jsonobject.StringProperty()  # Only relevant for Couch documents
    data_source_type = jsonobject.StringProperty(required=True)
    data_source_name = jsonobject.StringProperty(required=True)
    document_type = DefaultProperty()
    document_subtype = jsonobject.StringProperty()
    domain = jsonobject.StringProperty()
    is_deletion = jsonobject.BooleanProperty()
    publish_timestamp = jsonobject.DateTimeProperty(default=datetime.utcnow)
    _allow_dynamic_properties = False
示例#7
0
class StockReportHelper(jsonobject.JsonObject):
    """
    Intermediate class for dealing with stock XML
    """

    domain = jsonobject.StringProperty()
    form_id = jsonobject.StringProperty()
    timestamp = jsonobject.DateTimeProperty()
    tag = jsonobject.StringProperty()
    transactions = jsonobject.ListProperty(lambda: StockTransactionHelper)
    server_date = jsonobject.DateTimeProperty()
    deprecated = jsonobject.BooleanProperty()

    @property
    def report_type(self):
        # this is for callers to be able to use a less confusing name
        return self.tag

    @classmethod
    def make_from_form(cls, form, timestamp, tag, transactions):
        deprecated = form.is_deprecated
        return cls(
            domain=form.domain,
            form_id=form.form_id if not deprecated else form.orig_id,
            timestamp=timestamp,
            tag=tag,
            transactions=transactions,
            server_date=form.received_on,
            deprecated=deprecated,
        )

    def validate(self):
        """
        Validates this object as best we can and raises Exceptions if we find anything invalid .
        """
        if any(transaction_helper.product_id in ('', None)
               for transaction_helper in self.transactions):
            raise MissingProductId(
                _('Product IDs must be set for all ledger updates!'))