aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2016-10-02 11:05:10 +0200
committerGitHub <noreply@github.com>2016-10-02 11:05:10 +0200
commit6e5e27ab078527cb68c2e7a37512d050fd330258 (patch)
tree31ef95746133f5b603153397d354e35bc8449022 /src
parentbfb3ae01dafa921505384c5db1cd6625ecdd0bb8 (diff)
parent2455472e26fe06bf14d2ec74534de7bd2e542249 (diff)
downloadwallabag-6e5e27ab078527cb68c2e7a37512d050fd330258.tar.gz
wallabag-6e5e27ab078527cb68c2e7a37512d050fd330258.tar.zst
wallabag-6e5e27ab078527cb68c2e7a37512d050fd330258.zip
Merge pull request #2324 from wallabag/edit-tagging-rule
Add ability to edit a tagging rule
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php48
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.da.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.de.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.en.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.es.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.it.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig3
13 files changed, 58 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 75a9af0b..f1e212d9 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -108,7 +108,21 @@ class ConfigController extends Controller
108 108
109 // handle tagging rule 109 // handle tagging rule
110 $taggingRule = new TaggingRule(); 110 $taggingRule = new TaggingRule();
111 $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $this->generateUrl('config').'#set5']); 111 $action = $this->generateUrl('config').'#set5';
112
113 if ($request->query->has('tagging-rule')) {
114 $taggingRule = $this->getDoctrine()
115 ->getRepository('WallabagCoreBundle:TaggingRule')
116 ->find($request->query->get('tagging-rule'));
117
118 if ($this->getUser()->getId() !== $taggingRule->getConfig()->getUser()->getId()) {
119 return $this->redirect($action);
120 }
121
122 $action = $this->generateUrl('config').'?tagging-rule='.$taggingRule->getId().'#set5';
123 }
124
125 $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $action]);
112 $newTaggingRule->handleRequest($request); 126 $newTaggingRule->handleRequest($request);
113 127
114 if ($newTaggingRule->isValid()) { 128 if ($newTaggingRule->isValid()) {
@@ -205,9 +219,7 @@ class ConfigController extends Controller
205 */ 219 */
206 public function deleteTaggingRuleAction(TaggingRule $rule) 220 public function deleteTaggingRuleAction(TaggingRule $rule)
207 { 221 {
208 if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) { 222 $this->validateRuleAction($rule);
209 throw $this->createAccessDeniedException('You can not access this tagging rule.');
210 }
211 223
212 $em = $this->getDoctrine()->getManager(); 224 $em = $this->getDoctrine()->getManager();
213 $em->remove($rule); 225 $em->remove($rule);
@@ -222,6 +234,34 @@ class ConfigController extends Controller
222 } 234 }
223 235
224 /** 236 /**
237 * Edit a tagging rule.
238 *
239 * @param TaggingRule $rule
240 *
241 * @Route("/tagging-rule/edit/{id}", requirements={"id" = "\d+"}, name="edit_tagging_rule")
242 *
243 * @return RedirectResponse
244 */
245 public function editTaggingRuleAction(TaggingRule $rule)
246 {
247 $this->validateRuleAction($rule);
248
249 return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5');
250 }
251
252 /**
253 * Validate that a rule can be edited/deleted by the current user.
254 *
255 * @param TaggingRule $rule
256 */
257 private function validateRuleAction(TaggingRule $rule)
258 {
259 if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) {
260 throw $this->createAccessDeniedException('You can not access this tagging rule.');
261 }
262 }
263
264 /**
225 * Retrieve config for the current user. 265 * Retrieve config for the current user.
226 * If no config were found, create a new one. 266 * If no config were found, create a new one.
227 * 267 *
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
index 72374a4a..628cdbdb 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
@@ -95,6 +95,7 @@ config:
95 # if_label: 'if' 95 # if_label: 'if'
96 # then_tag_as_label: 'then tag as' 96 # then_tag_as_label: 'then tag as'
97 # delete_rule_label: 'delete' 97 # delete_rule_label: 'delete'
98 # edit_rule_label: 'edit'
98 # rule_label: 'Rule' 99 # rule_label: 'Rule'
99 # tags_label: 'Tags' 100 # tags_label: 'Tags'
100 # faq: 101 # faq:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
index 3013e780..2e683b8c 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
@@ -95,6 +95,7 @@ config:
95 if_label: 'Wenn' 95 if_label: 'Wenn'
96 then_tag_as_label: 'dann tagge als' 96 then_tag_as_label: 'dann tagge als'
97 delete_rule_label: 'löschen' 97 delete_rule_label: 'löschen'
98 # edit_rule_label: 'edit'
98 rule_label: 'Regel' 99 rule_label: 'Regel'
99 tags_label: 'Tags' 100 tags_label: 'Tags'
100 faq: 101 faq:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
index 7bd85cd6..d629312c 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
@@ -95,6 +95,7 @@ config:
95 if_label: 'if' 95 if_label: 'if'
96 then_tag_as_label: 'then tag as' 96 then_tag_as_label: 'then tag as'
97 delete_rule_label: 'delete' 97 delete_rule_label: 'delete'
98 edit_rule_label: 'edit'
98 rule_label: 'Rule' 99 rule_label: 'Rule'
99 tags_label: 'Tags' 100 tags_label: 'Tags'
100 faq: 101 faq:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
index cab0f302..860c466f 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
@@ -95,6 +95,7 @@ config:
95 if_label: 'si' 95 if_label: 'si'
96 then_tag_as_label: 'Etiquete como' 96 then_tag_as_label: 'Etiquete como'
97 delete_rule_label: 'Borre' 97 delete_rule_label: 'Borre'
98 # edit_rule_label: 'edit'
98 rule_label: 'Regla' 99 rule_label: 'Regla'
99 tags_label: 'Etiquetas' 100 tags_label: 'Etiquetas'
100 faq: 101 faq:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
index 202f9d2d..6e02010c 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
@@ -95,6 +95,7 @@ config:
95 if_label: 'اگر' 95 if_label: 'اگر'
96 then_tag_as_label: 'این برچسب را بزن' 96 then_tag_as_label: 'این برچسب را بزن'
97 delete_rule_label: 'پاک کن' 97 delete_rule_label: 'پاک کن'
98 # edit_rule_label: 'edit'
98 rule_label: 'قانون' 99 rule_label: 'قانون'
99 tags_label: 'برچسب‌ها' 100 tags_label: 'برچسب‌ها'
100 faq: 101 faq:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index 591b598b..0eeda011 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -95,6 +95,7 @@ config:
95 if_label: 'si' 95 if_label: 'si'
96 then_tag_as_label: 'alors attribuer les tags' 96 then_tag_as_label: 'alors attribuer les tags'
97 delete_rule_label: 'supprimer' 97 delete_rule_label: 'supprimer'
98 edit_rule_label: 'éditer'
98 rule_label: 'Règle' 99 rule_label: 'Règle'
99 tags_label: 'Tags' 100 tags_label: 'Tags'
100 faq: 101 faq:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
index b767e580..34f660f7 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
@@ -95,6 +95,7 @@ config:
95 if_label: 'se' 95 if_label: 'se'
96 then_tag_as_label: 'allora tagga come' 96 then_tag_as_label: 'allora tagga come'
97 delete_rule_label: 'elimina' 97 delete_rule_label: 'elimina'
98 # edit_rule_label: 'edit'
98 rule_label: 'Regola' 99 rule_label: 'Regola'
99 tags_label: 'Tag' 100 tags_label: 'Tag'
100 faq: 101 faq:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
index 39eac642..bcc59b29 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
@@ -95,6 +95,7 @@ config:
95 if_label: 'se' 95 if_label: 'se'
96 then_tag_as_label: 'alara atribuir las etiquetas' 96 then_tag_as_label: 'alara atribuir las etiquetas'
97 delete_rule_label: 'suprimir' 97 delete_rule_label: 'suprimir'
98 # edit_rule_label: 'edit'
98 rule_label: 'Règla' 99 rule_label: 'Règla'
99 tags_label: 'Etiquetas' 100 tags_label: 'Etiquetas'
100 faq: 101 faq:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
index 50da9ff2..ce5ebab9 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
@@ -95,6 +95,7 @@ config:
95 if_label: 'jeżeli' 95 if_label: 'jeżeli'
96 then_tag_as_label: 'wtedy otaguj jako' 96 then_tag_as_label: 'wtedy otaguj jako'
97 delete_rule_label: 'usuń' 97 delete_rule_label: 'usuń'
98 # edit_rule_label: 'edit'
98 rule_label: 'Reguła' 99 rule_label: 'Reguła'
99 tags_label: 'Tagi' 100 tags_label: 'Tagi'
100 faq: 101 faq:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
index 315d6aa0..a54efb4c 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
@@ -95,6 +95,7 @@ config:
95 # if_label: 'if' 95 # if_label: 'if'
96 # then_tag_as_label: 'then tag as' 96 # then_tag_as_label: 'then tag as'
97 # delete_rule_label: 'delete' 97 # delete_rule_label: 'delete'
98 # edit_rule_label: 'edit'
98 # rule_label: 'Rule' 99 # rule_label: 'Rule'
99 # tags_label: 'Tags' 100 # tags_label: 'Tags'
100 # faq: 101 # faq:
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
index 6446cf2c..dd4f7b00 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
@@ -191,6 +191,7 @@
191 « {{ tagging_rule.rule }} » 191 « {{ tagging_rule.rule }} »
192 {{ 'config.form_rules.then_tag_as_label'|trans }} 192 {{ 'config.form_rules.then_tag_as_label'|trans }}
193 « {{ tagging_rule.tags|join(', ') }} » 193 « {{ tagging_rule.tags|join(', ') }} »
194 <a href="{{ path('edit_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}" class="tool mode_edit">✎</a>
194 <a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}" class="tool delete icon-trash icon"></a> 195 <a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}" class="tool delete icon-trash icon"></a>
195 </li> 196 </li>
196 {% endfor %} 197 {% endfor %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
index 5330c353..650a3ae2 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
@@ -218,6 +218,9 @@
218 « {{ tagging_rule.rule }} » 218 « {{ tagging_rule.rule }} »
219 {{ 'config.form_rules.then_tag_as_label'|trans }} 219 {{ 'config.form_rules.then_tag_as_label'|trans }}
220 « {{ tagging_rule.tags|join(', ') }} » 220 « {{ tagging_rule.tags|join(', ') }} »
221 <a href="{{ path('edit_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}">
222 <i class="tool grey-text mode_edit material-icons">mode_edit</i>
223 </a>
221 <a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}"> 224 <a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}">
222 <i class="tool grey-text delete material-icons">delete</i> 225 <i class="tool grey-text delete material-icons">delete</i>
223 </a> 226 </a>