Example #1
0
    def __init__(self, page, article_id, type=None, mobile_access=False):
        super(ArticleEditor, self).__init__(None)
        self.mobile_access = mobile_access
        article = ArticleRepository().get_by_id(article_id)

        self.page = page
        self.creation = article is None

        self.DEFAULT_TOPIC = ArticleTopicData.get_by(default=True).label
        # gets the initial values
        type = article.type if article else (type or self.DEFAULT_TYPE)
        topic = article.topic.label if article else self.DEFAULT_TOPIC
        title = article.title if article else u''
        content = article.content if article else u''
        mobile_content = article.mobile_content if article else u''
        tags = u', '.join(article.tags) if article else u''

        # creates the properties
        self.type = editor.Property(type)
        self.topic = editor.Property(topic)
        self.title = editor.Property(title).validate(validators.non_empty_string)
        self.thumbnail = editor.Property().validate(self._validate_thumbnail)
        self.thumbnail_filename = None
        self.content = editor.Property(content).validate(validators.string)
        self.mobile_content = editor.Property(mobile_content).validate(validators.string)
        self.tags = editor.Property(tags).validate(lambda t: validators.word_list(t, duplicates='remove'))
Example #2
0
    def __init__(self, page, article_id, type=None, mobile_access=False):
        super(ArticleEditor, self).__init__(None)
        self.mobile_access = mobile_access
        article = ArticleRepository().get_by_id(article_id)

        self.page = page
        self.creation = article is None

        self.DEFAULT_TOPIC = ArticleTopicData.get_by(default=True).label
        # gets the initial values
        type = article.type if article else (type or self.DEFAULT_TYPE)
        topic = article.topic.label if article else self.DEFAULT_TOPIC
        title = article.title if article else u''
        content = article.content if article else u''
        mobile_content = article.mobile_content if article else u''
        tags = u', '.join(article.tags) if article else u''

        # creates the properties
        self.type = editor.Property(type)
        self.topic = editor.Property(topic)
        self.title = editor.Property(title).validate(
            validators.non_empty_string)
        self.thumbnail = editor.Property().validate(self._validate_thumbnail)
        self.thumbnail_filename = None
        self.content = editor.Property(content).validate(validators.string)
        self.mobile_content = editor.Property(mobile_content).validate(
            validators.string)
        self.tags = editor.Property(tags).validate(
            lambda t: validators.word_list(t, duplicates='remove'))
Example #3
0
    def __init__(self, challenge=None, mobile_access=False):
        self.id = challenge if (is_integer(challenge)
                                or challenge is None) else challenge.id
        self.challenge_repository = ChallengeRepository()
        self.mobile_access = mobile_access
        challenge = self.challenge

        # properties
        self.title = editor.Property(u'').validate(validators.non_empty_string)
        self.short_title = editor.Property(u'').validate(
            validators.non_empty_string)
        self.created_by = editor.Property(u'').validate(
            lambda t: validators.user_email(t, True))
        self.organization = editor.Property(u'').validate(
            validators.non_empty_string)
        self.associated_dis = editor.Property(u'').validate(
            validators.user_email_list)
        self.starting_date = editor.Property(u'').validate(
            validators.non_empty_date)
        self.ending_date = editor.Property(u'').validate(
            validators.non_empty_date)
        self.summary = editor.Property(u'').validate(
            validators.non_empty_string)
        self.description = editor.Property(u'').validate(
            validators.non_empty_string)
        self.mobile_description = editor.Property(u'')
        self.outcome = editor.Property(u'').validate(validators.string)
        self.tags = editor.Property(u'').validate(
            lambda t: validators.word_list(t, duplicates='remove'))

        if challenge:
            self.title.set(challenge.title)
            self.short_title.set(challenge.short_title)
            self.created_by.set(challenge.created_by.email)
            self.organization.set(challenge.organization)
            associated_dis_email = ','.join(
                user.email for user in challenge.associated_dis)
            self.associated_dis.set(associated_dis_email)
            self.starting_date.set(
                challenge.starting_date.date().strftime('%d/%m/%Y'))
            self.ending_date.set(
                challenge.ending_date.date().strftime('%d/%m/%Y'))
            self.summary.set(challenge.summary)
            self.description.set(challenge.description)
            self.mobile_description.set(challenge.mobile_description)
            self.outcome.set(challenge.outcome)
            self.tags.set(u', '.join(challenge.tags))

        # Because the mobile description is optional in each eureka instance
        # and the validator will be triggered if we do this before
        self.mobile_description.validate(validators.non_empty_string)
    def __init__(self, challenge=None, mobile_access=False):
        self.id = challenge if (is_integer(challenge)
                                or challenge is None) else challenge.id
        self.challenge_repository = ChallengeRepository()
        self.mobile_access = mobile_access
        challenge = self.challenge

        # properties
        self.title = editor.Property(u'').validate(validators.non_empty_string)
        self.short_title = editor.Property(u'').validate(
            validators.non_empty_string)
        self.created_by = editor.Property(u'').validate(
            lambda t: validators.user_email(t, True))
        self.organization = editor.Property(u'').validate(
            validators.non_empty_string)
        self.associated_dis = editor.Property(u'').validate(
            validators.user_email_list)
        self.starting_date = editor.Property(u'').validate(
            validators.non_empty_date)
        self.ending_date = editor.Property(u'').validate(
            validators.non_empty_date)
        self.summary = editor.Property(u'').validate(
            validators.non_empty_string)
        self.description = editor.Property(u'').validate(
            validators.non_empty_string)
        self.mobile_description = editor.Property(u'')
        self.outcome = editor.Property(u'').validate(validators.string)
        self.tags = editor.Property(u'').validate(
            lambda t: validators.word_list(t, duplicates='remove'))

        if challenge:
            self.title.set(challenge.title)
            self.short_title.set(challenge.short_title)
            self.created_by.set(challenge.created_by.email)
            self.organization.set(challenge.organization)
            associated_dis_email = ','.join(
                user.email for user in challenge.associated_dis)
            self.associated_dis.set(associated_dis_email)
            self.starting_date.set(
                challenge.starting_date.date().strftime('%d/%m/%Y'))
            self.ending_date.set(
                challenge.ending_date.date().strftime('%d/%m/%Y'))
            self.summary.set(challenge.summary)
            self.description.set(challenge.description)
            self.mobile_description.set(challenge.mobile_description)
            self.outcome.set(challenge.outcome)
            self.tags.set(u', '.join(challenge.tags))

        # Because the mobile description is optional in each eureka instance
        # and the validator will be triggered if we do this before
        self.mobile_description.validate(validators.non_empty_string)
Example #5
0
    def __init__(self, parent, suggested_challenge_id=None):
        super(IdeaEditor, self).__init__(None)
        event_management._register_listener(parent, self)

        self.idea = None

        # mandatory fields
        self.title = editor.Property(u'').validate(validators.non_empty_string)
        self.description = editor.Property(u'').validate(
            validators.non_empty_string)
        self.domain_id = editor.Property(u'').validate(
            validators.non_empty_string)
        self.challenge_id = editor.Property(
            suggested_challenge_id or u'').validate(
            validators.non_empty_string)
        self.impact = editor.Property(u'').validate(
            validators.non_empty_string)
        self.tags = editor.Property(u'').validate(
            lambda t: validators.word_list(t, required=True,
                                           duplicates='remove'))

        # Optional fields
        self.benefit_department = editor.Property(u'').validate(
            validators.string)
        self.origin = editor.Property(u'').validate(validators.string)
        self.implementation = editor.Property(u'').validate(validators.string)
        self.co_author_1 = editor.Property(u'').validate(validators.user_email)
        self.co_author_2 = editor.Property(u'').validate(validators.user_email)
        self.co_author_3 = editor.Property(u'').validate(validators.user_email)
        self.co_author_4 = editor.Property(u'').validate(validators.user_email)
        self.co_author_5 = editor.Property(u'').validate(validators.user_email)

        self.attachment_1 = editor.Property(None).validate(validate_attachment)
        self.attachment_2 = editor.Property(None).validate(validate_attachment)
        self.attachment_3 = editor.Property(None).validate(validate_attachment)

        # checkboxes
        self.anonymous = editor.Property(False)
        self.already_done = editor.Property(False)