@@ -157,10 +157,10 @@ app.get('/decline/:pid/:uid', function(req, res){
157157app . post ( '/projects/new' , isAuth , function ( req , res ) {
158158 if ( req . body . title && req . body . description ) {
159159 var hash = Math . floor ( Math . random ( ) * 9999999 + 1 ) ;
160- console . log ( req . body ) ;
161160 var project = {
162161 id : hash
163162 , title : req . body . title
163+ , created_at : Date . now ( )
164164 , owner_id : req . user . id
165165 , owner_username : req . user . username
166166 , description : req . body . description
@@ -214,9 +214,16 @@ app.post('/projects/edit/:id', isAuth, isOwner, function(req, res){
214214} ) ;
215215
216216app . get ( '/projects/remove/:id' , isAuth , isOwner , function ( req , res ) {
217- client . del ( 'hhba:projects:' + req . params . id , function ( err ) {
218- res . redirect ( '/dashboard' ) ;
219- search . remove ( req . params . id ) ;
217+ client . get ( 'hhba:projects:' + req . params . id , function ( err , project ) {
218+ project = JSON . parse ( project ) ;
219+ if ( project . contributors . length == 1 ) {
220+ client . del ( 'hhba:projects:' + req . params . id , function ( err ) {
221+ res . redirect ( '/dashboard' ) ;
222+ search . remove ( req . params . id ) ;
223+ } ) ;
224+ } else {
225+ res . redirect ( '/dashboard' ) ;
226+ }
220227 } ) ;
221228} ) ;
222229
@@ -234,7 +241,7 @@ app.get('/search', function(req, res){
234241 return ! ! project ;
235242 } ) ;
236243 var user = req . user || { 'username' : '' } ;
237- res . render ( 'dashboard' , { projects : projects , user : user } ) ;
244+ res . render ( 'dashboard' , { projects : projects , user : user , q : req . query . q } ) ;
238245 } ) ;
239246 } ) ;
240247} ) ;
0 commit comments