コード例 #1
0
 def description(self, description):
     if description is None:
         description = ''
     # Drop all unallowed html tags
     description_clean = bleach.clean(description, strip=True)
     # Strip spaces
     self._description = characterentities.decode(description_clean).strip()
コード例 #2
0
ファイル: moves.py プロジェクト: kumy/geokrety-api
    def validate_tracking_code(self, data):
        data = characterentities.decode(data).replace('\x00', '').strip()
        if not data:
            raise UnprocessableEntity(
                "Tracking Code cannot be blank",
                {'pointer': '/data/attributes/tracking-code'})

        if not all(c in ALLOWED_TRACKING_CODE_CHARACTERS for c in data):
            raise UnprocessableEntity(
                "Tracking Code format is invalid",
                {'pointer': '/data/attributes/tracking-code'})
        try:
            safe_query(self, Geokret, 'tracking_code', data, 'tracking_code')
        except ObjectNotFound:
            raise UnprocessableEntity(
                "Tracking Code is invalid",
                {'pointer': '/data/attributes/tracking-code'})
コード例 #3
0
 def description(self):
     return characterentities.decode(self._description)
コード例 #4
0
 def name(self, name):
     # Drop all html tags
     name_clean = bleach.clean(name, tags=[], strip=True)
     # Strip spaces
     self._name = characterentities.decode(name_clean).strip()
コード例 #5
0
 def validate_content_blank(self, data):
     data = characterentities.decode(data).replace('\x00', '').strip()
     if not data:
         raise UnprocessableEntity("News content cannot be blank",
                                   {'pointer': '/data/attributes/content'})
コード例 #6
0
ファイル: news.py プロジェクト: geokrety/geokrety-api-models
 def title(self, title):
     title_clean = bleach.clean(title, tags=[], strip=True)
     self._title = characterentities.decode(title_clean).strip()
コード例 #7
0
ファイル: badge.py プロジェクト: geokrety/geokrety-api-models
 def description(self, description):
     if description is None:
         return u''
     description_clean = bleach.clean(description, strip=True)
     self._description = characterentities.decode(description_clean).replace('\x00', '').strip()
コード例 #8
0
ファイル: badge.py プロジェクト: geokrety/geokrety-api-models
 def name(self, name):
     name_clean = bleach.clean(name, strip=True)
     self._name = characterentities.decode(name_clean).strip()
コード例 #9
0
 def application_name(self):
     if self._application_name is None:
         return None
     return characterentities.decode(self._application_name)
コード例 #10
0
 def application_version(self, application_version):
     if application_version is None:
         self._application_version = None
     else:
         application_version_clean = bleach.clean(application_version, tags=[], strip=True)
         self._application_version = characterentities.decode(application_version_clean).strip()
コード例 #11
0
 def application_version(self):
     if self._application_version is None:
         return None
     return characterentities.decode(self._application_version)
コード例 #12
0
 def comment(self, comment):
     comment_clean = bleach.clean(comment, strip=True)
     self._comment = characterentities.decode(comment_clean).strip()
コード例 #13
0
ファイル: news.py プロジェクト: geokrety/geokrety-api-models
 def username(self, username):
     username_clean = bleach.clean(username, tags=[], strip=True)
     self._username = characterentities.decode(username_clean).strip()
コード例 #14
0
ファイル: news.py プロジェクト: geokrety/geokrety-api-models
 def username(self):
     if self._username:
         return characterentities.decode(self._username)
コード例 #15
0
 def application_name(self, application_name):
     if application_name is None:
         self._application_name = None
     else:
         application_name_clean = bleach.clean(application_name, tags=[], strip=True)
         self._application_name = characterentities.decode(application_name_clean).strip()
コード例 #16
0
ファイル: badge.py プロジェクト: geokrety/geokrety-api-models
 def name(self):
     return characterentities.decode(self._name)
コード例 #17
0
 def comment(self):
     return characterentities.decode(self._comment)
コード例 #18
0
ファイル: badge.py プロジェクト: geokrety/geokrety-api-models
 def description(self):
     if self._description is None:
         return u''
     return characterentities.decode(self._description)
コード例 #19
0
 def comment(self, comment):
     # Drop all html tags
     comment_clean = bleach.clean(comment, strip=True)
     # Strip spaces
     self._comment = characterentities.decode(comment_clean).strip()
コード例 #20
0
ファイル: badges.py プロジェクト: kumy/geokrety-api
 def validate_title_blank(self, data):
     data = characterentities.decode(data).replace('\x00', '').strip()
     if not data:
         raise UnprocessableEntity("Badge name cannot be blank",
                                   {'pointer': '/data/attributes/name'})
コード例 #21
0
ファイル: news.py プロジェクト: geokrety/geokrety-api-models
 def title(self):
     return characterentities.decode(self._title)