Exemplo n.º 1
0
 def personal_website(self, personal_website):
     if not personal_website:
         self._personal_website = ''
         return
     min_length = CONSTANTS.min_url_length
     max_length = CONSTANTS.max_url_length
     if not validString(personal_website, min_length, max_length):
         raise ValidationError('Invalid personal website.')
     self._personal_website = personal_website
Exemplo n.º 2
0
    def dblp_profile(self, dblp_profile):
        if not dblp_profile:
            self._dblp_profile = ''
            return

        min_length = CONSTANTS.min_url_length
        max_length = CONSTANTS.max_url_length
        if not validString(dblp_profile, min_length, max_length):
            raise ValidationError('Invalid DBLP profile.')

        allowed_prefixes = ('https://dblp.org/', 'https://dblp.uni-trier.de/',
                            'dblp.uni-trier.de/', 'dblp.org/')
        if not dblp_profile.startswith(allowed_prefixes):
            raise ValidationError('DBLP url prefix does not match DBLP links.')

        dblp_profile = dblp_profile.replace('dblp.uni-trier.de', 'dblp.org')
        self._dblp_profile = dblp_profile
Exemplo n.º 3
0
    def google_scholar_profile(self, google_scholar_profile):
        if not google_scholar_profile:
            self._google_scholar_profile = ''
            return

        min_length = CONSTANTS.min_url_length
        max_length = CONSTANTS.max_url_length
        if not validString(google_scholar_profile, min_length, max_length):
            raise ValidationError('Invalid Google Scholar profile.')

        allowed_prefixes = ('scholar.google.com/',
                            'https://scholar.google.com/')
        if not google_scholar_profile.startswith(allowed_prefixes):
            raise ValidationError(
                'Google Scholar url prefix does not match Google Scholar links.'
            )
        self._google_scholar_profile = google_scholar_profile
Exemplo n.º 4
0
    def topics(self, topics):
        min_topics = CONSTANTS.min_topics_per_user
        max_length = CONSTANTS.max_topic_length

        if isinstance(topics, str):
            topics = [topic.strip() for topic in topics.lower().splitlines()]
        else:
            raise ValidationError('Topics must be a newline separated string.')
        if len(topics) < min_topics:
            raise ValidationError('You need to provide at least {} '
                                  'topics.'.format(min_topics))

        for topic in topics:
            if not validString(topic, 1, max_length):
                raise ValidationError(
                    'Topics must be shorter than {}.'.format(max_length))
            if not re.match('^[0-9a-zA-Z\- ]+$', topic):
                raise ValidationError(
                    'Topics must not contain special characters.')

        self._topics = topics
Exemplo n.º 5
0
    def semantic_scholar_profile(self, semantic_scholar_profile):
        if not semantic_scholar_profile:
            self._semantic_scholar_profile = ''
            return

        min_length = CONSTANTS.min_url_length
        max_length = CONSTANTS.max_url_length
        if not validString(semantic_scholar_profile, min_length, max_length):
            raise ValidationError('Invalid Semantic Scholar profile.')

        allowed_prefixes = ('semanticscholar.org/author/',
                            'https://www.semanticscholar.org/author/',
                            'www.semanticscholar.org/author/',
                            'https://semanticscholar.org/author/')
        if not semantic_scholar_profile.startswith(allowed_prefixes):
            raise ValidationError(
                'Semantic Scholar url prefix does not match Semantic Scholar links.'
            )

        semantic_scholar_profile = semantic_scholar_profile.replace('www.', '')
        self._semantic_scholar_profile = semantic_scholar_profile
Exemplo n.º 6
0
 def organization(self, organization):
     """Checks if organization name seems valid"""
     if not validString(organization, 1, CONSTANTS.max_organization_length):
         raise ValidationError('Invalid organization name format.')
     self._organization = organization
Exemplo n.º 7
0
 def lastname(self, lastname):
     """Checks if lastname seems valid"""
     if not validString(lastname, 1, CONSTANTS.max_human_name_length):
         raise ValidationError('Invalid  lastname fromat.')
     self._lastname = lastname
Exemplo n.º 8
0
 def firstname(self, firstname):
     """Checks if firstname seems valid"""
     if not validString(firstname, 1, CONSTANTS.max_human_name_length):
         raise ValidationError('Invalid firstname format.')
     self._firstname = firstname
Exemplo n.º 9
0
 def organization(self, organization):
     '''Checks if organization seems valid'''
     if not validString(organization, 1, 255):
         raise ValidationError('Invalid organization name')
     self._organization = organization
Exemplo n.º 10
0
 def name(self, name):
     '''Checks if name seems valid'''
     if not validString(name, 1, 255):
         raise ValidationError('Invalid system name.')
     self._name = name
Exemplo n.º 11
0
 def contact(self, contact):
     '''Checks if contact seems valid'''
     if not validString(contact, 1, 255):
         raise ValidationError('Invalid contact name.')
     self._contact = contact