 
   if format[1] is "jpg" or format[1] is "jpeg" or format[1] is "png" or format[1] is "gif"
     fs.rename req.files.image.path, path, (err) ->
-      
+
 
       Deal.findOne({_id: req.body.id}).exec (err, deal) ->
 

exports.delete = (req, res) ->
  shopId = req.session.currentShop.shopId
  dealId = req.params.dealId
  
  Deal.findOne({_id: req.params.dealId}).exec (err, deal) ->
   
    res.render 'pages/shopmanagement/deals/delete',
      {
        deal: deal,

            else
              console.log err
              res.redirect 'shopmanagement/deals/list'

   else
    fs.unlink file.path
    res.render "pages/shopmanagement/deals/edit",
    {errorMsg: 'El formato debe ser jpg, png o gif', deal: dealId, currentShop: req.session.currentShop}

exports.edit = (req, res) ->
  shopId = req.session.currentShop.shopId
  dealId = req.params.dealId

  Deal.findOne({_id: req.params.dealId}).exec( (err, deal) ->

    DealCategory.find().sort('name').exec( (err, categories ) ->
      res.render 'pages/shopmanagement/deals/create',
        {
