Skip to content

Commit

Permalink
Clean up reporting. We had to inline images and css because:
Browse files Browse the repository at this point in the history
We had the issue where this worked locally, but not on the server.
If we used links for stylesheet and `img src` urls, it would attempt
to fetch them but the request timed out after 10 seconds.

This might be because of concurrentrequests, and the test server only
having 1 thread at the time. In any case, this approach to inline it
should be prettty fool proof.
  • Loading branch information
cyrillkuettel committed Aug 5, 2024
1 parent 54e0bad commit 7d0258a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 252 deletions.
116 changes: 0 additions & 116 deletions src/privatim/reporting/report.css

This file was deleted.

12 changes: 1 addition & 11 deletions src/privatim/reporting/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from babel.dates import format_datetime

from privatim.i18n import translate, _
from privatim.layouts.layout import DEFAULT_TIMEZONE, Layout
from privatim.layouts.layout import DEFAULT_TIMEZONE
from privatim.utils import datetime_format
from pyramid.renderers import render
from weasyprint import HTML # type: ignore
Expand Down Expand Up @@ -110,7 +110,6 @@ class HTMLReportRenderer:
"""

css = 'privatim:reporting/template/report.css'
template = 'privatim:reporting/template/report.pt'

def render(
Expand All @@ -134,20 +133,11 @@ def render_template(

title = translate(_("Protocol of meeting ${title}",
mapping={'title': document_context['title']}))

layout = Layout(meeting, request)
ctx = {
'title': title,
'meeting': meeting,
'meeting_time': datetime_format(meeting.time),
'document': document_context,
'layout': layout,
# 'stylesheet': layout.static_url(
# 'privatim:static/custom.css'
# ),
'logo_url': layout.static_url(
'privatim:static/logo-dark-font-transparent-smaller.png'
)
}
return render(self.template, ctx)

Expand Down
14 changes: 5 additions & 9 deletions src/privatim/reporting/template/report.pt

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/privatim/static/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def get_default_profile_pic_data() -> tuple[str, bytes]:
fontawesome_css = css('fontawesome.min.css')
bootstrap = css('bootstrap.min.css')
bootstrap_css = css('custom.css', depends=[fontawesome_css, bootstrap])
report_css = css('report.css')

comments_css = css('comments.css')
profile_css = css('profile.css')
Expand Down
1 change: 1 addition & 0 deletions src/privatim/static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ mark {

}
/* https://stackoverflow.com/a/48484022/ */
/* Prevent having a blue outline (default) everywhere */
.form-control:focus,
.form-select:focus,
textarea:focus,
Expand Down
115 changes: 0 additions & 115 deletions src/privatim/static/css/report.css

This file was deleted.

0 comments on commit 7d0258a

Please sign in to comment.