Skip to content
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

Merged
merged 14 commits into from
Jul 26, 2024
Merged

Add reports to user-admin panel #43

merged 14 commits into from
Jul 26, 2024

Conversation

kjcioffi
Copy link
Owner

  • Added 3 kinds of reports
    • Customer
    • Product
    • Sales
  • Reports can be downloaded in CSV or PDF format.

@kjcioffi kjcioffi added the enhancement New feature or request label Jul 25, 2024
@kjcioffi kjcioffi requested a review from ryaustin July 25, 2024 19:47
@kjcioffi kjcioffi self-assigned this Jul 25, 2024
@kjcioffi kjcioffi linked an issue Jul 25, 2024 that may be closed by this pull request
3 tasks
Copy link
Collaborator

@ryaustin ryaustin left a 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" %}
Copy link
Collaborator

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>

Copy link
Owner Author

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.

@kjcioffi kjcioffi merged commit 249d29f into main Jul 26, 2024
@kjcioffi kjcioffi deleted the 4-add-reports branch July 26, 2024 17:27
@kjcioffi kjcioffi restored the 4-add-reports branch July 26, 2024 17:27
@kjcioffi kjcioffi mentioned this pull request Jul 26, 2024
2 tasks
@kjcioffi kjcioffi deleted the 4-add-reports branch August 20, 2024 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Reports
2 participants