Esempio n. 1
0
    def save(self, *args, **kwargs):
        self.nick = bleach_no_tags(self.nick)
        self.bio = bleach_tinymce(self.bio)
        self.discordTag = bleach_no_tags(self.discordTag)

        # TODO: old images can still stay on the server, as different extensions can be used (.jpeg, .jpg,
		# .png and etc.). Not too problematic but might want to fix - Sorc Save new image to file first -Sorc
        super(Member, self).save(*args, **kwargs)

        dim = 128, 128
        if self.img and (self.img_height != dim[1] or self.img_width != dim[0]):
            try:
                new_img = Image.open(self.img.path).convert("RGB")
                ######
                # http://matthiaseisen.com/pp/patterns/p0202/
                shorter_side_by_half = min(new_img.size) / 2
                half_the_width = new_img.size[0] / 2
                half_the_height = new_img.size[1] / 2
                new_img.crop(
                    (
                        half_the_width - shorter_side_by_half,
                        half_the_height - shorter_side_by_half,
                        half_the_width + shorter_side_by_half,
                        half_the_height + shorter_side_by_half
                    )
                ).resize(dim, Image.ANTIALIAS).save(self.img.path, quality=90)
                #######
                self.img_height = dim[1]
                self.img_width = dim[0]
                super(Member, self).save(*args, **kwargs)
            except Exception as e:
                raise
Esempio n. 2
0
    def save(self, **kwargs):
        self.title = bleach_no_tags(self.title)
        self.content = bleach_tinymce(self.content)
        self.slug = slugify(self.title)

        # Begin the webhook to Discord server
        # Note for some god damn stupid reason markupbase is required but doesn't exist anywhere for Python 3.5
        # To make this work, go to https://raw.githubusercontent.com/enthought/Python-2.7.3/master/Lib/markupbase.py
        # and add this to your project site-packages folder
        data = {"username": "******", "embeds": [{
            "title": re.compile(r'<.*?>').sub('', self.title),
            "description": "Created by " + self.created_by.member.nick,
            "url": "http://animesoc.co.uk/news/All/1/",
            "timestamp": self.created.utcnow().isoformat(),
            "fields": [{"name": "Info:", "value": html.unescape(re.sub(re.compile('<.*?>'), '', self.content))}]
        }]
                }
        data_json = json.dumps(data)
        headers = {'Content-type': 'application/json'}
        response = requests.post(discordwebhook, data=data_json, headers=headers)
        super(Article, self).save()
Esempio n. 3
0
    def save(self, **kwargs):
        self.title = bleach_no_tags(self.title)
        self.content = bleach_tinymce(self.content)
        self.slug = slugify(self.title)

        # Begin the webhook to Discord server
        # Note for some god damn stupid reason markupbase is required but doesn't exist anywhere for Python 3.5
        # To make this work, go to https://raw.githubusercontent.com/enthought/Python-2.7.3/master/Lib/markupbase.py
        # and add this to your project site-packages folder
        data = {
            "username":
            "******",
            "embeds": [{
                "title":
                re.compile(r'<.*?>').sub('', self.title),
                "description":
                "Created by " + self.created_by.member.nick,
                "url":
                "http://animesoc.co.uk/news/All/1/",
                "timestamp":
                self.created.utcnow().isoformat(),
                "fields": [{
                    "name":
                    "Info:",
                    "value":
                    html.unescape(re.sub(re.compile('<.*?>'), '',
                                         self.content))
                }]
            }]
        }
        data_json = json.dumps(data)
        headers = {'Content-type': 'application/json'}
        response = requests.post(discordwebhook,
                                 data=data_json,
                                 headers=headers)
        super(Article, self).save()
Esempio n. 4
0
 def save(self):
     self.content = bleach_tinymce(self.content)
     super(Post, self).save()
Esempio n. 5
0
 def save(self):
     self.title = bleach_no_tags(self.title)
     self.body = bleach_tinymce(self.body)
     super(HistoryEntry, self).save()
Esempio n. 6
0
 def save(self):
     self.title = bleach_no_tags(self.title)
     self.content = bleach_tinymce(self.content)
     super(HomeAlert, self).save()
Esempio n. 7
0
 def save(self):
     self.exec_role = bleach_no_tags(self.exec_role)
     self.exec_info = bleach_tinymce(self.exec_info)
     super(Exec, self).save()
Esempio n. 8
0
 def save(self):
     self.details = bleach_tinymce(self.details)
     super(Event, self).save()
Esempio n. 9
0
 def save(self):
     self.title = bleach_no_tags(self.title)
     self.body = bleach_tinymce(self.body)
     super(HistoryEntry, self).save()
Esempio n. 10
0
 def save(self):
     self.exec_role = bleach_no_tags(self.exec_role)
     self.exec_info = bleach_tinymce(self.exec_info)
     super(Exec, self).save()
Esempio n. 11
0
 def save(self):
     self.title = bleach_no_tags(self.title)
     self.content = bleach_tinymce(self.content)
     super(HomeAlert, self).save()
Esempio n. 12
0
 def save(self):
     self.details = bleach_tinymce(self.details)
     super(Event, self).save()