From f3e4c5f7f949ea07e876c51cd085b7d734177740 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Tue, 18 May 2021 18:44:15 +0300 Subject: Small fixes --- servo/models/common.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'servo/models/common.py') diff --git a/servo/models/common.py b/servo/models/common.py index 520b769..1d3e17b 100644 --- a/servo/models/common.py +++ b/servo/models/common.py @@ -46,6 +46,7 @@ class CsvTable(object): self.header = u'' def padrow(self, row): + """Pad row to self.colwdith""" r = [] for c in row: r.append(unicode(c).ljust(self.colwidth)) @@ -761,7 +762,9 @@ class Template(models.Model): class Attachment(models.Model): - """A file attached to something.""" + """ + A file attached to something. + """ content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) object_id = models.PositiveIntegerField() content_object = GenericForeignKey('content_type', 'object_id') @@ -786,7 +789,7 @@ class Attachment(models.Model): attachment.save() def save(self, *args, **kwargs): - DENIED_EXTENSIONS = ('.htm', '.html', '.py', '.js',) + DENIED_EXTENSIONS = ('.htm', '.html', '.py', '.js', '.exe', '.sh',) filename = self.content.name.lower() ext = os.path.splitext(filename)[1] @@ -798,10 +801,10 @@ class Attachment(models.Model): def __str__(self): return os.path.basename(self.content.name) - def __str__(self): - return unicode(self).encode('utf-8') - def from_url(self, url): + """ + Downloads a file and creates an attachment + """ pass def get_absolute_url(self): -- cgit v1.2.3