diff --git a/pastebin/models.py b/pastebin/models.py index ddeca43..f955579 100644 --- a/pastebin/models.py +++ b/pastebin/models.py @@ -12,14 +12,14 @@ from django.db import models vertex_pattern = re.compile(r'vertex\s+([0-9.e+-]+)\s+([0-9.e+-]+)\s+([0-9.e+-]+)') def safe_upload_path(base_dir): - + def generate_path(instance, filename): ext = os.path.splitext(filename)[1] md5sum = md5() - md5sum.update(instance.name - + str(datetime.now()) + md5sum.update(instance.name + + str(datetime.now()) + filename) randomname = md5sum.hexdigest() @@ -66,7 +66,7 @@ class Geometry(models.Model): @classmethod def get_latest(cls): - return cls.objects.all().filter(public = True).order_by('date')[:10] + return cls.objects.all().filter(public = True).order_by('-date')[:10] def get_expiration_date(self): for expiration in [self.HOUR, self.DAY, self.WEEK, self.MONTH]: @@ -83,13 +83,13 @@ class Geometry(models.Model): count = 0 min_coord = [None,None,None] - max_coord = [None,None,None] + max_coord = [None,None,None] if self.file.read(5) != "solid": print "binary" #Skip header self.file.seek(80) - count = struct.unpack("i",self.file.read(4))[0] + count = struct.unpack("i",self.file.read(4))[0] done = False for pos in range(0,count): @@ -97,24 +97,24 @@ class Geometry(models.Model): self.file.seek(self.file.tell()+3*4) #Loop over each coordinate for vert in range(0,3): - # Loop over each coordinate + # Loop over each coordinate for i in range(0,3): - x = struct.unpack("