forked from eregs/regulations-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
executable file
·60 lines (44 loc) · 1.9 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from django.db import models
job_status_pairs = (
("complete", "complete"),
("complete_with_errors", "complete_with_errors"),
("failed", "failed"),
("in_progress", "in_progress"),
("received", "received")
)
job_status_values = [j[0] for j in job_status_pairs]
class ParsingJob(models.Model):
class Meta:
abstract = True
created = models.DateTimeField(auto_now_add=True)
clear_cache = models.BooleanField(default=False)
destination = models.URLField(max_length=2000)
notification_email = models.EmailField(blank="True", max_length=254)
job_id = models.UUIDField(default=None, null=True)
use_uploaded_metadata = models.UUIDField(default=None, null=True)
use_uploaded_regulation = models.UUIDField(default=None, null=True)
parser_errors = models.TextField(blank=True)
regulation_url = models.URLField(blank=True, max_length=2000)
status = models.CharField(max_length=32, choices=(
("received", "received"),
("in_progress", "in_progress"),
("failed", "failed"),
("complete", "complete"),
("complete_with_errors", "complete_with_errors")
), default="received")
url = models.URLField(blank=True, max_length=2000)
def save(self, *args, **kwargs):
super(ParsingJob, self).save(*args, **kwargs)
class PipelineJob(ParsingJob):
cfr_title = models.IntegerField()
cfr_part = models.IntegerField()
only_latest = models.BooleanField(default=False)
class ProposalPipelineJob(ParsingJob):
file_hexhash = models.CharField(max_length=32)
only_latest = models.BooleanField(default=True)
class RegulationFile(models.Model):
contents = models.BinaryField()
file = models.FileField(null=True)
filename = models.CharField(default=None, max_length=512, null=True)
hexhash = models.CharField(default=None, max_length=32, null=True)
url = models.URLField(blank=True, max_length=2000)