/[transports]/trunk/web/templates/fragments/transports
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/web/templates/fragments/transports

Parent Directory Parent Directory | Revision Log Revision Log


Revision 46 - (hide annotations)
Tue May 30 18:09:51 2006 UTC (17 years, 11 months ago) by dpavlin
File size: 2082 byte(s)
bunch of changes:
- added import operator user role (user_object->can_import),
  added import transort which sets return_code and optional comment - it can
  be executed by import operators or admins
- import operators will get just transports which aren't imported under /transports
1 dpavlin 37 <%args>
2     $page => 1
3     </%args>
4     <%init>
5     my $transports = Transports::Model::TransportCollection->new();
6 dpavlin 43 if (Jifty->web->current_user->admin) {
7     $transports->unlimit();
8 dpavlin 46 } elsif (Jifty->web->current_user->can_import) {
9     $transports->limit(
10     column => 'return_code',
11     value => 'null',
12     operator => 'is',
13     );
14 dpavlin 43 } else {
15     $transports->limit(
16     column => 'created_by',
17     value => Jifty->web->current_user->id,
18 dpavlin 46 );
19 dpavlin 43 }
20 dpavlin 37 $transports->order_by({ column => 'date' });
21     $transports->set_page_info(
22     current_page => $page,
23     per_page => 5,
24     );
25 dpavlin 46 if (my $nr = $transports->pager->total_entries) {
26     $m->out("Showing $nr transports.")
27     } else {
28     $m->out("No transports found.")
29     }
30 dpavlin 37 </%init>
31    
32     <table>
33     <tr>
34 dpavlin 45 <th>src</th>
35     <th>dest</th>
36     <th>class</th>
37     <th>req.nr</th>
38     <th>dep</th>
39 dpavlin 37 <th>created by</th>
40 dpavlin 45 <th>description</th>
41 dpavlin 46 <th>import</th>
42 dpavlin 43 % if (Jifty->web->current_user->admin) {
43 dpavlin 37 <th>&nbsp;</th>
44 dpavlin 43 % }
45 dpavlin 37 </th>
46     </tr>
47    
48     % my $i = 0;
49     % while (my $t = $transports->next) {
50     <tr class="<% ++$i % 2 == 0 ? 'alt' : '' %>">
51     <td><% $t->source->name %></td>
52     <td><% $t->destination->name %></td>
53 dpavlin 45 <td><% $t->class->name %></td>
54 dpavlin 37 <td><tt><% $t->request_nr %></tt></td>
55     <td>
56     <% $t->client_dependent ? 'client' : 'none' %>
57     </td>
58     <td>
59     % if ($t->created_by) {
60     <em><% $t->created_by->name %></em>
61     % }
62     </td>
63 dpavlin 45 <td><% $t->description %></td>
64 dpavlin 46 <td>
65     % if ($t->return_code) {
66     <% $t->return_code->name %>
67     % } elsif (Jifty->web->current_user->can_import) {
68     <% Jifty->web->link( label => 'import', url => '/import/' . $t->id ) %>
69     % } else {
70     pending
71     % }
72     </td>
73 dpavlin 45 % if (Jifty->web->current_user->admin) {
74 dpavlin 39 <td><% Jifty->web->link( label => 'edit', url => '/edit/' . $t->id ) %></td>
75 dpavlin 45 % }
76 dpavlin 37 </tr>
77     % }
78     </table>
79    
80     % if ($transports->pager->previous_page) {
81     <% Jifty->web->link(
82     label => "Previous page",
83     onclick => { args => { page => $transports->pager->previous_page } }
84     ) %>
85     % }
86    
87     % if ($transports->pager->last_page > 1) {
88     page <% $page %> of <% $transports->pager->last_page %>
89     % }
90    
91     % if ($transports->pager->next_page) {
92     <% Jifty->web->link(
93     label => "Next page",
94     onclick => { args => { page => $transports->pager->next_page } }
95     ) %>
96     % }
97    

  ViewVC Help
Powered by ViewVC 1.1.26