... | ... |
@@ -209,8 +209,9 @@ sub is_private_project { |
209 | 209 |
my $user_row_id = $self->api->get_user_row_id($user_id); |
210 | 210 |
|
211 | 211 |
# Is private |
212 |
- my $private = $self->app->dbi->model('project') |
|
213 |
- ->select('private', where => {user => $user_row_id, project_id => $project_id})->value; |
|
212 |
+ my $private = $self->app->dbi->model('project')->select( |
|
213 |
+ 'private', where => {user => $user_row_id, id => $project_id} |
|
214 |
+ )->value; |
|
214 | 215 |
|
215 | 216 |
return $private; |
216 | 217 |
} |
... | ... |
@@ -5,10 +5,12 @@ |
5 | 5 |
|
6 | 6 |
# Parameters |
7 | 7 |
my $op = param('op') || ''; |
8 |
- my $user = param('user') || ''; |
|
8 |
+ my $user_id = param('user') || ''; |
|
9 |
+ my $user_row_id = $api->get_user_row_id($user_id); |
|
10 |
+ my $project_id = param('project'); |
|
9 | 11 |
|
10 | 12 |
# Authentication |
11 |
- unless ($api->logined($user)) { |
|
13 |
+ unless ($api->logined($user_id)) { |
|
12 | 14 |
$self->redirect_to('/'); |
13 | 15 |
return; |
14 | 16 |
} |
... | ... |
@@ -35,20 +37,20 @@ |
35 | 37 |
elsif (!$vc->check($to_project, 'project_name')) { |
36 | 38 |
$validation->add_failed('to-project' => 'Repository name contains invalid charactor.'); |
37 | 39 |
} |
38 |
- elsif (app->manager->exists_project($user, $to_project)) { |
|
40 |
+ elsif (app->manager->exists_project($user_id, $to_project)) { |
|
39 | 41 |
$validation->add_failed('to-project' => "$to_project is already exists"); |
40 | 42 |
} |
41 | 43 |
|
42 | 44 |
if ($validation->is_valid) { |
43 | 45 |
# Rename |
44 |
- eval { app->manager->rename_project($user, $project, $to_project) }; |
|
46 |
+ eval { app->manager->rename_project($user_id, $project_id, $to_project) }; |
|
45 | 47 |
if (my $e = $@) { |
46 | 48 |
app->log->error($e); |
47 | 49 |
$errors = ['Internal Error']; |
48 | 50 |
} |
49 | 51 |
else { |
50 | 52 |
flash(message => "Repository name is renamed to $to_project"); |
51 |
- $self->redirect_to("/$user/$to_project/settings"); |
|
53 |
+ $self->redirect_to("/$user_id/$to_project/settings"); |
|
52 | 54 |
return; |
53 | 55 |
} |
54 | 56 |
} |
... | ... |
@@ -60,9 +62,9 @@ |
60 | 62 |
my $description = param('description'); |
61 | 63 |
$description = '' unless defined $description; |
62 | 64 |
|
63 |
- eval { $git->description(app->rep_info($user, $project), $description) }; |
|
65 |
+ eval { $git->description(app->rep_info($user_id, $project_id), $description) }; |
|
64 | 66 |
if (my $e = $@) { |
65 |
- app->log->error("/$user/$project/settings?op=description: $e"); |
|
67 |
+ app->log->error("/$user_id/$project_id/settings?op=description: $e"); |
|
66 | 68 |
$errors = ['Internal Error']; |
67 | 69 |
} |
68 | 70 |
else { |
... | ... |
@@ -99,12 +101,12 @@ |
99 | 101 |
eval { |
100 | 102 |
$dbi->model('project')->update( |
101 | 103 |
$params, |
102 |
- where => {user_id => $user, name => $project} |
|
104 |
+ where => {user => $user_row_id, id => $project_id} |
|
103 | 105 |
); |
104 | 106 |
}; |
105 | 107 |
|
106 | 108 |
if (my $e = $@) { |
107 |
- app->log->error("/$user/$project/settings?op=save-settings: $e"); |
|
109 |
+ app->log->error("/$user_id/$project_id/settings?op=save-settings: $e"); |
|
108 | 110 |
$errors = ['Internal Error']; |
109 | 111 |
} |
110 | 112 |
else { |
... | ... |
@@ -117,17 +119,17 @@ |
117 | 119 |
# Delete project |
118 | 120 |
elsif ($op eq 'delete-project') { |
119 | 121 |
|
120 |
- my $user = param('user'); |
|
121 |
- my $project = param('project'); |
|
122 |
+ my $user_id = param('user'); |
|
123 |
+ my $project_id = param('project'); |
|
122 | 124 |
|
123 |
- eval { app->manager->delete_project($user, $project) }; |
|
125 |
+ eval { app->manager->delete_project($user_id, $project_id) }; |
|
124 | 126 |
if (my $e = $@) { |
125 |
- app->log->error("/$user/$project/settings: $e"); |
|
127 |
+ app->log->error("/$user_id/$project_id/settings: $e"); |
|
126 | 128 |
$errors = ['Internal Error']; |
127 | 129 |
} |
128 | 130 |
else { |
129 |
- flash(message => "Repository $project is deleted."); |
|
130 |
- $self->redirect_to("/$user"); |
|
131 |
+ flash(message => "Repository $project_id is deleted."); |
|
132 |
+ $self->redirect_to("/$user_id"); |
|
131 | 133 |
return; |
132 | 134 |
} |
133 | 135 |
} |
... | ... |
@@ -148,7 +150,7 @@ |
148 | 150 |
// Check matching deleted project |
149 | 151 |
$('input[name="deleted-project"]').on('keyup', function () { |
150 | 152 |
var deleted_project = $(this).val(); |
151 |
- var project = "<%= $project %>"; |
|
153 |
+ var project = "<%= $project_id %>"; |
|
152 | 154 |
|
153 | 155 |
if (deleted_project == project) { |
154 | 156 |
$('#delete').attr('class', 'btn btn-danger') |
... | ... |
@@ -177,7 +179,7 @@ |
177 | 179 |
<div class="left"> |
178 | 180 |
<ul> |
179 | 181 |
<li><b>Options</b></li> |
180 |
- <li><a href="<%= url_for("/$user/$project/settings/collaboration") %>">Collaborators</a></li> |
|
182 |
+ <li><a href="<%= url_for("/$user_id/$project_id/settings/collaboration") %>">Collaborators</a></li> |
|
181 | 183 |
</ul> |
182 | 184 |
</div> |
183 | 185 |
<div class="right"> |
... | ... |
@@ -191,7 +193,7 @@ |
191 | 193 |
<li> |
192 | 194 |
<form id="form-rename-project" action="<%= url_for->query(op => 'rename-project') %>" method="post"> |
193 | 195 |
<div> |
194 |
- %= text_field 'to-project' => $project, style => "width:80%"; |
|
196 |
+ %= text_field 'to-project' => $project_id, style => "width:80%"; |
|
195 | 197 |
<a href="#rename-confirm" role="button" class="btn" data-toggle="modal"> |
196 | 198 |
Rename |
197 | 199 |
</a> |
... | ... |
@@ -209,7 +211,7 @@ |
209 | 211 |
<li> |
210 | 212 |
<form action="<%= url_for->query(op => 'change-description') %>" method="post"> |
211 | 213 |
<div> |
212 |
- % my $description = $git->description(app->rep_info($user, $project)); |
|
214 |
+ % my $description = $git->description(app->rep_info($user_id, $project_id)); |
|
213 | 215 |
% $description = '' unless defined $description; |
214 | 216 |
%= text_field 'description' => $description, style => "width:90%"; |
215 | 217 |
<input type="submit" class="btn" value="Save"> |
... | ... |
@@ -229,9 +231,9 @@ |
229 | 231 |
<li id="default-branch"> |
230 | 232 |
Default Branch |
231 | 233 |
<% |
232 |
- my $branches = $git->branches($self->app->rep_info($user, $project)); |
|
234 |
+ my $branches = $git->branches($self->app->rep_info($user_id, $project_id)); |
|
233 | 235 |
my $branch_names = [map { $_->{name} } @$branches]; |
234 |
- my $default_branch = app->manager->default_branch($user, $project); |
|
236 |
+ my $default_branch = app->manager->default_branch($user_id, $project_id); |
|
235 | 237 |
push @$branch_names, $default_branch unless @$branch_names; |
236 | 238 |
param('default-branch', $default_branch); |
237 | 239 |
%> |
... | ... |
@@ -239,18 +241,16 @@ |
239 | 241 |
</li> |
240 | 242 |
<li> |
241 | 243 |
<span>Make this repository private</span> |
242 |
- % my $private = app->manager->is_private_project($user, $project); |
|
243 |
- % if ($private) { |
|
244 |
- % param('private', 1); |
|
245 |
- % } |
|
244 |
+ % my $private = app->manager->is_private_project($user_id, $project_id); |
|
245 |
+ % my @private_checked = $private ? (checked => undef) : (); |
|
246 | 246 |
%= hidden_field 'private' => 0; |
247 |
- %= check_box 'private' => 1; |
|
247 |
+ %= check_box 'private' => 1, @private_checked; |
|
248 | 248 |
</li> |
249 | 249 |
<li> |
250 | 250 |
<% |
251 | 251 |
my $ignore_space_change = app->dbi->model('project')->select( |
252 | 252 |
'ignore_space_change', |
253 |
- where => {user_id => $user, name => $project} |
|
253 |
+ where => {user => $user_row_id, id => $project_id} |
|
254 | 254 |
)->value; |
255 | 255 |
my @ignore_space_change_checked = $ignore_space_change ? (checked => undef) : (); |
256 | 256 |
%> |
... | ... |
@@ -263,7 +263,7 @@ |
263 | 263 |
<% |
264 | 264 |
my $guess_encoding = app->dbi->model('project')->select( |
265 | 265 |
'guess_encoding', |
266 |
- where => {user_id => $user, name => $project} |
|
266 |
+ where => {user => $user_row_id, id => $project_id} |
|
267 | 267 |
)->value; |
268 | 268 |
%> |
269 | 269 |
<div>Guess encoding</div> |
... | ... |
@@ -291,8 +291,8 @@ |
291 | 291 |
<a style="color:red" href="#delete-confirm" role="button" class="btn" data-toggle="modal"> |
292 | 292 |
Delete this repository |
293 | 293 |
</a> |
294 |
- %= hidden_field user => $user; |
|
295 |
- %= hidden_field project => $project; |
|
294 |
+ %= hidden_field user => $user_id; |
|
295 |
+ %= hidden_field project => $project_id; |
|
296 | 296 |
</form> |
297 | 297 |
</li> |
298 | 298 |
</ul> |
... | ... |
@@ -344,11 +344,11 @@ |
344 | 344 |
Unexpected bad things will happen if you don't read this. |
345 | 345 |
</p> |
346 | 346 |
<p> |
347 |
- This action <b>CANNOT</b> be undone. This will delete the <b><%= "$user/$project" %></b> |
|
347 |
+ This action <b>CANNOT</b> be undone. This will delete the <b><%= "$user_id/$project_id" %></b> |
|
348 | 348 |
repository, wiki, issues, and comments permanently. |
349 | 349 |
</p> |
350 | 350 |
<p> |
351 |
- Please type in the name of the repository(<b><%= $project %></b>) to confirm. |
|
351 |
+ Please type in the name of the repository(<b><%= $project_id %></b>) to confirm. |
|
352 | 352 |
</p> |
353 | 353 |
%= text_field 'deleted-project'; |
354 | 354 |
</div> |