This repository was archived by the owner on Mar 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathhome.mako
More file actions
177 lines (170 loc) · 6.11 KB
/
home.mako
File metadata and controls
177 lines (170 loc) · 6.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# -*- coding: utf-8 -*-
<%inherit file="base.mako"/>
<%block name="header">
</%block>
<%block name="content">
<%
base_url = request.route_path('home')
priorities = [_('urgent'), _('high'), _('medium'), _('low')]
sorts = [('priority', 'asc', _('High priority first')),
('created', 'desc', _('Creation date')),
('last_update', 'desc', _('Last update'))]
%>
<div class="container">
<div class="col-md-6">
<h3>Projects</h3>
<%
qs = dict(request.GET)
sort_by = qs.get('sort_by', 'priority')
direction = qs.get('direction', 'asc')
button_text = ''
for sort in sorts:
if sort[0] == sort_by and sort[1] == direction:
button_text = sort[2]
endfor
%>
<form class="form-inline" role="form"
action="${request.current_route_url()}"
method="GET">
<div class="row">
<div class="col-md-12">
<input type="hidden" name="sort_by"
value="${request.params.get('sort_by', 'priority')}">
<input type="hidden" name="direction"
value="${request.params.get('direction', 'asc')}">
<div class="form-group left-inner-addon">
<i class="glyphicon glyphicon-search text-muted"></i>
<input type="search" class="form-control input-sm"
name="search" placeholder="${_('Search')}"
value="${request.params.get('search', '')}">
</div>
<div class="btn-group pull-right">
<button type="button" class="btn btn-default btn-sm dropdown-toggle"
data-toggle="dropdown">
${_('Sort by:')} <strong>${button_text}</strong>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
% for sort in sorts:
<%
qs['sort_by'] = sort[0]
qs['direction'] = sort[1]
%>
<li>
<a href="${request.current_route_url(_query=qs.items())}">
${sort[2]}
</a>
</li>
% endfor
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="checkbox input-sm pull-right">
<label>
<input type="checkbox" name="my_projects"
${'checked' if request.params.get('my_projects') == 'on' else ''}
onclick="this.form.submit();"> ${_('Your projects')}
</label>
</div>
</div>
</div>
</form>
% if paginator.items:
% for project in paginator.items:
${project_block(project=project, base_url=base_url,
priorities=priorities)}
% endfor
${paginator.pager()}
% endif
</div>
<div class="col-md-6">
<h3>${_('About the Tasking Manager')}</h3>
<p>
${_('OSM Tasking Manager is a mapping tool designed and built for the Humanitarian OSM Team collaborative mapping. The purpose of the tool is to divide up a mapping job into smaller tasks that can be completed rapidly. It shows which areas need to be mapped and which areas need the mapping validated. <br />This approach facilitates the distribution of tasks to the various mappers in a context of emergency. It also permits to control the progress and the homogeinity of the work done (ie. Elements to cover, specific tags to use, etc.).')|n}
</p>
</div>
</div>
</%block>
<%def name="project_block(project, base_url, priorities)">
<%
import markdown
import bleach
from sqlalchemy.orm import joinedload
from osmtm.models import DBSession, Project, ProjectTranslation
priority = priorities[project.priority]
project = DBSession.query(Project).\
options(joinedload(Project.translations[request.locale_name])).\
filter(Project.id == project.id).first()
if request.locale_name:
project.locale = request.locale_name
if project.status == project.status_archived:
status = 'Archived'
elif project.status == project.status_draft:
status = 'Draft'
else:
status = ''
%>
<div class="project well ${status.lower()}">
<ul class="nav project-stats">
<li>
<table>
<tr>
<%
locked = project.get_locked()
title = _('${locked} user(s) is (are) currently working on this project', mapping={'locked': locked})
%>
% if locked:
<td>
<span title="${title}" class="text-muted">
<span class="glyphicon glyphicon-user"></span>
${locked}
</span>
</td>
% endif
<td>
<div class="progress">
<div style="width: ${project.done}%;" class="progress-bar progress-bar-warning"></div>
<div style="width: ${project.validated}%;" class="progress-bar progress-bar-success"></div>
</div>
</td>
<td> ${project.done + project.validated}%</td>
</tr>
</table>
</li>
</ul>
<h4>
<a href="${base_url}project/${project.id}">#${project.id} ${project.name}
</a>
</h4>
<div class="clear"></div>
<div class="world_map">
% if project.area:
<%
from geoalchemy2 import shape
centroid = shape.to_shape(project.area.centroid)
%>
<div style="top: ${(-centroid.y + 90) * 60 / 180 - 1}px; left: ${(centroid.x + 180) * 120 / 360 - 1}px;" class="marker"></div>
% endif
</div>
${bleach.clean(markdown.markdown(project.short_description), strip=True) |n}
<div class="clear"></div>
<small class="text-muted">
% if project.private:
<span class="glyphicon glyphicon-lock"
title="${_('Access to this project is limited')}"></span> -
% endif
% if project.author:
<span>${_('Created by')} ${project.author.username}</span> -
% endif
<span>${_('Updated')} <span class="timeago" title="${project.last_update}Z"></span></span> -
<span>${_('Priority:')} ${priority}</span>
% if status:
- <span>${_(status)}</span>
% endif
</small>
</div>
</%def>