license + handle re-adding drive (somewhat)

This commit is contained in:
sanj 2010-11-25 11:18:39 +01:00
parent 1011b48877
commit e2919ae161
4 changed files with 43 additions and 7 deletions

14
COPYING Normal file
View File

@ -0,0 +1,14 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2010 Sanjay Bhangar <sanjay@camputer.org>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

View File

@ -1,8 +1,19 @@
from django.db import models
class File(models.Model):
fullpath = models.TextField()
filename = models.CharField(max_length=512)
extension = models.CharField(max_length=10, blank=True)
file_size = models.BigIntegerField()
date_created = models.DateTimeField()
date_modified = models.DateTimeField()
date_accessed = models.DateTimeField()
sha1sum = models.CharField(max_length=100)
mime_type = models.CharField
class Meta:
abstract = True
# Create your models here.
class Video(File):

View File

@ -16,8 +16,8 @@ def addHardDrive(filename, path):
filePath = join(path, filename)
hdName = filename.replace(".txt", "")
file = open(filePath)
if hardDriveExists(hdName):
return False
if hd = hardDriveExists(hdName):
hd.remove_files()
else:
hd = HardDrive(name = hdName)
hd.save()
@ -38,6 +38,10 @@ def addFile(filePath, hd):
print "added " + filename
def hardDriveExists(hdName):
q = HardDrive.objects.filter(name=hdName)
if q.count() > 0:
return q[0]
else:
return False
def getFileNameFromPath(filePath):

View File

@ -2,9 +2,16 @@ from django.db import models
class HardDrive(models.Model):
name = models.CharField(max_length = 255, unique = True)
def __unicode__(self):
return self.name
# volumeLabel = models.CharField(max_length = 255)
def remove_files(self):
files = File.objects.filter(hd=self)
for f in files:
f.delete()
return True
class File(models.Model):