Newer Older
132 lines | 3.611kb
cleanup many pages
Yuki Kimoto authored on 2013-03-31
1
<%
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
2
  my $op = param('op') || '';
3
  my $api = gitprep_api;
4
  
5
  my $errors;
6
  if ($op eq 'delete' && lc $self->req->method eq 'post') {
7
    
cleanup users validation
Yuki Kimoto authored on 2016-02-09
8
    # Parameters
9
    my $user = param('user');
10
    
11
    # Validator
12
    my $vc = app->vc;
13
    
14
    # Validation result
15
    my $validation = $vc->validation;
16
    
17
    # "user" check
18
    if (!(defined $user && length $user)) {
19
      $validation->add_failed(user => 'User name is empty.');
20
    }
21

            
22
    if ($validation->is_valid) {
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
23
      
24
      # Delete user
added delete user test
Yuki Kimoto authored on 2013-05-18
25
      my $count;
revert encoding support
Yuki Kimoto authored on 2013-11-22
26
      eval { $count = app->manager->delete_user($user) };
improve error message
Yuki Kimoto authored on 2014-02-13
27
      if (my $e = $@) {
28
        app->log->error(url_for . ": $e");
added delete user test
Yuki Kimoto authored on 2013-05-18
29
        $errors = ['Internal Error'];
30
      }
31
      elsif ($count == 0) {
32
        app->log->error("/_admin/users?op=delete: User $user not exists");
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
33
        $errors = ['Internal Error'];
34
      }
35
      else {
added delete user test
Yuki Kimoto authored on 2013-05-18
36
        $self->flash(message => "User $user is deleted.");
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
37
        $self->redirect_to('current');
added delete user test
Yuki Kimoto authored on 2013-05-18
38
        return;
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
39
      }
40
    }
cleanup users validation
Yuki Kimoto authored on 2016-02-09
41
    else { $errors = $validation->messages }
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
42
  }
43
  
display user name and mail i...
Yuki Kimoto authored on 2016-04-07
44
  my $users = app->dbi->model('user')->select(
45
    where => {admin => 0},
46
    append => 'order by id'
47
  )->all;
cleanup many pages
Yuki Kimoto authored on 2013-03-31
48
%>
49

            
add title
Yuki Kimoto authored on 2013-06-12
50
% layout 'common', title => 'Admin Users';
cleanup many pages
Yuki Kimoto authored on 2013-03-31
51

            
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
52
  %= javascript begin
53
    $(document).ready(function () {
54
      
55
      // Confirm delete
56
      $('.delete-btn').on('click', function () {
57
        var user = $(this).attr('user');
58
        
59
        var input = window.prompt(
60
          'Are you really delete user "' + user
61
          + '". User and user\'s all repositories are deleted. Please input user name.'
62
        );
63
        
64
        if (user === input) {
65
          return true;
66
        }
67
        else {
68
          return false;
69
        }
70
      });
71
    });
72
  % end
73

            
cleanup many pages
Yuki Kimoto authored on 2013-03-31
74
  %= include '/include/header';
75

            
76
  <div class="container">
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
77

            
78
    % if (my $message = flash('message')) {
added user delete feature
Yuki Kimoto authored on 2013-04-09
79
      <div class="alert alert-success">
80
        <button type="button" class="close" data-dismiss="alert">&times;</button>
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
81
        %= $message;
82
      </div>
83
    % }
84
    
85
    % if ($errors) {
86
      <div class="alert">
87
        <button type="button" class="close" data-dismiss="alert">&times;</button>
88
        % for my $error (@$errors) {
89
          <p><%= $error %></p>
90
        % }
added user delete feature
Yuki Kimoto authored on 2013-04-09
91
      </div>
92
    % }
93
    
improve admin users page des...
Yuki Kimoto authored on 2016-01-23
94
    <h3 class="topic1">Admin Users</h3>
fixed link bugs
Yuki Kimoto authored on 2013-04-21
95
    <div style="margin-bottom:10px"><a class="btn" href="<%= url_for('/_admin/user/create') %>">Create User</a></div>
cleanup many pages
Yuki Kimoto authored on 2013-03-31
96
    <div class="container">
display user name and mail i...
Yuki Kimoto authored on 2016-04-07
97
      <table class="admin-users">
98
        <tr>
99
          <th>ID</th>
100
          <th>Name</th>
101
          <th>Mail</th>
102
          <th></th>
103
        </tr>
added reset password feature
Yuki Kimoto authored on 2013-04-10
104
        % for my $user (@$users) {
display user name and mail i...
Yuki Kimoto authored on 2016-04-07
105
          <tr>
106
            % my $uid = $user->{id};
107
            <td>
added reset password feature
Yuki Kimoto authored on 2013-04-10
108
              <a href="#"><%= $uid %></a>
display user name and mail i...
Yuki Kimoto authored on 2016-04-07
109
            </td>
110
            <td>
111
              <%= $user->{name} %>
112
            </td>
113
            <td>
fix mail bug
Yuki Kimoto authored on 2016-04-21
114
              <%= $user->{email} %>
display user name and mail i...
Yuki Kimoto authored on 2016-04-07
115
            </td>
116
            <td>
add user update page
Yuki Kimoto authored on 2016-04-07
117
              <a class="btn btn-small" href="<%= url_for('/_admin/user/update')->query(id => $uid) %>">Settings</a>
118
              <a class="btn btn-small" href="<%= url_for('/reset-password')->query(user => $uid) %>">Reset Password</a>
improve admin users page des...
Yuki Kimoto authored on 2016-01-23
119
              <form action="<%= url_for->query(op => 'delete') %>" method="post">
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
120
                %= hidden_field user => $uid;
add user update page
Yuki Kimoto authored on 2016-04-07
121
                <input type="submit" class="btn btn-small delete-btn" style="color:red" user="<%= $uid %>" value="Delete">
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
122
              </form>
display user name and mail i...
Yuki Kimoto authored on 2016-04-07
123
            </td>
124
          </tr>
added reset password feature
Yuki Kimoto authored on 2013-04-10
125
        % }
126
      </table>
cleanup many pages
Yuki Kimoto authored on 2013-03-31
127
    </div>
128
  </div>
improve admin users page des...
Yuki Kimoto authored on 2016-01-23
129
  <div style="text-align:center;margin:20px 0"><big><a href="<%= url_for('/_admin') %>">Admin page</a></big></div>
cleanup many pages
Yuki Kimoto authored on 2013-03-31
130
  
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
131
  %= include '/include/footer';
132