Commit 31ba3f0eaac2fdafd578d38b902fad193e239ee6
Exists in
master
and in
8 other branches
Merge branch 'master' of https://gitlab.com/participa/proposal-app
Showing
3 changed files
with
12 additions
and
4 deletions
Show diff stats
index.html
... | ... | @@ -195,7 +195,7 @@ |
195 | 195 | <div class="info">Ela se tornará pública em até 24 horas após o envio e poderá ser apoiada por outros participantes.</div> |
196 | 196 | <div class="send-proposal-button send-button"><a href="#"><span>Envie Sua Proposta</span></a></div> |
197 | 197 | <div class="login-container hide">Login</div> |
198 | - <form class="make-proposal-form save-article-form hide" id="make-proposal-form-{{id}}" action="/api/v1/articles/{{id}}/children/suggest"> | |
198 | + <form class="make-proposal-form save-article-form hide" id="make-proposal-form-{{id}}" action="{{proposal_action ../article . }}"> | |
199 | 199 | <div class="message hide"></div> |
200 | 200 | <div> |
201 | 201 | <div><label for="article_abstract">Descrição</label></div> | ... | ... |
js/handlebars-helpers.js
... | ... | @@ -74,12 +74,20 @@ define(['handlebars'], function(Handlebars){ |
74 | 74 | ret += '</select>'; |
75 | 75 | return ret; |
76 | 76 | }); |
77 | - | |
77 | + | |
78 | 78 | Handlebars.registerHelper('trimString', function(passedString, endstring) { |
79 | 79 | var theString = passedString.substring(0, endstring); |
80 | 80 | return new Handlebars.SafeString(theString) |
81 | 81 | }); |
82 | - | |
82 | + | |
83 | + Handlebars.registerHelper('proposal_action', function(discussion, target) { | |
84 | + if(discussion.setting && discussion.setting.moderate_proposals) { | |
85 | + return '/api/v1/articles/'+target.id+'/children/suggest'; | |
86 | + } else { | |
87 | + return '/api/v1/articles/'+target.id+'/children'; | |
88 | + } | |
89 | + }); | |
90 | + | |
83 | 91 | function proposal_has_category(proposal, category_slug) { |
84 | 92 | for(var i=0; i<proposal.categories.length; i++) { |
85 | 93 | if(proposal.categories[i].slug == category_slug) | ... | ... |
js/main.js
... | ... | @@ -32,7 +32,7 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ |
32 | 32 | } |
33 | 33 | |
34 | 34 | // Load data from localhost when it is dev env. |
35 | - var noosferoAPI = host + '/api/v1/articles/' + proposal_discussion + '?private_token=' + private_token + '&fields=id,children,categories,abstract,title,image,url'; | |
35 | + var noosferoAPI = host + '/api/v1/articles/' + proposal_discussion + '?private_token=' + private_token + '&fields=id,children,categories,abstract,title,image,url,setting'; | |
36 | 36 | |
37 | 37 | $.getJSON(noosferoAPI) |
38 | 38 | .done(function( data ) { | ... | ... |