Pull requests

#43 Merged
Repository
simonedeponti simonedeponti
Branch
default
Repository
chris1610 chris1610
Branch
default

New document generation system

Author
  1. Simone Deponti avatarSimone Deponti
Reviewers
Description

New document generation system (bills, packing slips, etc). Currently generates HTML pages by default (the templates need to be fixed/extended) but also has capabilities to create PDF files either via trml2pdf or wkhtmltopdf. Capabilities exists to make the generation of pdf using other technologies such as xhtml2pdf trivial, or even to generate documents in any format (e.g. DOC, DOCX, ODT).

Comments (8)

  1. Chris Moffitt repo owner

    Simone,

    This looks pretty good. I merged it locally and noticed a couple of things.

    • The HTML file names shouldn't have a dash in them. They need to be packingslip.html and shippinglabel.html to work
    • The basic HTML files could use just a little more HTML styling. I don't need them to be really fancy but I do think they need to be useable out of the box. I think some of the <table> tags got missed somehow.
    • Can you add a documentation note to configuration.txt that outlines that SATCHMO_SETTINGS to put in place for TRML or WKHTML?
    • The reference to iconuri in the templates should be removed because I don't think it's defined in the default store.

    This is looking good and I'm really looking forward to including it in Satchmo once we get these things cleaned up.

    1. Simone Deponti author

      I did polish the template quite a bit and added documentation. I also removed the requirements of trml2pdf and Reportlab in the documentation, as they are not needed with the default HTML converter (they are still listed when the doc talks about enabling trml2pdf).

      While I was at it, I also did a complete check of the Italian translations, which were in a unmaintained state: they're now up to speed with the rest. As a side effect (I'm too used to git to get the hang on mercurial) I ended up including a lot of .mo files for other translations, which, however, shouldn't create problems (./manage.py compilemessages did it).

  2. marconius

    I like it. It's definitely an improvement over being stuck with the ol' rml2pdf. And it's all class-based and nice. For now though, would it be better to have ``'DOCUMENT_CONVERTER'`` default to ``'shipping.views.TRMLDocument'``? This way current users upgrading will not be surprised by the different-looking order docs. Maybe insert a DeprecationWarning somewhere?

    Also, I think this fixes an ommition in the code:

    --- a/satchmo/apps/shipping/views.py	Thu May 17 17:56:27 2012 +0200
    +++ b/satchmo/apps/shipping/views.py	Fri Jun 29 12:58:45 2012 -0400
    @@ -96,7 +96,7 @@
     
         def get_filename(self, request, context):
             return '%s-%s-%d.%s' % (
    -            context['shopDetails'].domain,
    +            context['shopDetails'].site.domain,
                 context['doc'],
                 context['order'].pk,
                 self.output_ext
    
    1. Simone Deponti author

      It's okay for me.

      I would restore the default to go to trml2pdf but, in the project skeleton, I would force it to be the HTML generator.

      In this way:

      • New users get the "cool way" up from the beginning
      • Old users don't get any surprise

      The deprecation warning is mostly related to how trml2pdf evolves but, seeing it's practically unmaintaned, it might be okay to raise it once (although I have no idea of when).

    1. Chris Moffitt repo owner

      I will try to take a look at it and make sure I can pull it in cleanly. I'll encourage others to test it out but I think it's shaping up nicely.

      1. Simone Deponti author

        I've modified slightly how wkhtml works because subprocess sometimes hangs if the data is quite big and pipes are being used, therefore I have switched to a tempfile-based approach.

        Also the LOGO_URI might need some rework because right now, if you put in a filename (file:) it won't work with the HTMLDocument (because it can't load such resource except when on localhost). Inversely, TRML and WKHTML might have problems when it is not a file: URI.

        It's probably best to have a default setting of '%(static)s/logo.png' and then the various document converters can fill that in either with settings.STATIC_ROOT or settings.STATIC_URL. This is not exactly critical (right now, changing the setting accordingly to one's setup makes everything work) but it might make things easier for newcomers.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.