alerts.html 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. {% extends "cranefly/layout.html" %}
  2. {% load i18n %}
  3. {% import "cranefly/macros.html" as macros with context %}
  4. {% block title %}{% if user.alerts -%}
  5. {{ macros.page_title(title=get_title(),parent=_('Your Notifications')) }}
  6. {%- else -%}
  7. {{ macros.page_title(title=get_title()) }}
  8. {%- endif %}{% endblock %}
  9. {% block container %}
  10. <div class="page-header header-primary">
  11. <div class="container">
  12. {{ messages_list(messages) }}
  13. <h1>{% if user.alerts %}{{ get_title() }} <small>{% trans %}Your Notifications{% endtrans %}</small>
  14. {%- else -%}
  15. {% trans %}Your Notifications{% endtrans %}{% endif %}</h1>
  16. </div>
  17. </div>
  18. <div class="container container-primary">
  19. {% if alerts %}
  20. <div class="user-alerts">
  21. {% if alerts.today %}{{ alerts_list(_("Today Notifications"), alerts.today) }}{% endif %}
  22. {% if alerts.yesterday %}{{ alerts_list(_("Yesterday Notifications"), alerts.yesterday) }}{% endif %}
  23. {% if alerts.week %}{{ alerts_list(_("This Week"), alerts.week) }}{% endif %}
  24. {% if alerts.month %}{{ alerts_list(_("This Month"), alerts.month) }}{% endif %}
  25. {% if alerts.older %}{{ alerts_list(_("Older Notifications"), alerts.older) }}{% endif %}
  26. </div>
  27. {% else %}
  28. <p class="lead">{% trans %}Looks like you don't have any notifications... yet.{% endtrans %}</p>
  29. {% endif %}
  30. </div>
  31. {% endblock %}
  32. {% macro get_title() -%}
  33. {% if new_alerts -%}
  34. {% trans count=new_alerts -%}
  35. You have one new alert
  36. {%- pluralize -%}
  37. You have {{ count }} new alerts
  38. {%- endtrans %}
  39. {%- else -%}
  40. {% trans %}Your Notifications{% endtrans %}
  41. {%- endif %}
  42. {%- endmacro %}
  43. {% macro alerts_list(title, alerts) %}
  44. <table class="table table-striped">
  45. <thead>
  46. <tr>
  47. <th style="width: 1%;">&nbsp;</th>
  48. <th colspan="2">{{ title }}</th>
  49. </tr>
  50. </thead>
  51. <tbody>
  52. {% for alert in alerts %}
  53. <tr>
  54. <td class="alert-icon"><span class="label {% if alert.new %} label-warning{% endif %} tooltip-top" title="{% if alert.new %}{% trans %}New notification{% endtrans %}{% else %}{% trans %}Old notification{% endtrans %}{% endif %}"><i class="icon-fire"></i></label></td>
  55. <td class="alert-message">{{ (_(alert.message) % alert.vars())|safe }}</td>
  56. <td class="alert-date">{{ alert.date|reltimesince }}</td>
  57. </tr>
  58. {% endfor %}
  59. </tbody>
  60. </table>
  61. {% endmacro %}