gitprep / templates / fork.html.ep /
Newer Older
37 lines | 0.952kb
added fork feature
Yuki Kimoto authored on 2013-03-29
1
<%
add fork test
Yuki Kimoto authored on 2013-05-25
2
  # API
added fork feature
Yuki Kimoto authored on 2013-03-29
3
  my $api = gitprep_api;
4
  
fix session
Yuki Kimoto authored on 2016-04-21
5
  # Parameters
6
  my $user_id = param('user');
7
  my $project_id = param('project');
8
  my $session_user_row_id = session('user_row_id');
9
  my $session_user = app->dbi->model('user')->select(
10
    where => {row_id => $session_user_row_id}
11
  )->one;
added fork feature
Yuki Kimoto authored on 2013-03-29
12
  
add fork test
Yuki Kimoto authored on 2013-05-25
13
  # Can fork?
14
  unless ($api->logined) {
15
    $self->redirect_to('/');
16
    return;
17
  }
18
  
19
  # Repository is already exists
fix session
Yuki Kimoto authored on 2016-04-21
20
  if (app->manager->exists_project($session_user->{id}, $project_id)) {
21
    $self->redirect_to("/$session_user->{id}/$project_id");
add fork test
Yuki Kimoto authored on 2013-05-25
22
    return;
23
  }
24
  # Fork
25
  else {
fix session
Yuki Kimoto authored on 2016-04-21
26
    eval { app->manager->fork_project($session_user->{id}, $user_id, $project_id) };
improve error message
Yuki Kimoto authored on 2014-02-13
27
    if (my $e = $@) {
do success xt tests
Yuki Kimoto authored on 2016-03-25
28
      $self->reply->exception('Internal Error');
improve error message
Yuki Kimoto authored on 2014-02-13
29
      app->log->error(url_for . ": $e");
added fork feature
Yuki Kimoto authored on 2013-03-29
30
    }
31
    else {
fix session
Yuki Kimoto authored on 2016-04-21
32
      flash(message => "Repository is forked from /$user_id/$project_id.");
33
      $self->redirect_to("/$session_user->{id}/$project_id");
added fork feature
Yuki Kimoto authored on 2013-03-29
34
    }
fixed bug that fork return e...
Yuki Kimoto authored on 2013-05-13
35
    return;
added fork feature
Yuki Kimoto authored on 2013-03-29
36
  }
37
%>