|
1 | 1 | from django.db import models
|
2 | 2 |
|
| 3 | +job_status_pairs = ( |
| 4 | + ("complete", "complete"), |
| 5 | + ("complete_with_errors", "complete_with_errors"), |
| 6 | + ("failed", "failed"), |
| 7 | + ("in_progress", "in_progress"), |
| 8 | + ("received", "received") |
| 9 | +) |
| 10 | +job_status_values = tuple(j[0] for j in job_status_pairs) |
| 11 | + |
3 | 12 |
|
4 | 13 | class ParsingJob(models.Model):
|
5 | 14 |
|
| 15 | + class Meta: |
| 16 | + abstract = True |
| 17 | + |
6 | 18 | created = models.DateTimeField(auto_now_add=True)
|
7 |
| - cfr_title = models.IntegerField() |
8 |
| - cfr_part = models.IntegerField() |
9 | 19 | clear_cache = models.BooleanField(default=False)
|
10 |
| - destination = models.URLField(default="http://fake-reg-site.gov/api", |
11 |
| - max_length=2000) |
| 20 | + destination = models.URLField(max_length=2000) |
12 | 21 | notification_email = models.EmailField(blank="True", max_length=254)
|
13 |
| - only_latest = models.BooleanField(default=False) |
14 | 22 | job_id = models.UUIDField(default=None, null=True)
|
15 | 23 | use_uploaded_metadata = models.UUIDField(default=None, null=True)
|
16 | 24 | use_uploaded_regulation = models.UUIDField(default=None, null=True)
|
17 | 25 |
|
18 | 26 | parser_errors = models.TextField(blank=True)
|
19 | 27 | regulation_url = models.URLField(blank=True, max_length=2000)
|
20 |
| - status = models.CharField(max_length=32, choices=( |
21 |
| - ("received", "received"), |
22 |
| - ("in_progress", "in_progress"), |
23 |
| - ("failed", "failed"), |
24 |
| - ("complete", "complete"), |
25 |
| - ("complete_with_errors", "complete_with_errors") |
26 |
| - ), default="received") |
| 28 | + status = models.CharField(max_length=32, choices=job_status_pairs, |
| 29 | + default="received") |
| 30 | + url = models.URLField(blank=True, max_length=2000) |
| 31 | + |
| 32 | + |
| 33 | +class PipelineJob(ParsingJob): |
| 34 | + |
| 35 | + cfr_title = models.IntegerField() |
| 36 | + cfr_part = models.IntegerField() |
| 37 | + only_latest = models.BooleanField(default=False) |
| 38 | + |
| 39 | + |
| 40 | +class ProposalPipelineJob(ParsingJob): |
| 41 | + |
| 42 | + file_hexhash = models.CharField(max_length=32) |
| 43 | + only_latest = models.BooleanField(default=True) |
| 44 | + |
| 45 | + |
| 46 | +class RegulationFile(models.Model): |
| 47 | + |
| 48 | + contents = models.BinaryField() |
| 49 | + file = models.FileField(null=True) |
| 50 | + filename = models.CharField(default=None, max_length=512, null=True) |
| 51 | + hexhash = models.CharField(default=None, max_length=32, null=True) |
27 | 52 | url = models.URLField(blank=True, max_length=2000)
|
0 commit comments