Login

Snippets by shapiromatron

Snippet List

Template tag - list punctuation for a list of items

If you have multiple items in a list and want them to be displayed as human readable list of items, this will add the proper punctuation to generate the text. You'll need to provide a conjugation to the end of the list like "or" or "and"; it defaults to "or". Intended use: `{% for item in items %}{{item}}{% list_punctuation forloop "and" %}{% endfor %}` * If items was `['a']`; the template would return `a`. * If items was `['a', 'b']`; the template would return `a and b`. * If items was `['a', 'b', 'c']`; the template would return `a, b, and c`.

Read More

Middleware for fixing Microsoft Office (Word, Excel, Powerpoint) hyperlinks to views requiring authentication

Hyperlinks to views requiring authentication in Microsoft Office (Word, Excel, Powerpoint) can fail based on how Office handles rendering. This middleware sends a refresh return to the client, which will allow the page to be opened as normal, instead of the "Unable to open ... Cannot download the information you requested." This is a port from the ruby middleware project [fix microsoft links](https://github.com/spilliton/fix_microsoft_links). To enable, add to your [middleware stack](https://docs.djangoproject.com/en/dev/topics/http/middleware/) in the django project settings.

  • middleware
  • office
  • word
  • excel
  • powerpoint
Read More

shapiromatron has posted 2 snippets.