Browse Source

Back-end updates for saving file metadata

pull/170/head
Michael Olund 5 years ago
parent
commit
89e314c2a4
5 changed files with 58 additions and 5 deletions
  1. +23
    -0
      edivorce/apps/poc/migrations/0003_auto_20200915_1645.py
  2. +18
    -0
      edivorce/apps/poc/migrations/0004_auto_20200917_1008.py
  3. +2
    -0
      edivorce/apps/poc/models.py
  4. +5
    -2
      edivorce/apps/poc/views.py
  5. +10
    -3
      vue/src/components/Uploader.vue

+ 23
- 0
edivorce/apps/poc/migrations/0003_auto_20200915_1645.py View File

@ -0,0 +1,23 @@
# Generated by Django 2.2.15 on 2020-09-15 23:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('poc', '0002_auto_20200823_0606'),
]
operations = [
migrations.AddField(
model_name='document',
name='docType',
field=models.CharField(max_length=4, null=True),
),
migrations.AddField(
model_name='document',
name='partyId',
field=models.IntegerField(default=0),
),
]

+ 18
- 0
edivorce/apps/poc/migrations/0004_auto_20200917_1008.py View File

@ -0,0 +1,18 @@
# Generated by Django 2.2.15 on 2020-09-17 17:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('poc', '0003_auto_20200915_1645'),
]
operations = [
migrations.AlterField(
model_name='document',
name='docType',
field=models.CharField(blank=True, max_length=4, null=True),
),
]

+ 2
- 0
edivorce/apps/poc/models.py View File

@ -10,6 +10,8 @@ class Document(models.Model):
"""
filename = models.CharField(max_length=128, null=True) # saving the original filename separately
file = models.FileField(upload_to=redis.generate_unique_filename, storage=redis.RedisStorage())
docType = models.CharField(max_length=4, null=True, blank=True)
partyId = models.IntegerField(default=0)
def save(self, *args, **kwargs):
self.filename = self.file.name


+ 5
- 2
edivorce/apps/poc/views.py View File

@ -39,13 +39,16 @@ class UploadScan(FormView):
class UploadStorage(CreateView):
model = Document
fields = ['file']
fields = ['file', 'docType', 'partyId']
template_name = "storage.html"
success_url = settings.FORCE_SCRIPT_NAME + 'poc/storage'
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return super(UploadStorage, self).dispatch(request, *args, **kwargs)
response = super(UploadStorage, self).dispatch(request, *args, **kwargs)
if response.status_code == 200:
return HttpResponse(status=204)
return response
def get_context_data(self, **kwargs):
kwargs['documents'] = Document.objects.all()


+ 10
- 3
vue/src/components/Uploader.vue View File

@ -22,11 +22,12 @@
:drop="true"
:drop-directory="false"
:post-action="postAction"
@input-file="inputFile"
@input-filter="inputFilter"
:input-id="inputId"
name="file"
:class="['drop-zone', dragging ? 'dragging' : '']">
:class="['drop-zone', dragging ? 'dragging' : '']"
:data="data"
@input-file="inputFile"
@input-filter="inputFilter">
<div v-if="files.length === 0" class="placeholder">
<i class="fa fa-plus-circle"></i><br>
<em>Drag and Drop the PDF document or JPG pages here,<br>or click here to Browse for files.</em>
@ -91,6 +92,12 @@ export default {
},
postAction() {
return this.$parent.proxyRootPath + "poc/storage"
},
data() {
return {
docType: this.docType,
partyId: this.party
};
}
},
methods: {


Loading…
Cancel
Save