Fixing attachments permissions

stable
Alejandro Alonso 2014-08-07 13:29:22 +02:00
parent 9a1bf4fef2
commit 3ed3eaf99d
11 changed files with 30 additions and 7 deletions

View File

@ -209,7 +209,7 @@ AttachmentDirective = ($log, $repo, $confirm) ->
$ctrl = $el.controller()
render = (attachment, isEditable=false) ->
modifyPermission = $scope.project.my_permissions.indexOf("modify_#{$attrs.ngModel}") > -1
modifyPermission = $scope.project.my_permissions.indexOf("modify_#{$attrs.permissionSuffix}") > -1
ctx = {
id: attachment.id
name: attachment.name

View File

@ -44,7 +44,9 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm) ->
<li class="wiki-link" data-id="<%- index %>">
<a title="<%- link.title %>">
<span class="link-title"><%- link.title %></span>
<% if (deleteWikiLinkPermission) { %>
<span class="icon icon-delete"></span>
<% } %>
</a>
<input type="text" placeholder="name" class="hidden" value="<%- link.title %>" />
</li>
@ -54,7 +56,9 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm) ->
</li>
</ul>
</nav>
<% if (addWikiLinkPermission) { %>
<a href="" title="Add link" class="add-button button button-gray">Add link</a>
<% } %>
""")
link = ($scope, $el, $attrs) ->
$ctrl = $el.controller()
@ -63,7 +67,15 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm) ->
return $log.error "WikiNavDirective: no ng-model attr is defined"
render = (wikiLinks) ->
html = template({wikiLinks: wikiLinks, projectSlug: $scope.projectSlug})
addWikiLinkPermission = $scope.project.my_permissions.indexOf("add_wiki_link") > -1
deleteWikiLinkPermission = $scope.project.my_permissions.indexOf("delete_wiki_link") > -1
html = template({
wikiLinks: wikiLinks,
projectSlug: $scope.projectSlug
addWikiLinkPermission: addWikiLinkPermission
deleteWikiLinkPermission: deleteWikiLinkPermission
})
$el.off()
$el.html(html)

View File

@ -25,6 +25,7 @@ block content
textarea(placeholder="Write a description of your issue", ng-model="issue.description", tg-markitup)
- var attachModel = "issue"
- var permissionSuffix = "issue"
include views/modules/attachments
textarea(ng-model="issue.comment", placeholder="Write here a new commet")

View File

@ -28,6 +28,7 @@ block content
section.us-content.wysiwyg(tg-bind-html="issue.description_html")
- var attachModel = "issue"
- var permissionSuffix = "issue"
include views/modules/attachments
section.us-activity

View File

@ -25,6 +25,7 @@ block content
textarea(placeholder="Write a description of your task", ng-model="task.description", tg-markitup)
- var attachModel = "task"
- var permissionSuffix = "task"
include views/modules/attachments
textarea(ng-model="task.comment", placeholder="Write here a new commet")

View File

@ -28,6 +28,7 @@ block content
section.us-content.wysiwyg(tg-bind-html="task.description_html")
- var attachModel = "task"
- var permissionSuffix = "task"
include views/modules/attachments
section.us-activity

View File

@ -25,6 +25,7 @@ block content
textarea(placeholder="Write a description of your user story", ng-model="us.description", tg-markitup)
- var attachModel = "us"
- var permissionSuffix = "us"
include views/modules/attachments
textarea(ng-model="us.comment", placeholder="Write here a new commet")

View File

@ -30,6 +30,7 @@ block content
section.us-content.wysiwyg(tg-bind-html="us.description_html")
- var attachModel = "us"
- var permissionSuffix = "us"
include views/modules/attachments
section.us-activity

View File

@ -1,4 +1,4 @@
//- NOTE: You must to define 'var attachModel' with the object model
//- NOTE: You must to define 'var attachModel' 'var permissionSuffix' with the object model
//- that have attachments
section.attachments(tg-attachments, ng-model=attachModel, ng-if="#{attachModel}.id")
@ -7,13 +7,13 @@ section.attachments(tg-attachments, ng-model=attachModel, ng-if="#{attachModel}.
span.icon.icon-attachments
span.attachments-num 0
span.attachments-text attachments
a.button.button-gray.add-attach(tg-check-permission, permission="modify_"+attachModel, href="", title="Add new attachment")
a.button.button-gray.add-attach(tg-check-permission, permission="modify_"+permissionSuffix, href="", title="Add new attachment")
span +new file
input.hidden.add-attach(type="file", multiple="multiple")
div.attachment-body.sortable
div.hidden.single-attachment(ng-repeat="attach in attachments",
tg-attachment="attach", ng-model=attachModel)
tg-attachment="attach", permission-suffix=permissionSuffix)
//- See modules/common/attachments.coffee - AttachmentDirective

View File

@ -22,4 +22,5 @@ block content
textarea(placeholder="Write a your wiki page", ng-model="wiki.content", tg-markitup)
- var attachModel = "wiki"
- var permissionSuffix = "wiki_page"
include views/modules/attachments

View File

@ -15,12 +15,16 @@ block content
span.green Wiki
span.wiki-title(tg-bo-bind='wiki.slug|unslugify')
.action-buttons
a.button.button-red.delete-wiki(href="", title="Delete", ng-click="ctrl.delete()") Delete
a.button.button-green.edit-wiki(href="", title="Edit", ng-click="ctrl.edit()") Edit
a.button.button-red.delete-wiki(tg-check-permission, permission="delete_wiki_page",
href="", title="Delete", ng-click="ctrl.delete()") Delete
a.button.button-green.edit-wiki(tg-check-permission, permission="modify_wiki_page",
href="", title="Edit", ng-click="ctrl.edit()") Edit
include views/modules/wiki-summary
section.wiki-content.wysiwyg(tg-bind-html="wiki.html")
- var attachModel = "wiki"
- var permissionSuffix = "wiki_page"
include views/modules/attachments