Varghese robin newspost detail fixes#10
Conversation
…cms_user_sees_edit_link
| <link href="{% static 'bootstrap/css/bootstrap.min.css' %}" rel="stylesheet"> | ||
| <link href="{% static 'app.css' %}" rel="stylesheet"> | ||
| <title>Wavepool | Industry Dive</title> | ||
| <title>{{ newspost.title }} | Wavepool | Industry Dive</title> |
There was a problem hiding this comment.
This fixes was made to include the newspost.title in the template as required by test_newspost_page_title_attribute
|
|
||
| @property | ||
| def edit_url(self): | ||
| return reverse('admin:wavepool_newspost_change', args=[self.pk]) No newline at end of file |
There was a problem hiding this comment.
Here i Introduced a edit_url property that is eventually used in newspost.html to surface the edit URL to CMS users
| {% if is_staff %} | ||
| <div class="row"> | ||
| <a id="edit-link" href="{{ newspost.edit_url }}"><button>edit</button></a> | ||
| </div> | ||
| {% endif %} |
There was a problem hiding this comment.
This conditional template shows edit_url property only when a logged in user has is_staff flag set. The is_staffflag is set into context in the view.py
| context = { | ||
| 'newspost': newspost | ||
| 'newspost': newspost, | ||
| 'is_staff': request.user.is_staff |
There was a problem hiding this comment.
Here we set the is_staff flag based on current requesting user
| # Implementation based on naive assumption that URL is in a | ||
| # <protocol>://www.<hostname>.xyz/asdf-asdf-asdf format | ||
| hostname = self.source.split('/')[2].split('.')[1] | ||
| return DIVESITE_SOURCE_NAMES[hostname] |
There was a problem hiding this comment.
source_divesite_name was hardcoded before. I have modified this to resolve the hostname from the URL and then return the lookup from DIVESITE_SOURCE_NAMES
There was a problem hiding this comment.
i really like and prefer an implementation similar to ref in branch set_coverstory_for_front_page
def source_divesite_name(self):
return 'Industry Dive'
""" Return the real divesite source name for the newspost's source
"""
source_dive = 'Industry Dive'
url_parts = self.source.split('/')
dive_domain = url_parts[2]
domain_parts = dive_domain.split('.')
dive_domain = domain_parts[1]
if dive_domain in DIVESITE_SOURCE_NAMES:
return DIVESITE_SOURCE_NAMES[dive_domain]
return source_diveHowever i didn't want to just copy it
|
Kindly find attached along is a PDF with the pseudo code, a diagram/sketch, and a list of technical sub-tasks needed to fullfill the request. |
Comments and changes for Fixes #1, #2 and #4 are encapsulated in there individual commits.
Fix #3 is spread into three different commits in an attempt to pass
test_newspost_page_contentThe first one ads ids to templates, since it was previously not mentioned on the template.
Second modifies the test to compare text and not markedup text to rendered_body text as before.
Third there seems to be a typo in the fixture with missing paired
<p>tag.Lastly i have some minor verbiage changes to two typos in last commit