Mitja Nikolaus | 6a67913 | 2018-08-30 14:35:29 +0200 | [diff] [blame] | 1 | """Django template tags for crashreport statistics.""" |
| 2 | |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 3 | from django.template import Library, loader |
Dirk Vogt | 62ff7f2 | 2017-05-04 16:07:21 +0200 | [diff] [blame] | 4 | |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 5 | |
| 6 | register = Library() |
Dirk Vogt | 62ff7f2 | 2017-05-04 16:07:21 +0200 | [diff] [blame] | 7 | |
Dirk Vogt | 62ff7f2 | 2017-05-04 16:07:21 +0200 | [diff] [blame] | 8 | |
| 9 | @register.simple_tag |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 10 | def device_overview( |
| 11 | title="General Information", uuid="e1c0cc95-ab8d-461a-a768-cb8d9d7adb04" |
| 12 | ): |
Mitja Nikolaus | 6a67913 | 2018-08-30 14:35:29 +0200 | [diff] [blame] | 13 | """Render general device information.""" |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 14 | template = loader.get_template( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 15 | "crashreport_stats/tags/device_overview.html" |
| 16 | ) |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 17 | return template.render( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 18 | {"uuid": uuid, "title": title, "element_name": "device_overview"} |
| 19 | ) |
Dirk Vogt | 1accb67 | 2017-05-10 14:07:42 +0200 | [diff] [blame] | 20 | |
| 21 | |
| 22 | @register.simple_tag |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 23 | def device_crashreport_table( |
| 24 | title="Crashreports", uuid="e1c0cc95-ab8d-461a-a768-cb8d9d7adb04" |
| 25 | ): |
Mitja Nikolaus | 6a67913 | 2018-08-30 14:35:29 +0200 | [diff] [blame] | 26 | """Render device crashreport table.""" |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 27 | template = loader.get_template( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 28 | "crashreport_stats/tags/device_crashreport_table.html" |
| 29 | ) |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 30 | return template.render( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 31 | { |
| 32 | "uuid": uuid, |
| 33 | "title": title, |
| 34 | "element_name": "device_crashreport_table", |
| 35 | } |
| 36 | ) |
| 37 | |
Dirk Vogt | 1accb67 | 2017-05-10 14:07:42 +0200 | [diff] [blame] | 38 | |
| 39 | @register.simple_tag |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 40 | def device_update_history( |
| 41 | title="Update History", uuid="e1c0cc95-ab8d-461a-a768-cb8d9d7adb04" |
| 42 | ): |
Mitja Nikolaus | 6a67913 | 2018-08-30 14:35:29 +0200 | [diff] [blame] | 43 | """Render device update history.""" |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 44 | template = loader.get_template( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 45 | "crashreport_stats/tags/device_update_history.html" |
| 46 | ) |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 47 | return template.render( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 48 | { |
| 49 | "uuid": uuid, |
| 50 | "title": title, |
| 51 | "element_name": "device_update_statistic", |
| 52 | } |
| 53 | ) |
| 54 | |
Dirk Vogt | 1accb67 | 2017-05-10 14:07:42 +0200 | [diff] [blame] | 55 | |
| 56 | @register.simple_tag |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 57 | def device_report_history( |
| 58 | title="Report History", uuid="e1c0cc95-ab8d-461a-a768-cb8d9d7adb04" |
| 59 | ): |
Mitja Nikolaus | 6a67913 | 2018-08-30 14:35:29 +0200 | [diff] [blame] | 60 | """Render device report history.""" |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 61 | template = loader.get_template( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 62 | "crashreport_stats/tags/device_report_history.html" |
| 63 | ) |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 64 | return template.render( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 65 | {"uuid": uuid, "title": title, "element_name": "device_report_history"} |
| 66 | ) |
| 67 | |
Dirk Vogt | 1accb67 | 2017-05-10 14:07:42 +0200 | [diff] [blame] | 68 | |
| 69 | @register.simple_tag |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 70 | def versions_table(title="FP2 OS Versions", is_official_release="1"): |
Mitja Nikolaus | 6a67913 | 2018-08-30 14:35:29 +0200 | [diff] [blame] | 71 | """Render versions table.""" |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 72 | template = loader.get_template("crashreport_stats/tags/versions_table.html") |
| 73 | return template.render( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 74 | { |
| 75 | "title": title, |
| 76 | "is_official_release": is_official_release, |
| 77 | "element_name": "versions_overview_table", |
| 78 | } |
| 79 | ) |
| 80 | |
| 81 | |
| 82 | @register.simple_tag |
| 83 | def versions_pie_chart( |
| 84 | title="FP2 Version Distribution", is_official_release="1" |
| 85 | ): |
Mitja Nikolaus | 6a67913 | 2018-08-30 14:35:29 +0200 | [diff] [blame] | 86 | """Render versions pie chart.""" |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 87 | template = loader.get_template( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 88 | "crashreport_stats/tags/versions_pie_chart.html" |
| 89 | ) |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 90 | return template.render( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 91 | { |
| 92 | "title": title, |
| 93 | "is_official_release": is_official_release, |
| 94 | "element_name": "versions_overview_pie_chart", |
| 95 | } |
| 96 | ) |
| 97 | |
| 98 | |
| 99 | @register.simple_tag |
| 100 | def versions_area_chart( |
| 101 | title="FP2 Version Distribution", is_official_release="1" |
| 102 | ): |
Mitja Nikolaus | 6a67913 | 2018-08-30 14:35:29 +0200 | [diff] [blame] | 103 | """Render versions area chart.""" |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 104 | template = loader.get_template( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 105 | "crashreport_stats/tags/versions_area_chart.html" |
| 106 | ) |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 107 | return template.render( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 108 | { |
| 109 | "title": title, |
| 110 | "is_official_release": is_official_release, |
| 111 | "element_name": "versions_overview_area_chart", |
| 112 | } |
| 113 | ) |
| 114 | |
| 115 | |
| 116 | @register.simple_tag |
| 117 | def versions_bar_chart(title="Version Stability", is_official_release="1"): |
Mitja Nikolaus | 6a67913 | 2018-08-30 14:35:29 +0200 | [diff] [blame] | 118 | """Render versions bar chart.""" |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 119 | template = loader.get_template( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 120 | "crashreport_stats/tags/versions_bar_chart.html" |
| 121 | ) |
Mitja Nikolaus | e7d3c76 | 2018-08-30 17:29:27 +0200 | [diff] [blame] | 122 | return template.render( |
Mitja Nikolaus | cb50f2c | 2018-08-24 13:54:48 +0200 | [diff] [blame] | 123 | { |
| 124 | "title": title, |
| 125 | "is_official_release": is_official_release, |
| 126 | "element_name": "versions_overview_bar_chart", |
| 127 | } |
| 128 | ) |