Showing 3 changed files with 28 additions and 5 deletions
+6 -1
lib/Gitprep/Manager.pm
... ...
@@ -137,12 +137,17 @@ sub members {
137 137
 sub create_project {
138 138
   my ($self, $user, $project, $opts) = @_;
139 139
   
140
+  my $params = {};
141
+  if ($opts->{private}) {
142
+    $params->{private} = 1;
143
+  }
144
+  
140 145
   # Create project
141 146
   my $dbi = $self->app->dbi;
142 147
   my $error;
143 148
   eval {
144 149
     $dbi->connector->txn(sub {
145
-      eval { $self->_create_project($user, $project) };
150
+      eval { $self->_create_project($user, $project, $params) };
146 151
       croak $error = $@ if $@;
147 152
       eval {$self->_create_rep($user, $project, $opts) };
148 153
       croak $error = $@ if $@;
+15 -4
templates/auto/_new.html.ep
... ...
@@ -22,11 +22,14 @@
22 22
         ['not_blank' => 'Repository name is empty'],
23 23
         ['project_name' => 'Invalid repository name']
24 24
       ],
25
-      description => [
25
+      description => {require => 0} => [
26 26
         'any'
27 27
       ],
28 28
       readme => {require => 0} => [
29 29
         'any'
30
+      ],
31
+      private => {require => 0} => [
32
+        'any'
30 33
       ]
31 34
     ];
32 35
     my $validator = app->validator;
... ...
@@ -44,7 +47,9 @@
44 47
       my $user = session('user');
45 48
       my $project = $data->{project};
46 49
       my $description = $data->{description};
50
+      $description = '' unless defined $description;
47 51
       my $readme = $data->{readme};
52
+      my $private = $data->{private};
48 53
       
49 54
       my $manager = app->manager;
50 55
       if ($manager->exists_project($user, $project)) {
... ...
@@ -56,7 +61,7 @@
56 61
           $manager->create_project(
57 62
             $user,
58 63
             $project,
59
-            {description => $description, readme => $readme}
64
+            {description => $description, readme => $readme, private => $private}
60 65
           );
61 66
         };
62 67
         
... ...
@@ -106,9 +111,15 @@
106 111
           <%= check_box readme => 1 %><b>Initialize this repository with a README</b>
107 112
         </label>
108 113
       </div>
109
-      <div class="muted" style="margin-bottom:10px;margin-left:20px">This will allow you to git clone the repository immediately.</div>
114
+      <div class="muted" style="margin-left:20px">This will allow you to git clone the repository immediately.</div>
110 115
 
111
-      <input type="submit" class="btn" value="Create repository">
116
+      <div>
117
+        <label class="checkbox" style="margin-bottom:0">
118
+          <%= check_box private => 1 %><b>Make this repository private </b>
119
+        </label>
120
+      </div>
121
+            
122
+      <input style="margin-top:10px" type="submit" class="btn" value="Create repository">
112 123
     </form>
113 124
   </div>
114 125
   %= include '/include/footer';
+7
xt/user.t
... ...
@@ -329,6 +329,11 @@ note 'Profile';
329 329
     # Settings page(has README)
330 330
     $t->get_ok('/kimoto1/t2/settings');
331 331
     $t->content_like(qr/Settings/);
332
+
333
+    # Create repository(with private)
334
+    $t->post_ok('/_new?op=create', form => {project => 't_private', private => 1});
335
+    $t->content_like(qr/t_private\.git/);
336
+    $t->content_like(qr/icon-lock/);
332 337
   }
333 338
   
334 339
   note 'Project settings';
... ...
@@ -388,6 +393,8 @@ note 'Profile';
388 393
   }
389 394
 }
390 395
 
396
+__END__
397
+
391 398
 note 'fork';
392 399
 {
393 400
   my $app = Gitprep->new;