license + handle re-adding drive (somewhat)
This commit is contained in:
parent
1011b48877
commit
e2919ae161
14
COPYING
Normal file
14
COPYING
Normal 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.
|
||||
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user