Skip to content

Commit

Permalink
Switch to header structure for different levels of interests
Browse files Browse the repository at this point in the history
- Start at h4 to allow for the structure of the page.
  • Loading branch information
ajparsons committed Dec 12, 2024
1 parent fd4cdf4 commit 4eee62a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pyscraper/regmem/commons/api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ def multi_to_camel(value: str) -> AliasChoices:
interest_template = Template(
"""
<div class="interest-item" id="{{ interest.id }}">
<p class="interest-summary parent-interest-item">{{ interest.summary|e }}</p>
{% if is_child %}
<h6 class="interest-summary">{{ interest.summary|e }}</h6>
{% else %}
<h4 class="interest-summary">{{ interest.summary|e }}</h4>
{% endif %}
<ul class="interest-details-list">
{% for field in interest.present_fields() %}
{{field.to_html()}}
Expand All @@ -60,10 +63,10 @@ def multi_to_camel(value: str) -> AliasChoices:
</ul>
{% if interest.child_items %}
<p class="child-item-header">Specific work or payments</p>
<h5 class="child-item-header">Specific work or payments</h5>
<div class="interest-child-items" id="parent-{{ interest.id }}">
{% for child in interest.child_items %}
{{child.to_html()}}
{{ child.to_html(is_child=True) }}
{% endfor %}
</div>
{% endif %}
Expand Down Expand Up @@ -212,8 +215,8 @@ def last_updated_date(self) -> Optional[date]:
return self.updated_date[-1]
return None

def to_html(self) -> str:
result = interest_template.render(interest=self)
def to_html(self, is_child: bool = False) -> str:
result = interest_template.render(interest=self, is_child=is_child)

# remove blank lines
result = "\n".join([x for x in result.split("\n") if x.strip()])
Expand Down

0 comments on commit 4eee62a

Please sign in to comment.