alerts.html 2.8 KB

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