Exemplo n.º 1
0
class InternalTip_v_20(ModelWithID):
    __storm_table__ = 'internaltip'
    creation_date = DateTime()
    context_id = Unicode()
    wb_steps = JSON()
    expiration_date = DateTime()
    last_activity = DateTime()
    new = Int()
Exemplo n.º 2
0
class ArchivedSchema(Model):
    __storm_primary__ = 'hash', 'type'

    hash = Unicode()
    type = Unicode()
    schema = JSON()

    unicode_keys = ['hash']
Exemplo n.º 3
0
class Context(Model):
    """
    This model keeps track of contexts settings.
    """
    show_small_cards = Bool(default=False)
    show_context = Bool(default=True)
    show_receivers = Bool(default=True)
    maximum_selectable_receivers = Int(default=0)
    select_all_receivers = Bool(default=False)

    enable_comments = Bool(default=True)
    enable_messages = Bool(default=False)
    enable_two_way_comments = Bool(default=True)
    enable_two_way_messages = Bool(default=True)
    enable_attachments = Bool(default=True)
    enable_whistleblower_identity = Bool(default=False)

    tip_timetolive = Int()

    # localized strings
    name = JSON(validator=shortlocal_v)
    description = JSON(validator=longlocal_v)
    recipients_clarification = JSON(validator=longlocal_v)

    questionnaire_layout = Unicode(default=u'horizontal')

    show_receivers_in_alphabetical_order = Bool(default=False)

    presentation_order = Int(default=0)

    unicode_keys = ['questionnaire_layout']

    localized_keys = ['name', 'description', 'recipients_clarification']

    int_keys = [
        'tip_timetolive', 'maximum_selectable_receivers',
        'show_receivers_in_alphabetical_order', 'presentation_order'
    ]

    bool_keys = [
        'select_all_receivers', 'show_small_cards', 'show_context',
        'show_receivers', 'enable_comments', 'enable_messages',
        'enable_two_way_comments', 'enable_two_way_messages',
        'enable_attachments'
    ]
Exemplo n.º 4
0
class CodeReviewInlineCommentDraft(StormBase):
    __storm_table__ = 'CodeReviewInlineCommentDraft'
    __storm_primary__ = ('previewdiff_id', 'person_id')

    previewdiff_id = Int(name='previewdiff')
    previewdiff = Reference(previewdiff_id, 'PreviewDiff.id')
    person_id = Int(name='person')
    person = Reference(person_id, 'Person.id')
    comments = JSON()
Exemplo n.º 5
0
class FieldOption(Model):
    field_id = Unicode()
    presentation_order = Int(default=0)
    label = JSON()
    score_points = Int(default=0)

    unicode_keys = ['field_id']
    int_keys = ['presentation_order', 'score_points']
    localized_strings = ['label']
Exemplo n.º 6
0
class Comment_v_22(Model):
    __storm_table__ = 'comment'
    creation_date = DateTime()
    internaltip_id = Unicode()
    author = Unicode()
    content = Unicode()
    system_content = JSON()
    type = Unicode()
    new = Int(default=True)
Exemplo n.º 7
0
class CustomTexts(Model):
    """
    Class used to implement custom texts
    """
    lang = Unicode(primary=True, validator=shorttext_v)
    texts = JSON()

    unicode_keys = ['lang']
    json_keys = ['texts']
Exemplo n.º 8
0
class Comment_v_19(Model):
    __storm_table__ = 'comment'
    creation_date = DateTime()
    internaltip_id = Unicode()
    author = Unicode()
    content = Unicode()
    system_content = JSON()
    type = Unicode()
    mark = Unicode()
Exemplo n.º 9
0
class InternalTip_v_19(Model):
    __storm_table__ = 'internaltip'
    creation_date = DateTime()
    context_id = Unicode()
    wb_steps = JSON()
    expiration_date = DateTime()
    last_activity = DateTime()
    access_limit = Int()
    download_limit = Int()
    mark = Unicode()
Exemplo n.º 10
0
class CodeReviewInlineComment(StormBase):
    __storm_table__ = 'CodeReviewInlineComment'

    previewdiff_id = Int(name='previewdiff')
    previewdiff = Reference(previewdiff_id, 'PreviewDiff.id')
    person_id = Int(name='person')
    person = Reference(person_id, 'Person.id')
    comment_id = Int(name='comment', primary=True)
    comment = Reference(comment_id, 'CodeReviewComment.id')
    comments = JSON()
Exemplo n.º 11
0
class Field_v_27(ModelWithID):
    __storm_table__ = 'field'
    x = Int()
    y = Int()
    width = Int()
    key = Unicode()
    label = JSON()
    description = JSON()
    hint = JSON()
    required = Bool()
    preview = Bool()
    multi_entry = Bool()
    multi_entry_hint = JSON()
    stats_enabled = Bool()
    activated_by_score = Int()
    template_id = Unicode()
    type = Unicode()
    instance = Unicode()
    editable = Bool()
Exemplo n.º 12
0
class Field(Model):
    x = Int(default=0)
    y = Int(default=0)
    width = Int(default=0)

    key = Unicode(default=u"")

    label = JSON(validator=longlocal_v)
    description = JSON(validator=longlocal_v)
    hint = JSON(validator=longlocal_v)

    required = Bool(default=False)
    preview = Bool(default=False)

    multi_entry = Bool(default=False)
    multi_entry_hint = JSON(validator=shortlocal_v)

    # This is set if the field should be duplicated for collecting statistics
    # when encryption is enabled.
    stats_enabled = Bool(default=False)

    activated_by_score = Int(default=0)

    # This reference when != NULL means
    # that the field is referencing a template
    template_id = Unicode()

    type = Unicode(default=u'inputbox')

    instance = Unicode(default=u'instance')
    editable = Bool(default=True)

    unicode_keys = ['type', 'instance', 'key']
    int_keys = ['x', 'y', 'width', 'activated_by_score']
    localized_keys = ['label', 'description', 'hint', 'multi_entry_hint']
    bool_keys = [
        'editable', 'multi_entry', 'preview', 'required', 'stats_enabled'
    ]

    def delete(self, store):
        for child in self.children:
            child.delete(store)
        store.remove(self)
Exemplo n.º 13
0
class Context(Model):
    """
    This model keeps track of specific contexts settings.
    """
    show_small_cards = Bool(default=False)
    show_receivers = Bool(default=True)
    maximum_selectable_receivers = Int(default=0)
    select_all_receivers = Bool(default=False)
    enable_comments = Bool(default=True)
    enable_private_messages = Bool(default=False)

    tip_timetolive = Int()

    # localized strings
    name = JSON(validator=shortlocal_v)
    description = JSON(validator=longlocal_v)

    # receivers = ReferenceSet(
    #                         Context.id,
    #                         ReceiverContext.context_id,
    #                         ReceiverContext.receiver_id,
    #                         Receiver.id)

    steps_arrangement = Unicode(default=u'horizontal')

    show_receivers_in_alphabetical_order = Bool(default=False)

    presentation_order = Int(default=0)

    unicode_keys = ['steps_arrangement']

    localized_strings = ['name', 'description']

    int_keys = [
        'maximum_selectable_receivers', 'show_receivers_in_alphabetical_order',
        'presentation_order'
    ]

    bool_keys = [
        'select_all_receivers', 'show_small_cards', 'show_receivers',
        'enable_comments', 'enable_private_messages'
    ]
Exemplo n.º 14
0
class Context(Model):
    """
    This model keeps track of specific contexts settings.
    """
    show_small_cards = Bool()
    show_receivers = Bool()
    maximum_selectable_receivers = Int()
    select_all_receivers = Bool()
    enable_private_messages = Bool()

    tip_max_access = Int()
    file_max_download = Int()
    tip_timetolive = Int()
    submission_timetolive = Int()
    last_update = DateTime()

    # localized strings
    name = JSON(validator=shortlocal_v)
    description = JSON(validator=longlocal_v)
    receiver_introduction = JSON(validator=longlocal_v)

    # receivers = ReferenceSet(
    #                         Context.id,
    #                         ReceiverContext.context_id,
    #                         ReceiverContext.receiver_id,
    #                         Receiver.id)

    postpone_superpower = Bool()
    can_delete_submission = Bool()

    presentation_order = Int()

    unicode_keys = []
    localized_strings = ['name', 'description', 'receiver_introduction']
    int_keys = [
        'tip_max_access', 'file_max_download', 'maximum_selectable_receivers',
        'presentation_order'
    ]
    bool_keys = [
        'select_all_receivers', 'postpone_superpower', 'can_delete_submission',
        'show_small_cards', 'show_receivers', "enable_private_messages"
    ]
Exemplo n.º 15
0
class FieldOption(ModelWithID):
    field_id = Unicode()
    presentation_order = Int(default=0)
    label = JSON()
    score_points = Int(default=0)
    trigger_field = Unicode()
    trigger_step = Unicode()

    unicode_keys = ['field_id']
    int_keys = ['presentation_order', 'score_points']
    localized_keys = ['label']
Exemplo n.º 16
0
class Context_v_26(ModelWithID):
    __storm_table__ = 'context'
    show_small_cards = Bool()
    show_context = Bool()
    show_receivers = Bool()
    maximum_selectable_receivers = Int()
    select_all_receivers = Bool()
    enable_comments = Bool()
    enable_messages = Bool()
    enable_two_way_comments = Bool()
    enable_two_way_messages = Bool()
    enable_attachments = Bool()
    enable_whistleblower_identity = Bool()
    tip_timetolive = Int()
    name = JSON()
    description = JSON()
    recipients_clarification = JSON()
    questionnaire_layout = Unicode()
    show_receivers_in_alphabetical_order = Bool()
    presentation_order = Int()
Exemplo n.º 17
0
class InternalTip_v_23(Model):
    __storm_table__ = 'internaltip'
    creation_date = DateTime()
    context_id = Unicode()
    questionnaire_hash = Unicode()
    preview = JSON()
    progressive = Int()
    tor2web = Bool()
    expiration_date = DateTime()
    last_activity = DateTime()
    new = Int()
Exemplo n.º 18
0
class Context_v_30(ModelWithID):
    __storm_table__ = 'context'
    show_small_cards = Bool()
    show_context = Bool()
    show_recipients_details = Bool()
    allow_recipients_selection = Bool()
    maximum_selectable_receivers = Int()
    select_all_receivers = Bool()
    enable_comments = Bool()
    enable_messages = Bool()
    enable_two_way_comments = Bool()
    enable_two_way_messages = Bool()
    enable_attachments = Bool()
    tip_timetolive = Int()
    name = JSON()
    description = JSON()
    recipients_clarification = JSON()
    status_page_message = JSON()
    show_receivers_in_alphabetical_order = Bool()
    presentation_order = Int()
    questionnaire_id = Unicode(default=u'default')
Exemplo n.º 19
0
class Receiver(Model):
    """
    name, description, password and notification_fields, can be changed
    by Receiver itself
    """
    name = Unicode(validator=shorttext_v)

    # localization strings
    description = JSON(validator=longlocal_v)

    configuration = Unicode()
    # configurations: 'default', 'forcefully_selected', 'unselectable'

    # of PGP key fields
    pgp_key_info = Unicode()
    pgp_key_fingerprint = Unicode()
    pgp_key_public = Unicode()
    pgp_key_expiration = DateTime()

    pgp_key_status = Unicode()
    # pgp_statuses: 'disabled', 'enabled'

    # Can be changed by the user itself
    ping_mail_address = Unicode()

    # Admin chosen options
    can_delete_submission = Bool(default=False)
    can_postpone_expiration = Bool(default=False)

    tip_notification = Bool(default=True)
    ping_notification = Bool(default=False)

    tip_expiration_threshold = Int(default=72)

    # contexts = ReferenceSet("Context.id",
    #                         "ReceiverContext.context_id",
    #                         "ReceiverContext.receiver_id",
    #                         "Receiver.id")

    presentation_order = Int(default=0)

    unicode_keys = ['name', 'configuration', 'ping_mail_address']

    localized_strings = ['description']

    int_keys = ['presentation_order', 'tip_expiration_threshold']

    bool_keys = [
        'can_delete_submission',
        'can_postpone_expiration',
        'tip_notification',
        'ping_notification'
    ]
Exemplo n.º 20
0
class Field_v_37(models.ModelWithID):
    __storm_table__ = 'field'
    x = Int(default=0)
    y = Int(default=0)
    width = Int(default=0)
    key = Unicode(default=u'')
    label = JSON(validator=longlocal_v)
    description = JSON(validator=longlocal_v)
    hint = JSON(validator=longlocal_v)
    required = Bool(default=False)
    preview = Bool(default=False)
    multi_entry = Bool(default=False)
    multi_entry_hint = JSON(validator=shortlocal_v)
    stats_enabled = Bool(default=False)
    triggered_by_score = Int(default=0)
    fieldgroup_id = Unicode()
    step_id = Unicode()
    template_id = Unicode()
    type = Unicode(default=u'inputbox')
    instance = Unicode(default=u'instance')
    editable = Bool(default=True)
Exemplo n.º 21
0
class Context_v_34(models.ModelWithID):
    __storm_table__ = 'context'
    show_small_receiver_cards = Bool(default=False)
    show_context = Bool(default=True)
    show_recipients_details = Bool(default=False)
    allow_recipients_selection = Bool(default=False)
    maximum_selectable_receivers = Int(default=0)
    select_all_receivers = Bool(default=True)
    enable_comments = Bool(default=True)
    enable_messages = Bool(default=False)
    enable_two_way_comments = Bool(default=True)
    enable_two_way_messages = Bool(default=True)
    enable_attachments = Bool(default=True)
    tip_timetolive = Int(default=15)
    name = JSON(validator=shortlocal_v)
    description = JSON(validator=longlocal_v)
    recipients_clarification = JSON()
    status_page_message = JSON()
    show_receivers_in_alphabetical_order = Bool(default=False)
    presentation_order = Int(default=0)
    questionnaire_id = Unicode()
    img_id = Unicode()
Exemplo n.º 22
0
class Field(ModelWithID):
    x = Int(default=0)
    y = Int(default=0)
    width = Int(default=0)

    key = Unicode(default=u'')

    label = JSON(validator=longlocal_v)
    description = JSON(validator=longlocal_v)
    hint = JSON(validator=longlocal_v)

    required = Bool(default=False)
    preview = Bool(default=False)

    multi_entry = Bool(default=False)
    multi_entry_hint = JSON(validator=shortlocal_v)

    # This is set if the field should be duplicated for collecting statistics
    # when encryption is enabled.
    stats_enabled = Bool(default=False)

    triggered_by_score = Int(default=0)

    fieldgroup_id = Unicode()
    step_id = Unicode()
    template_id = Unicode()

    type = Unicode(default=u'inputbox')

    instance = Unicode(default=u'instance')
    editable = Bool(default=True)

    unicode_keys = ['type', 'instance', 'key']
    int_keys = ['x', 'y', 'width', 'triggered_by_score']
    localized_keys = ['label', 'description', 'hint', 'multi_entry_hint']
    bool_keys = [
        'editable', 'multi_entry', 'preview', 'required', 'stats_enabled'
    ]
Exemplo n.º 23
0
class Config(Storm):
    __storm_table__ = 'config'
    __storm_primary__ = ('var_group', 'var_name')

    var_group = Unicode()
    var_name = Unicode()
    value = JSON()
    customized = Bool(default=False)

    def __init__(self, group=None, name=None, value=None, migrate=False):
        if migrate:
            return
        self.var_group = unicode(group)
        self.var_name = unicode(name)

        self.set_v(value)
        # If the value initializing the config item does not equal the default
        # record the fact that it was customized.
        if value != self.desc.default:
            self.customized = True

    @classmethod
    def find_descriptor(cls, var_group, var_name):
        d = GLConfig.get(var_group, {}).get(var_name, None)
        if d is None:
            raise ValueError('%s.%s descriptor cannot be None' % (var_group, var_name))
        return d

    def set_v(self, val):
        self.desc = Config.find_descriptor(self.var_group, self.var_name)
        if val is None:
            val = self.desc._type()
        if isinstance(self.desc, config_desc.Unicode) and isinstance(val, str):
            val = unicode(val)
        if not isinstance(val, self.desc._type):
            raise ValueError("Cannot assign %s with %s" % (self, type(val)))
        if self.desc.validator is not None:
            self.desc.validator(self, self.var_name, val)

        if self.value is not None and self.value['v'] != val:
            self.customized = True

        self.value = {'v': val}

    def get_v(self):
        return self.value['v']

    def __repr__(self):
        return "<Config: %s.%s>" % (self.var_group, self.var_name)
Exemplo n.º 24
0
class User(ModelWithID):
    """
    This model keeps track of globaleaks users.
    """
    creation_date = DateTime(default_factory=datetime_now)

    username = Unicode(validator=shorttext_v, default=u'')

    password = Unicode(default=u'')
    salt = Unicode()

    deletable = Bool(default=True)

    name = Unicode(validator=shorttext_v, default=u'')
    description = JSON(validator=longlocal_v, default={})

    public_name = Unicode(validator=shorttext_v, default=u'')

    # roles: 'admin', 'receiver', 'custodian'
    role = Unicode(default=u'receiver')
    state = Unicode(default=u'enabled')
    last_login = DateTime(default_factory=datetime_null)
    mail_address = Unicode(default=u'')
    language = Unicode()
    password_change_needed = Bool(default=True)
    password_change_date = DateTime(default_factory=datetime_null)

    # BEGIN of PGP key fields
    pgp_key_fingerprint = Unicode(default=u'')
    pgp_key_public = Unicode(default=u'')
    pgp_key_expiration = DateTime(default_factory=datetime_null)
    # END of PGP key fields

    img_id = Unicode()

    unicode_keys = [
        'username', 'role', 'state', 'language', 'mail_address', 'name',
        'public_name', 'language'
    ]

    localized_keys = ['description']

    bool_keys = ['deletable', 'password_change_needed']

    date_keys = [
        'creation_date', 'last_login', 'password_change_date',
        'pgp_key_expiration'
    ]
Exemplo n.º 25
0
class Comment(Model):
    """
    This table handle the comment collection, has an InternalTip referenced
    """
    internaltip_id = Unicode()

    author = Unicode()
    content = Unicode(validator=longtext_v)

    # In case of system_content usage, content has repr() equiv
    system_content = JSON()

    type = Unicode()
    # types = [u'receiver', u'whistleblower', u'system']

    mark = Unicode()
Exemplo n.º 26
0
class User(Model):
    """
    This model keeps track of globaleaks users.
    """
    creation_date = DateTime(default_factory=datetime_now)

    username = Unicode(validator=shorttext_v)

    password = Unicode()
    salt = Unicode()

    deletable = Bool(default=True)

    name = Unicode(validator=shorttext_v)
    description = JSON(validator=longlocal_v)

    role = Unicode()
    state = Unicode()
    last_login = DateTime(default_factory=datetime_null)
    mail_address = Unicode()
    language = Unicode()
    timezone = Int()
    password_change_needed = Bool(default=True)
    password_change_date = DateTime(default_factory=datetime_null)

    # roles: 'admin', 'receiver', 'custodian'
    # states: 'disabled', 'enabled'

    # BEGIN of PGP key fields
    pgp_key_info = Unicode(default=u'')
    pgp_key_fingerprint = Unicode(default=u'')
    pgp_key_public = Unicode(default=u'')
    pgp_key_expiration = DateTime(default_factory=datetime_null)
    pgp_key_status = Unicode(default=u'disabled')  # 'disabled', 'enabled'
    # END of PGP key fields

    unicode_keys = [
        'username', 'password', 'salt', 'role', 'state', 'language',
        'mail_address', 'name'
    ]

    localized_keys = ['description']

    int_keys = ['timezone', 'password_change_needed']

    bool_keys = ['deletable']
Exemplo n.º 27
0
class Receiver_v_23(Model):
    __storm_table__ = 'receiver'
    name = Unicode()
    description = JSON()
    configuration = Unicode()
    pgp_key_info = Unicode()
    pgp_key_fingerprint = Unicode()
    pgp_key_public = Unicode()
    pgp_key_expiration = DateTime()
    pgp_key_status = Unicode()
    ping_mail_address = Unicode()
    can_delete_submission = Bool()
    can_postpone_expiration = Bool()
    tip_notification = Bool()
    ping_notification = Bool()
    tip_expiration_threshold = Int()
    presentation_order = Int()
Exemplo n.º 28
0
class InternalTip_v_34(models.ModelWithID):
    __storm_table__ = 'internaltip'
    creation_date = DateTime(default_factory=datetime_now)
    update_date = DateTime(default_factory=datetime_now)
    context_id = Unicode()
    questionnaire_hash = Unicode()
    preview = JSON()
    progressive = Int(default=0)
    tor2web = Bool(default=False)
    total_score = Int(default=0)
    expiration_date = DateTime()
    identity_provided = Bool(default=False)
    identity_provided_date = DateTime(default_factory=datetime_null)
    enable_two_way_comments = Bool(default=True)
    enable_two_way_messages = Bool(default=True)
    enable_attachments = Bool(default=True)
    enable_whistleblower_identity = Bool(default=False)
    wb_last_access = DateTime(default_factory=datetime_now)
Exemplo n.º 29
0
class Receiver_v_15(Model):
    __storm_table__ = 'receiver'
    user_id = Unicode()
    name = Unicode()
    description = JSON()
    configuration = Unicode()
    gpg_key_info = Unicode()
    gpg_key_fingerprint = Unicode()
    gpg_key_status = Unicode()
    gpg_key_armor = Unicode()
    gpg_enable_notification = Bool()
    mail_address = Unicode()
    can_delete_submission = Bool()
    postpone_superpower = Bool()
    last_update = DateTime()
    tip_notification = Bool()
    comment_notification = Bool()
    file_notification = Bool()
    message_notification = Bool()
    presentation_order = Int()
Exemplo n.º 30
0
class SnapBase(Storm):
    """See `ISnapBase`."""

    __storm_table__ = "SnapBase"

    id = Int(primary=True)

    date_created = DateTime(
        name="date_created", tzinfo=pytz.UTC, allow_none=False)

    registrant_id = Int(name="registrant", allow_none=False)
    registrant = Reference(registrant_id, "Person.id")

    name = Unicode(name="name", allow_none=False)

    display_name = Unicode(name="display_name", allow_none=False)

    distro_series_id = Int(name="distro_series", allow_none=False)
    distro_series = Reference(distro_series_id, "DistroSeries.id")

    build_channels = JSON(name="build_channels", allow_none=False)

    is_default = Bool(name="is_default", allow_none=False)

    def __init__(self, registrant, name, display_name, distro_series,
                 build_channels, date_created=DEFAULT):
        super(SnapBase, self).__init__()
        self.registrant = registrant
        self.name = name
        self.display_name = display_name
        self.distro_series = distro_series
        self.build_channels = build_channels
        self.date_created = date_created
        self.is_default = False

    def destroySelf(self):
        """See `ISnapBase`."""
        # Guard against unfortunate accidents.
        if self.is_default:
            raise CannotDeleteSnapBase("Cannot delete the default base.")
        Store.of(self).remove(self)