         form = $el.find("form").checksley({"onlyOneErrorElement": true})
 
         onSuccessSubmit = (response) ->
+            # remove all $http cache
+            # This is necessary when a project is created with the same name
+            # than another deleted in the same session
+            $cacheFactory.get('$http').removeAll()
+
             $rootscope.$broadcast("projects:reload")
             $confirm.notify("success", "Success") #TODO: i18n
             $location.url($projectUrl.get(response))

    return {link:link}

module.directive("tgLbCreateProject", ["$rootScope", "$tgRepo", "$tgConfirm", "$location", "$tgNavUrls",
                                       "$tgResources", "$projectUrl", "lightboxService", CreateProject])


#############################################################################


module = angular.module("taigaProject")

CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $projectUrl, lightboxService, $cacheFactory) ->
    link = ($scope, $el, attrs) ->
        $scope.data = {}
        $scope.templates = []
