summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Scheibenpflug <zorchenhimer@gmail.com>2015-06-16 22:47:49 (GMT)
committerNick Scheibenpflug <zorchenhimer@gmail.com>2015-06-16 22:47:49 (GMT)
commitea4d4b5a92411bb743dfded99cca78286bf1a3e3 (patch)
treeff95f8232540af218399652f663cfffbc56318cd
parent3ef793c7183d67529dad8ea6345a16142d2c7a9a (diff)
downloadmanga-reader-ea4d4b5a92411bb743dfded99cca78286bf1a3e3.zip
manga-reader-ea4d4b5a92411bb743dfded99cca78286bf1a3e3.tar.gz
Added oneshot field to orphan model.
-rw-r--r--file_management/forms.py1
-rw-r--r--file_management/migrations/0005_uploadedorphan_oneshot.py19
-rw-r--r--file_management/models.py1
-rw-r--r--file_management/views.py7
4 files changed, 25 insertions, 3 deletions
diff --git a/file_management/forms.py b/file_management/forms.py
index 6f0d7ff..dd9cd43 100644
--- a/file_management/forms.py
+++ b/file_management/forms.py
@@ -8,3 +8,4 @@ class EditOrphanedManga(forms.Form):
8 orphan_id = forms.HiddenInput() 8 orphan_id = forms.HiddenInput()
9 manga_name = forms.CharField(max_length=120) 9 manga_name = forms.CharField(max_length=120)
10 system_name = forms.CharField(max_length=120) 10 system_name = forms.CharField(max_length=120)
11 oneshot = forms.BooleanField(label="Oneshot", initial=False, required=False)
diff --git a/file_management/migrations/0005_uploadedorphan_oneshot.py b/file_management/migrations/0005_uploadedorphan_oneshot.py
new file mode 100644
index 0000000..1c24bf8
--- /dev/null
+++ b/file_management/migrations/0005_uploadedorphan_oneshot.py
@@ -0,0 +1,19 @@
1# -*- coding: utf-8 -*-
2from __future__ import unicode_literals
3
4from django.db import models, migrations
5
6
7class Migration(migrations.Migration):
8
9 dependencies = [
10 ('file_management', '0004_manga_oneshot'),
11 ]
12
13 operations = [
14 migrations.AddField(
15 model_name='uploadedorphan',
16 name='oneshot',
17 field=models.BooleanField(default=False),
18 ),
19 ]
diff --git a/file_management/models.py b/file_management/models.py
index 40fa7d7..68b9576 100644
--- a/file_management/models.py
+++ b/file_management/models.py
@@ -63,6 +63,7 @@ class Chapter(models.Model):
63class UploadedOrphan(models.Model): 63class UploadedOrphan(models.Model):
64 filename = models.CharField(max_length=120) 64 filename = models.CharField(max_length=120)
65 original_filename = models.CharField(max_length=120) 65 original_filename = models.CharField(max_length=120)
66 oneshot = models.BooleanField(default=False)
66 67
67 def __str__(self): 68 def __str__(self):
68 return '{f} - {o}'.format(f=self.filename, o=self.original_filename) 69 return '{f} - {o}'.format(f=self.filename, o=self.original_filename)
diff --git a/file_management/views.py b/file_management/views.py
index 8557e2a..b8e27d9 100644
--- a/file_management/views.py
+++ b/file_management/views.py
@@ -52,13 +52,13 @@ def handle_upload(form_data):
52 extracted_list = os.listdir(extracted_dir) 52 extracted_list = os.listdir(extracted_dir)
53 print('[handle_upload] form_data: {}'.format(form_data)) 53 print('[handle_upload] form_data: {}'.format(form_data))
54 54
55 if len(extracted_list) == 1 and form_data['oneshot'] == False: 55 if form_data['oneshot'] == True:
56 # One subdirectory, move everything up one level 56 # One subdirectory, move everything up one level
57 for file in os.listdir( os.path.join( extracted_dir, extracted_list[0]) ): 57 for file in os.listdir( os.path.join( extracted_dir, extracted_list[0]) ):
58 os.rename( os.path.join( extracted_dir, extracted_list[0], file), os.path.join(extracted_dir, file) ) 58 os.rename( os.path.join( extracted_dir, extracted_list[0], file), os.path.join(extracted_dir, file) )
59 os.rmdir( os.path.join( extracted_dir, extracted_list[0] ) ) 59 os.rmdir( os.path.join( extracted_dir, extracted_list[0] ) )
60 60
61 ou = UploadedOrphan.objects.create(filename=stamp, original_filename=uploaded_file.name) 61 ou = UploadedOrphan.objects.create(filename=stamp, original_filename=uploaded_file.name, oneshot=form_data['oneshot'])
62 return ou.id 62 return ou.id
63 63
64def edit_manga(request, mid): 64def edit_manga(request, mid):
@@ -72,7 +72,8 @@ def edit_orphan(request, oid):
72 if form.is_valid(): 72 if form.is_valid():
73 manga = Manga.objects.create( 73 manga = Manga.objects.create(
74 full_name=form['manga_name'].value(), 74 full_name=form['manga_name'].value(),
75 system_name=form['system_name'].value() 75 system_name=form['system_name'].value(),
76 oneshot = form['oneshot'].value()
76 ) 77 )
77 move_orphan(oid, manga.id) 78 move_orphan(oid, manga.id)
78 #return HttpResponse('Given name: {n}<br />System: {s}'.format(n=form['manga_name'].value(), s=form['system_name'].value())) 79 #return HttpResponse('Given name: {n}<br />System: {s}'.format(n=form['manga_name'].value(), s=form['system_name'].value()))