-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add reports to user-admin panel #43
Conversation
kjcioffi
commented
Jul 25, 2024
- Added 3 kinds of reports
- Customer
- Product
- Sales
- Reports can be downloaded in CSV or PDF format.
- Add column for displaying percentage of order. - Add dollar signs and other symbols to better describe the data. - Add store name into the file name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is totally rad!
Now with reporting using csv and pdfs this app is shaping up to a very useful saas tool
- reports are working
- no regression possible
- we can discuss how to test this particularly pdfs
- we can think about refactoring later such as reducing some repetition but not essential today.
I'm happy that you raised the alarm and stuck through this problem!
@@ -0,0 +1,21 @@ | |||
{% extends "store/base.html" %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might consider creating reports_base.html. This is so that you can set reports up independent of the base.html with its navigation etc that will not make much sense on a pdf report.
We see from he weasyprint documentation that using @page
we can create a block rules that weasyprint will respond to. A practical example could be
- setting the page size and orientation (which can also be passed in as variables in the context data).
- setting up headers and footers so that reports look consistent
Here's an example of a reports_base.html taken from bits and pieces of their documentation and a bit of regular html/django:
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Report {% block title %} {% endblock %}</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'css/reports/reports_base.css' %}">
<style>
@page {
size: letter Portrait;
margin: 1in;
font-family: 'Roboto', 'Arial', sans-serif;
@bottom-left {
content: 'Contempo Crafts';
font-size: x-small;
}
@bottom-center {
content: "Page " counter(page) " of " counter(pages);
font-size: x-small;
}
@bottom-right {
content: '{{report_date | default_if_none:""}} {{report_name}}';
font-size: x-small;
}
}
</style>
{% block styles %}{% endblock %}
</head>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware these features existed, thanks! I will add this suggestion to #3 for my sanity as this seems more related to that issue. That way I can also close and complete this PR.