-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a letter model for the habitability letter. (#2256)
* Add models for new letter type * Move some commonly used code into project/util * Run django:makemessages * Styling * Run dcra python manage.py makemigrations laletterbuilder * Lint and tests * fix imports * Add tests * Remove duplicate * Fix imports * Fix comment * Fix translation of text * Add back lost django translation * Add space back
- Loading branch information
1 parent
5a14457
commit 9113397
Showing
15 changed files
with
318 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Generated by Django 3.2.5 on 2022-02-22 19:51 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import project.util.lob_django_util | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='HabitabilityLetter', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('locale', models.CharField(choices=[('en', 'English'), ('es', 'Spanish')], default='en', help_text="The locale of the user who sent the mail item, at the time that they sent it. Note that this may be different from the user's current locale, e.g. if they changed it after sending the mail item.", max_length=5)), | ||
('lob_letter_object', models.JSONField(blank=True, help_text='If the mail item was sent via Lob, this is the JSON response of the API call that was made to send the mail item, documented at https://lob.com/docs/python#letters.', null=True)), | ||
('tracking_number', models.CharField(blank=True, help_text='The USPS tracking number for the mail item.', max_length=100)), | ||
('html_content', models.TextField(help_text='The HTML content of the letter at the time it was sent, in English.')), | ||
('localized_html_content', models.TextField(blank=True, help_text="The HTML content of the letter at the time it was sent, in the user's locale at the time they sent it. If the user's locale is English, this will be blank (since the English version is already stored in another field).")), | ||
('letter_sent_at', models.DateTimeField(blank=True, help_text='When the letter was mailed.', null=True)), | ||
('letter_emailed_at', models.DateTimeField(blank=True, help_text='When the letter was e-mailed.', null=True)), | ||
('fully_processed_at', models.DateTimeField(blank=True, help_text='When the letter was fully processed, i.e. sent to all relevant parties.', null=True)), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='laletterbuilder_letters', to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
'ordering': ['-created_at'], | ||
'abstract': False, | ||
}, | ||
bases=(models.Model, project.util.lob_django_util.SendableViaLobMixin), | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
from project import common_data | ||
from project.util.lob_models_util import LocalizedHTMLLetter | ||
from users.models import JustfixUser | ||
from django.db import models | ||
|
||
|
||
LETTER_TYPE_CHOICES = common_data.Choices.from_file("la-letter-builder-letter-choices.json") | ||
|
||
|
||
class Letter(LocalizedHTMLLetter): | ||
""" | ||
A LA Letter Builder letter that's ready to be sent, or has already been sent. | ||
""" | ||
|
||
class Meta: | ||
abstract = True | ||
ordering = ["-created_at"] | ||
|
||
user = models.ForeignKey( | ||
JustfixUser, on_delete=models.CASCADE, related_name="laletterbuilder_letters" | ||
) | ||
|
||
|
||
class HabitabilityLetter(Letter): | ||
def __str__(self): | ||
if not self.pk: | ||
return super().__str__() | ||
return f"{self.user.full_legal_name}'s Habitability LA Letter Builder letter" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import factory | ||
from users.tests.factories import UserFactory | ||
from loc.models import LandlordDetails | ||
from laletterbuilder.models import HabitabilityLetter | ||
|
||
|
||
class LandlordDetailsFactory(factory.django.DjangoModelFactory): | ||
|
@@ -14,10 +15,16 @@ class Meta: | |
address = "1 Cloud City" | ||
|
||
|
||
class LandlordDetailsFactory(LandlordDetailsFactory): | ||
address = "123 Cloud City Drive\nBespin, NY 12345" | ||
primary_line = "123 Cloud City Drive" | ||
city = "Bespin" | ||
state = "NY" | ||
zip_code = "12345" | ||
email = "[email protected]" | ||
class HabitabilityLetterFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = HabitabilityLetter | ||
|
||
user = factory.SubFactory(UserFactory) | ||
|
||
html_content = "<p>hi i am a habitability letter</p>" | ||
|
||
@classmethod | ||
def _create(self, model_class, *args, **kwargs): | ||
letter = HabitabilityLetter(*args, **kwargs) | ||
letter.save() | ||
return letter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from laletterbuilder.models import HabitabilityLetter | ||
from .factories import HabitabilityLetterFactory | ||
|
||
|
||
class TestHabitabilityLetter: | ||
def test_str_works_on_brand_new_models(self): | ||
assert str(HabitabilityLetter()) == "HabitabilityLetter object (None)" | ||
|
||
def test_str_works_on_filled_out_models(self, db): | ||
decl = HabitabilityLetterFactory() | ||
assert str(decl) == "Boop Jones's Habitability LA Letter Builder letter" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2021-11-29 19:23+0000\n" | ||
"POT-Creation-Date: 2022-02-23 19:00+0000\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -23,22 +23,22 @@ msgstr "" | |
msgid "%(name)s, your eviction protection form has been emailed to your landlord." | ||
msgstr "" | ||
|
||
#: evictionfree/declaration_sending.py:133 | ||
#: evictionfree/declaration_sending.py:132 | ||
#, python-format | ||
msgid "%(name)s, a hard copy of your eviction protection form has been mailed to your landlord via USPS mail. You can track the delivery of your hard copy form using USPS Tracking: %(url)s." | ||
msgstr "" | ||
|
||
#: evictionfree/declaration_sending.py:176 | ||
#: evictionfree/declaration_sending.py:175 | ||
#, python-format | ||
msgid "%(name)s, your eviction protection form has been emailed to your local housing court." | ||
msgstr "" | ||
|
||
#: evictionfree/declaration_sending.py:249 | ||
#: evictionfree/declaration_sending.py:248 | ||
#, python-format | ||
msgid "%(name)s, you can download a PDF of your completed declaration form by logging back into your account: %(url)s." | ||
msgstr "" | ||
|
||
#: evictionfree/declaration_sending.py:257 | ||
#: evictionfree/declaration_sending.py:256 | ||
#, python-format | ||
msgid "For more information about New York’s eviction protections and your rights as a tenant, visit %(url)s. To get involved in organizing and the fight to #StopEvictions and #CancelRent, follow us on Twitter at @RTCNYC and @housing4allNY." | ||
msgstr "" | ||
|
@@ -92,7 +92,7 @@ msgstr "" | |
msgid "%(city)s, %(state_name)s doesn't seem to exist!" | ||
msgstr "" | ||
|
||
#: norent/letter_sending.py:112 | ||
#: norent/letter_sending.py:38 | ||
#, python-format | ||
msgid "%(name)s you've sent your letter of non-payment of rent. You can track the delivery of your letter using USPS Tracking: %(url)s." | ||
msgstr "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.