-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ISSUE-8): Use Django's form and hide with css
- Loading branch information
Thu Trang Pham
committed
Feb 21, 2021
1 parent
9aeb799
commit b1c9324
Showing
6 changed files
with
105 additions
and
130 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 |
---|---|---|
@@ -1,24 +1,28 @@ | ||
.submit-row a.cancel-link { | ||
display: block; | ||
background: #ba2121; | ||
border-radius: 4px; | ||
padding: 10px 15px; | ||
height: 15px; | ||
line-height: 15px; | ||
color: #fff; | ||
display: block; | ||
background: #ba2121; | ||
border-radius: 4px; | ||
padding: 10px 15px; | ||
height: 15px; | ||
line-height: 15px; | ||
color: #fff; | ||
} | ||
|
||
.submit-row a.cancel-link:focus, | ||
.submit-row a.cancel-link:hover, | ||
.submit-row a.cancel-link:active { | ||
background: #a41515; | ||
background: #a41515; | ||
} | ||
|
||
.changed-data table { | ||
width: 100%; | ||
width: 100%; | ||
} | ||
.changed-data th, | ||
.changed-data td { | ||
width: 30%; | ||
white-space: nowrap; | ||
} | ||
width: 30%; | ||
white-space: nowrap; | ||
} | ||
|
||
.hidden { | ||
display: none; | ||
} |
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 @@ | ||
from django.test import TestCase, RequestFactory | ||
from django.contrib.auth.models import User | ||
|
||
|
||
class ConfirmAdminTestCase(TestCase): | ||
@classmethod | ||
def setUpTestData(cls): | ||
cls.superuser = User.objects.create_superuser( | ||
username="super", email="super@email.org", password="pass" | ||
) | ||
|
||
def setUp(self): | ||
self.client.force_login(self.superuser) | ||
self.factory = RequestFactory() | ||
|
||
def _assertManyToManyFormHtml(self, rendered_content, options, selected_ids): | ||
# Form data should be embedded and hidden on confirmation page | ||
# Should have the correct ManyToMany options selected | ||
for option in options: | ||
self.assertIn( | ||
f'<option value="{option.id}"{" selected" if option.id in selected_ids else ""}>{str(option)}</option>', | ||
rendered_content, | ||
) | ||
# ManyToManyField should be embedded | ||
self.assertIn("related-widget-wrapper", rendered_content) | ||
|
||
def _assertSubmitHtml(self, rendered_content, save_action="_save"): | ||
# Submit should conserve the save action | ||
self.assertIn( | ||
f'<input type="submit" value="Yes, I’m sure" name="{save_action}">', | ||
rendered_content, | ||
) | ||
# There should not be _confirm_add or _confirm_change sent in the form on confirmaiton page | ||
self.assertNotIn("_confirm_add", rendered_content) | ||
self.assertNotIn("_confirm_change", rendered_content) | ||
|
||
def _assertSimpleFieldFormHtml(self, rendered_content, fields): | ||
for k, v in fields.items(): | ||
self.assertIn(f'name="{k}"', rendered_content) | ||
self.assertIn(f'value="{v}"', rendered_content) |
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