diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-01 09:26:32 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-22 13:13:06 +0200 |
commit | 206bade58a279d7f2e34c2dbada10366b90d2d6b (patch) | |
tree | 6c5fc1fe65dfa9e661a09b3fd92253f2931b84de | |
parent | e8331dd9e7772a396bb211459eca4a682c8e947e (diff) | |
download | wallabag-206bade58a279d7f2e34c2dbada10366b90d2d6b.tar.gz wallabag-206bade58a279d7f2e34c2dbada10366b90d2d6b.tar.zst wallabag-206bade58a279d7f2e34c2dbada10366b90d2d6b.zip |
Add ability to reset some datas
- annotations
- tags
- entries
18 files changed, 406 insertions, 22 deletions
diff --git a/app/DoctrineMigrations/Version20161001072726.php b/app/DoctrineMigrations/Version20161001072726.php new file mode 100644 index 00000000..2e112949 --- /dev/null +++ b/app/DoctrineMigrations/Version20161001072726.php | |||
@@ -0,0 +1,54 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | class Version20161001072726 extends AbstractMigration implements ContainerAwareInterface | ||
11 | { | ||
12 | /** | ||
13 | * @var ContainerInterface | ||
14 | */ | ||
15 | private $container; | ||
16 | |||
17 | public function setContainer(ContainerInterface $container = null) | ||
18 | { | ||
19 | $this->container = $container; | ||
20 | } | ||
21 | |||
22 | private function getTable($tableName) | ||
23 | { | ||
24 | return $this->container->getParameter('database_table_prefix') . $tableName; | ||
25 | } | ||
26 | |||
27 | /** | ||
28 | * @param Schema $schema | ||
29 | */ | ||
30 | public function up(Schema $schema) | ||
31 | { | ||
32 | $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY FK_F035C9E5BA364942'); | ||
33 | $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY FK_F035C9E5BAD26311'); | ||
34 | $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_F035C9E5BA364942 FOREIGN KEY (entry_id) REFERENCES `entry` (id) ON DELETE CASCADE'); | ||
35 | $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_F035C9E5BAD26311 FOREIGN KEY (tag_id) REFERENCES `tag` (id) ON DELETE CASCADE'); | ||
36 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP FOREIGN KEY FK_2E443EF2BA364942'); | ||
37 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' ADD CONSTRAINT FK_2E443EF2BA364942 FOREIGN KEY (entry_id) REFERENCES `entry` (id) ON DELETE CASCADE'); | ||
38 | } | ||
39 | |||
40 | /** | ||
41 | * @param Schema $schema | ||
42 | */ | ||
43 | public function down(Schema $schema) | ||
44 | { | ||
45 | $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); | ||
46 | |||
47 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP FOREIGN KEY FK_2E443EF2BA364942'); | ||
48 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' ADD CONSTRAINT FK_2E443EF2BA364942 FOREIGN KEY (entry_id) REFERENCES entry (id)'); | ||
49 | $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY FK_F035C9E5BA364942'); | ||
50 | $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY FK_F035C9E5BAD26311'); | ||
51 | $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_F035C9E5BA364942 FOREIGN KEY (entry_id) REFERENCES entry (id)'); | ||
52 | $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_F035C9E5BAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id)'); | ||
53 | } | ||
54 | } | ||
diff --git a/src/Wallabag/AnnotationBundle/Entity/Annotation.php b/src/Wallabag/AnnotationBundle/Entity/Annotation.php index c48d8731..0838f5aa 100644 --- a/src/Wallabag/AnnotationBundle/Entity/Annotation.php +++ b/src/Wallabag/AnnotationBundle/Entity/Annotation.php | |||
@@ -82,7 +82,7 @@ class Annotation | |||
82 | * @Exclude | 82 | * @Exclude |
83 | * | 83 | * |
84 | * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Entry", inversedBy="annotations") | 84 | * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Entry", inversedBy="annotations") |
85 | * @ORM\JoinColumn(name="entry_id", referencedColumnName="id") | 85 | * @ORM\JoinColumn(name="entry_id", referencedColumnName="id", onDelete="cascade") |
86 | */ | 86 | */ |
87 | private $entry; | 87 | private $entry; |
88 | 88 | ||
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index abd35c02..ccbf550a 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php | |||
@@ -225,6 +225,48 @@ class ConfigController extends Controller | |||
225 | } | 225 | } |
226 | 226 | ||
227 | /** | 227 | /** |
228 | * Remove all annotations OR tags OR entries for the current user. | ||
229 | * | ||
230 | * @Route("/reset/{type}", requirements={"id" = "annotations|tags|entries"}, name="config_reset") | ||
231 | * | ||
232 | * @return RedirectResponse | ||
233 | */ | ||
234 | public function resetAction($type) | ||
235 | { | ||
236 | $em = $this->getDoctrine()->getManager(); | ||
237 | |||
238 | switch ($type) { | ||
239 | case 'annotations': | ||
240 | $em->createQuery('DELETE FROM Wallabag\AnnotationBundle\Entity\Annotation a WHERE a.user = '.$this->getUser()->getId()) | ||
241 | ->execute(); | ||
242 | break; | ||
243 | |||
244 | case 'tags': | ||
245 | $tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findAllTags($this->getUser()->getId()); | ||
246 | |||
247 | if (empty($tags)) { | ||
248 | break; | ||
249 | } | ||
250 | |||
251 | $this->getDoctrine() | ||
252 | ->getRepository('WallabagCoreBundle:Entry') | ||
253 | ->removeTags($this->getUser()->getId(), $tags); | ||
254 | break; | ||
255 | |||
256 | case 'entries': | ||
257 | $em->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\Entry e WHERE e.user = '.$this->getUser()->getId()) | ||
258 | ->execute(); | ||
259 | } | ||
260 | |||
261 | $this->get('session')->getFlashBag()->add( | ||
262 | 'notice', | ||
263 | 'flashes.config.notice.'.$type.'_reset' | ||
264 | ); | ||
265 | |||
266 | return $this->redirect($this->generateUrl('config').'#set3'); | ||
267 | } | ||
268 | |||
269 | /** | ||
228 | * Validate that a rule can be edited/deleted by the current user. | 270 | * Validate that a rule can be edited/deleted by the current user. |
229 | * | 271 | * |
230 | * @param TaggingRule $rule | 272 | * @param TaggingRule $rule |
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index f2da3f4d..dd49acf0 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -190,10 +190,10 @@ class Entry | |||
190 | * @ORM\JoinTable( | 190 | * @ORM\JoinTable( |
191 | * name="entry_tag", | 191 | * name="entry_tag", |
192 | * joinColumns={ | 192 | * joinColumns={ |
193 | * @ORM\JoinColumn(name="entry_id", referencedColumnName="id") | 193 | * @ORM\JoinColumn(name="entry_id", referencedColumnName="id", onDelete="cascade") |
194 | * }, | 194 | * }, |
195 | * inverseJoinColumns={ | 195 | * inverseJoinColumns={ |
196 | * @ORM\JoinColumn(name="tag_id", referencedColumnName="id") | 196 | * @ORM\JoinColumn(name="tag_id", referencedColumnName="id", onDelete="cascade") |
197 | * } | 197 | * } |
198 | * ) | 198 | * ) |
199 | */ | 199 | */ |
diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index e76878d4..69661b12 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php | |||
@@ -53,6 +53,23 @@ class TagRepository extends EntityRepository | |||
53 | } | 53 | } |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Find all tags. | ||
57 | * | ||
58 | * @param int $userId | ||
59 | * | ||
60 | * @return array | ||
61 | */ | ||
62 | public function findAllTags($userId) | ||
63 | { | ||
64 | return $this->createQueryBuilder('t') | ||
65 | ->select('t') | ||
66 | ->leftJoin('t.entries', 'e') | ||
67 | ->where('e.user = :userId')->setParameter('userId', $userId) | ||
68 | ->getQuery() | ||
69 | ->getResult(); | ||
70 | } | ||
71 | |||
72 | /** | ||
56 | * Used only in test case to get a tag for our entry. | 73 | * Used only in test case to get a tag for our entry. |
57 | * | 74 | * |
58 | * @return Tag | 75 | * @return Tag |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index f5548a21..7c8ae66e 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml | |||
@@ -89,10 +89,17 @@ config: | |||
89 | email_label: 'Emailadresse' | 89 | email_label: 'Emailadresse' |
90 | # twoFactorAuthentication_label: 'Two factor authentication' | 90 | # twoFactorAuthentication_label: 'Two factor authentication' |
91 | delete: | 91 | delete: |
92 | # title: Delete my account (danger zone !) | 92 | # title: Delete my account (a.k.a danger zone) |
93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. | 93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. |
94 | # confirm: Are you really sure? (it can't be UNDONE) | 94 | # confirm: Are you really sure? (THIS CAN'T BE UNDONE) |
95 | # button: Delete my account | 95 | # button: Delete my account |
96 | reset: | ||
97 | # title: Reset area (a.k.a danger zone) | ||
98 | # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE. | ||
99 | # annotations: Remove ALL annotations | ||
100 | # tags: Remove ALL tags | ||
101 | # entries: Remove ALL entries | ||
102 | # confirm: Are you really really sure? (THIS CAN'T BE UNDONE) | ||
96 | form_password: | 103 | form_password: |
97 | old_password_label: 'Gammel adgangskode' | 104 | old_password_label: 'Gammel adgangskode' |
98 | new_password_label: 'Ny adgangskode' | 105 | new_password_label: 'Ny adgangskode' |
@@ -462,6 +469,9 @@ flashes: | |||
462 | # tagging_rules_deleted: 'Tagging rule deleted' | 469 | # tagging_rules_deleted: 'Tagging rule deleted' |
463 | # user_added: 'User "%username%" added' | 470 | # user_added: 'User "%username%" added' |
464 | # rss_token_updated: 'RSS token updated' | 471 | # rss_token_updated: 'RSS token updated' |
472 | # annotations_reset: Annotations reset | ||
473 | # tags_reset: Tags reset | ||
474 | # entries_reset: Entries reset | ||
465 | entry: | 475 | entry: |
466 | notice: | 476 | notice: |
467 | # entry_already_saved: 'Entry already saved on %date%' | 477 | # entry_already_saved: 'Entry already saved on %date%' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index 9edd7fb7..20f9753b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml | |||
@@ -89,10 +89,17 @@ config: | |||
89 | email_label: 'E-Mail-Adresse' | 89 | email_label: 'E-Mail-Adresse' |
90 | twoFactorAuthentication_label: 'Zwei-Faktor-Authentifizierung' | 90 | twoFactorAuthentication_label: 'Zwei-Faktor-Authentifizierung' |
91 | delete: | 91 | delete: |
92 | # title: Delete my account (danger zone !) | 92 | # title: Delete my account (a.k.a danger zone) |
93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. | 93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. |
94 | # confirm: Are you really sure? (it can't be UNDONE) | 94 | # confirm: Are you really sure? (THIS CAN'T BE UNDONE) |
95 | # button: Delete my account | 95 | # button: Delete my account |
96 | reset: | ||
97 | # title: Reset area (a.k.a danger zone) | ||
98 | # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE. | ||
99 | # annotations: Remove ALL annotations | ||
100 | # tags: Remove ALL tags | ||
101 | # entries: Remove ALL entries | ||
102 | # confirm: Are you really really sure? (THIS CAN'T BE UNDONE) | ||
96 | form_password: | 103 | form_password: |
97 | old_password_label: 'Altes Kennwort' | 104 | old_password_label: 'Altes Kennwort' |
98 | new_password_label: 'Neues Kennwort' | 105 | new_password_label: 'Neues Kennwort' |
@@ -462,6 +469,9 @@ flashes: | |||
462 | tagging_rules_deleted: 'Tagging-Regel gelöscht' | 469 | tagging_rules_deleted: 'Tagging-Regel gelöscht' |
463 | user_added: 'Benutzer "%username%" erstellt' | 470 | user_added: 'Benutzer "%username%" erstellt' |
464 | rss_token_updated: 'RSS-Token aktualisiert' | 471 | rss_token_updated: 'RSS-Token aktualisiert' |
472 | # annotations_reset: Annotations reset | ||
473 | # tags_reset: Tags reset | ||
474 | # entries_reset: Entries reset | ||
465 | entry: | 475 | entry: |
466 | notice: | 476 | notice: |
467 | entry_already_saved: 'Eintrag bereits am %date% gespeichert' | 477 | entry_already_saved: 'Eintrag bereits am %date% gespeichert' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index b86145a0..35dde535 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml | |||
@@ -89,10 +89,17 @@ config: | |||
89 | email_label: 'Email' | 89 | email_label: 'Email' |
90 | twoFactorAuthentication_label: 'Two factor authentication' | 90 | twoFactorAuthentication_label: 'Two factor authentication' |
91 | delete: | 91 | delete: |
92 | title: Delete my account (danger zone !) | 92 | title: Delete my account (a.k.a danger zone) |
93 | description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. | 93 | description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. |
94 | confirm: Are you really sure? (it can't be UNDONE) | 94 | confirm: Are you really sure? (THIS CAN'T BE UNDONE) |
95 | button: Delete my account | 95 | button: Delete my account |
96 | reset: | ||
97 | title: Reset area (a.k.a danger zone) | ||
98 | description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE. | ||
99 | annotations: Remove ALL annotations | ||
100 | tags: Remove ALL tags | ||
101 | entries: Remove ALL entries | ||
102 | confirm: Are you really really sure? (THIS CAN'T BE UNDONE) | ||
96 | form_password: | 103 | form_password: |
97 | old_password_label: 'Current password' | 104 | old_password_label: 'Current password' |
98 | new_password_label: 'New password' | 105 | new_password_label: 'New password' |
@@ -461,6 +468,9 @@ flashes: | |||
461 | tagging_rules_updated: 'Tagging rules updated' | 468 | tagging_rules_updated: 'Tagging rules updated' |
462 | tagging_rules_deleted: 'Tagging rule deleted' | 469 | tagging_rules_deleted: 'Tagging rule deleted' |
463 | rss_token_updated: 'RSS token updated' | 470 | rss_token_updated: 'RSS token updated' |
471 | annotations_reset: Annotations reset | ||
472 | tags_reset: Tags reset | ||
473 | entries_reset: Entries reset | ||
464 | entry: | 474 | entry: |
465 | notice: | 475 | notice: |
466 | entry_already_saved: 'Entry already saved on %date%' | 476 | entry_already_saved: 'Entry already saved on %date%' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index b7187f50..13f2e977 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml | |||
@@ -89,10 +89,17 @@ config: | |||
89 | email_label: 'Direccion e-mail' | 89 | email_label: 'Direccion e-mail' |
90 | twoFactorAuthentication_label: 'Autentificación de dos factores' | 90 | twoFactorAuthentication_label: 'Autentificación de dos factores' |
91 | delete: | 91 | delete: |
92 | # title: Delete my account (danger zone !) | 92 | # title: Delete my account (a.k.a danger zone) |
93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. | 93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. |
94 | # confirm: Are you really sure? (it can't be UNDONE) | 94 | # confirm: Are you really sure? (THIS CAN'T BE UNDONE) |
95 | # button: Delete my account | 95 | # button: Delete my account |
96 | reset: | ||
97 | # title: Reset area (a.k.a danger zone) | ||
98 | # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE. | ||
99 | # annotations: Remove ALL annotations | ||
100 | # tags: Remove ALL tags | ||
101 | # entries: Remove ALL entries | ||
102 | # confirm: Are you really really sure? (THIS CAN'T BE UNDONE) | ||
96 | form_password: | 103 | form_password: |
97 | old_password_label: 'Contraseña actual' | 104 | old_password_label: 'Contraseña actual' |
98 | new_password_label: 'Nueva contraseña' | 105 | new_password_label: 'Nueva contraseña' |
@@ -462,6 +469,9 @@ flashes: | |||
462 | tagging_rules_deleted: 'Regla de etiquetado actualizada' | 469 | tagging_rules_deleted: 'Regla de etiquetado actualizada' |
463 | user_added: 'Usuario "%username%" añadido' | 470 | user_added: 'Usuario "%username%" añadido' |
464 | rss_token_updated: 'RSS token actualizado' | 471 | rss_token_updated: 'RSS token actualizado' |
472 | # annotations_reset: Annotations reset | ||
473 | # tags_reset: Tags reset | ||
474 | # entries_reset: Entries reset | ||
465 | entry: | 475 | entry: |
466 | notice: | 476 | notice: |
467 | entry_already_saved: 'Entrada ya guardada por %fecha%' | 477 | entry_already_saved: 'Entrada ya guardada por %fecha%' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index 0751752b..5ee1f62d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml | |||
@@ -89,10 +89,17 @@ config: | |||
89 | email_label: 'نشانی ایمیل' | 89 | email_label: 'نشانی ایمیل' |
90 | twoFactorAuthentication_label: 'تأیید ۲مرحلهای' | 90 | twoFactorAuthentication_label: 'تأیید ۲مرحلهای' |
91 | delete: | 91 | delete: |
92 | # title: Delete my account (danger zone !) | 92 | # title: Delete my account (a.k.a danger zone) |
93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. | 93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. |
94 | # confirm: Are you really sure? (it can't be UNDONE) | 94 | # confirm: Are you really sure? (THIS CAN'T BE UNDONE) |
95 | # button: Delete my account | 95 | # button: Delete my account |
96 | reset: | ||
97 | # title: Reset area (a.k.a danger zone) | ||
98 | # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE. | ||
99 | # annotations: Remove ALL annotations | ||
100 | # tags: Remove ALL tags | ||
101 | # entries: Remove ALL entries | ||
102 | # confirm: Are you really really sure? (THIS CAN'T BE UNDONE) | ||
96 | form_password: | 103 | form_password: |
97 | old_password_label: 'رمز قدیمی' | 104 | old_password_label: 'رمز قدیمی' |
98 | new_password_label: 'رمز تازه' | 105 | new_password_label: 'رمز تازه' |
@@ -461,6 +468,9 @@ flashes: | |||
461 | tagging_rules_deleted: 'قانون برچسبگذاری پاک شد' | 468 | tagging_rules_deleted: 'قانون برچسبگذاری پاک شد' |
462 | user_added: 'کابر "%username%" افزوده شد' | 469 | user_added: 'کابر "%username%" افزوده شد' |
463 | rss_token_updated: 'کد آر-اس-اس بهروز شد' | 470 | rss_token_updated: 'کد آر-اس-اس بهروز شد' |
471 | # annotations_reset: Annotations reset | ||
472 | # tags_reset: Tags reset | ||
473 | # entries_reset: Entries reset | ||
464 | entry: | 474 | entry: |
465 | notice: | 475 | notice: |
466 | entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود' | 476 | entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 8d19ccb1..7a98f133 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml | |||
@@ -91,8 +91,15 @@ config: | |||
91 | delete: | 91 | delete: |
92 | title: Supprimer mon compte (attention danger !) | 92 | title: Supprimer mon compte (attention danger !) |
93 | description: Si vous confirmez la suppression de votre compte, TOUS les articles, TOUS les tags, TOUTES les annotations et votre compte seront DÉFINITIVEMENT supprimé (c'est IRRÉVERSIBLE). Vous serez ensuite déconnecté. | 93 | description: Si vous confirmez la suppression de votre compte, TOUS les articles, TOUS les tags, TOUTES les annotations et votre compte seront DÉFINITIVEMENT supprimé (c'est IRRÉVERSIBLE). Vous serez ensuite déconnecté. |
94 | confirm: Vous êtes vraiment sûr ? (c'est IRRÉVERSIBLE !) | 94 | confirm: Vous êtes vraiment sûr ? (C'EST IRREVERSIBLE) |
95 | button: 'Supprimer mon compte' | 95 | button: 'Supprimer mon compte' |
96 | reset: | ||
97 | title: Réinitialisation (attention danger !) | ||
98 | description: En cliquant sur les boutons ci-dessous vous avez la possibilité de supprimer certaines informations de votre compte. Attention, ces actions sont IRREVERSIBLES ! | ||
99 | annotations: Supprimer TOUTES les annotations | ||
100 | tags: Supprimer TOUS les tags | ||
101 | entries: Supprimer TOUS les articles | ||
102 | confirm: Êtes-vous vraiment vraiment sûr ? (C'EST IRREVERSIBLE) | ||
96 | form_password: | 103 | form_password: |
97 | old_password_label: 'Mot de passe actuel' | 104 | old_password_label: 'Mot de passe actuel' |
98 | new_password_label: 'Nouveau mot de passe' | 105 | new_password_label: 'Nouveau mot de passe' |
@@ -462,6 +469,9 @@ flashes: | |||
462 | tagging_rules_deleted: 'Règle supprimée' | 469 | tagging_rules_deleted: 'Règle supprimée' |
463 | user_added: 'Utilisateur "%username%" ajouté' | 470 | user_added: 'Utilisateur "%username%" ajouté' |
464 | rss_token_updated: 'Jeton RSS mis à jour' | 471 | rss_token_updated: 'Jeton RSS mis à jour' |
472 | annotations_reset: Annotations supprimées | ||
473 | tags_reset: Tags supprimés | ||
474 | entries_reset: Articles supprimés | ||
465 | entry: | 475 | entry: |
466 | notice: | 476 | notice: |
467 | entry_already_saved: 'Article déjà sauvergardé le %date%' | 477 | entry_already_saved: 'Article déjà sauvergardé le %date%' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 4d3452ea..bc4448bd 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml | |||
@@ -89,10 +89,17 @@ config: | |||
89 | email_label: 'E-mail' | 89 | email_label: 'E-mail' |
90 | twoFactorAuthentication_label: 'Two factor authentication' | 90 | twoFactorAuthentication_label: 'Two factor authentication' |
91 | delete: | 91 | delete: |
92 | # title: Delete my account (danger zone !) | 92 | # title: Delete my account (a.k.a danger zone) |
93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. | 93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. |
94 | # confirm: Are you really sure? (it can't be UNDONE) | 94 | # confirm: Are you really sure? (THIS CAN'T BE UNDONE) |
95 | # button: Delete my account | 95 | # button: Delete my account |
96 | reset: | ||
97 | # title: Reset area (a.k.a danger zone) | ||
98 | # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE. | ||
99 | # annotations: Remove ALL annotations | ||
100 | # tags: Remove ALL tags | ||
101 | # entries: Remove ALL entries | ||
102 | # confirm: Are you really really sure? (THIS CAN'T BE UNDONE) | ||
96 | form_password: | 103 | form_password: |
97 | old_password_label: 'Password corrente' | 104 | old_password_label: 'Password corrente' |
98 | new_password_label: 'Nuova password' | 105 | new_password_label: 'Nuova password' |
@@ -462,6 +469,9 @@ flashes: | |||
462 | tagging_rules_deleted: 'Regola di tagging aggiornate' | 469 | tagging_rules_deleted: 'Regola di tagging aggiornate' |
463 | user_added: 'Utente "%username%" aggiunto' | 470 | user_added: 'Utente "%username%" aggiunto' |
464 | rss_token_updated: 'RSS token aggiornato' | 471 | rss_token_updated: 'RSS token aggiornato' |
472 | # annotations_reset: Annotations reset | ||
473 | # tags_reset: Tags reset | ||
474 | # entries_reset: Entries reset | ||
465 | entry: | 475 | entry: |
466 | notice: | 476 | notice: |
467 | entry_already_saved: 'Contenuto già salvato in data %date%' | 477 | entry_already_saved: 'Contenuto già salvato in data %date%' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index f14213c6..7d1a801a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml | |||
@@ -89,10 +89,17 @@ config: | |||
89 | email_label: 'Adreça de corrièl' | 89 | email_label: 'Adreça de corrièl' |
90 | twoFactorAuthentication_label: 'Dobla autentificacion' | 90 | twoFactorAuthentication_label: 'Dobla autentificacion' |
91 | delete: | 91 | delete: |
92 | # title: Delete my account (danger zone !) | 92 | # title: Delete my account (a.k.a danger zone) |
93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. | 93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. |
94 | # confirm: Are you really sure? (it can't be UNDONE) | 94 | # confirm: Are you really sure? (THIS CAN'T BE UNDONE) |
95 | # button: Delete my account | 95 | # button: Delete my account |
96 | reset: | ||
97 | # title: Reset area (a.k.a danger zone) | ||
98 | # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE. | ||
99 | # annotations: Remove ALL annotations | ||
100 | # tags: Remove ALL tags | ||
101 | # entries: Remove ALL entries | ||
102 | # confirm: Are you really really sure? (THIS CAN'T BE UNDONE) | ||
96 | form_password: | 103 | form_password: |
97 | old_password_label: 'Senhal actual' | 104 | old_password_label: 'Senhal actual' |
98 | new_password_label: 'Senhal novèl' | 105 | new_password_label: 'Senhal novèl' |
@@ -462,6 +469,9 @@ flashes: | |||
462 | tagging_rules_deleted: 'Règla suprimida' | 469 | tagging_rules_deleted: 'Règla suprimida' |
463 | user_added: 'Utilizaire "%username%" ajustat' | 470 | user_added: 'Utilizaire "%username%" ajustat' |
464 | rss_token_updated: 'Geton RSS mes a jorn' | 471 | rss_token_updated: 'Geton RSS mes a jorn' |
472 | # annotations_reset: Annotations reset | ||
473 | # tags_reset: Tags reset | ||
474 | # entries_reset: Entries reset | ||
465 | entry: | 475 | entry: |
466 | notice: | 476 | notice: |
467 | entry_already_saved: 'Article ja salvargardat lo %date%' | 477 | entry_already_saved: 'Article ja salvargardat lo %date%' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 6f22f90d..b05a9dfd 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml | |||
@@ -93,6 +93,13 @@ config: | |||
93 | description: Jeżeli usuniesz swoje konto, wszystkie twoje artykuły, tagi, adnotacje, oraz konto zostaną trwale usunięte (operacja jest NIEODWRACALNA). Następnie zostaniesz wylogowany. | 93 | description: Jeżeli usuniesz swoje konto, wszystkie twoje artykuły, tagi, adnotacje, oraz konto zostaną trwale usunięte (operacja jest NIEODWRACALNA). Następnie zostaniesz wylogowany. |
94 | confirm: Jesteś pewien? (tej operacji NIE MOŻNA cofnąć) | 94 | confirm: Jesteś pewien? (tej operacji NIE MOŻNA cofnąć) |
95 | button: Usuń moje konto | 95 | button: Usuń moje konto |
96 | reset: | ||
97 | # title: Reset area (a.k.a danger zone) | ||
98 | # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE. | ||
99 | # annotations: Remove ALL annotations | ||
100 | # tags: Remove ALL tags | ||
101 | # entries: Remove ALL entries | ||
102 | # confirm: Are you really really sure? (THIS CAN'T BE UNDONE) | ||
96 | form_password: | 103 | form_password: |
97 | old_password_label: 'Stare hasło' | 104 | old_password_label: 'Stare hasło' |
98 | new_password_label: 'Nowe hasło' | 105 | new_password_label: 'Nowe hasło' |
@@ -462,6 +469,9 @@ flashes: | |||
462 | tagging_rules_deleted: 'Reguła tagowania usunięta' | 469 | tagging_rules_deleted: 'Reguła tagowania usunięta' |
463 | user_added: 'Użytkownik "%username%" dodany' | 470 | user_added: 'Użytkownik "%username%" dodany' |
464 | rss_token_updated: 'Token kanału RSS zaktualizowany' | 471 | rss_token_updated: 'Token kanału RSS zaktualizowany' |
472 | # annotations_reset: Annotations reset | ||
473 | # tags_reset: Tags reset | ||
474 | # entries_reset: Entries reset | ||
465 | entry: | 475 | entry: |
466 | notice: | 476 | notice: |
467 | entry_already_saved: 'Wpis już został dodany %date%' | 477 | entry_already_saved: 'Wpis już został dodany %date%' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 29db9c3e..571452c0 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml | |||
@@ -89,10 +89,17 @@ config: | |||
89 | email_label: 'E-mail' | 89 | email_label: 'E-mail' |
90 | # twoFactorAuthentication_label: 'Two factor authentication' | 90 | # twoFactorAuthentication_label: 'Two factor authentication' |
91 | delete: | 91 | delete: |
92 | # title: Delete my account (danger zone !) | 92 | # title: Delete my account (a.k.a danger zone) |
93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. | 93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. |
94 | # confirm: Are you really sure? (it can't be UNDONE) | 94 | # confirm: Are you really sure? (THIS CAN'T BE UNDONE) |
95 | # button: Delete my account | 95 | # button: Delete my account |
96 | reset: | ||
97 | # title: Reset area (a.k.a danger zone) | ||
98 | # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE. | ||
99 | # annotations: Remove ALL annotations | ||
100 | # tags: Remove ALL tags | ||
101 | # entries: Remove ALL entries | ||
102 | # confirm: Are you really really sure? (THIS CAN'T BE UNDONE) | ||
96 | form_password: | 103 | form_password: |
97 | old_password_label: 'Parola veche' | 104 | old_password_label: 'Parola veche' |
98 | new_password_label: 'Parola nouă' | 105 | new_password_label: 'Parola nouă' |
@@ -462,6 +469,9 @@ flashes: | |||
462 | # tagging_rules_deleted: 'Tagging rule deleted' | 469 | # tagging_rules_deleted: 'Tagging rule deleted' |
463 | # user_added: 'User "%username%" added' | 470 | # user_added: 'User "%username%" added' |
464 | # rss_token_updated: 'RSS token updated' | 471 | # rss_token_updated: 'RSS token updated' |
472 | # annotations_reset: Annotations reset | ||
473 | # tags_reset: Tags reset | ||
474 | # entries_reset: Entries reset | ||
465 | entry: | 475 | entry: |
466 | notice: | 476 | notice: |
467 | # entry_already_saved: 'Entry already saved on %date%' | 477 | # entry_already_saved: 'Entry already saved on %date%' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 41e8e576..8e429653 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml | |||
@@ -89,10 +89,17 @@ config: | |||
89 | email_label: 'E-posta' | 89 | email_label: 'E-posta' |
90 | twoFactorAuthentication_label: 'İki adımlı doğrulama' | 90 | twoFactorAuthentication_label: 'İki adımlı doğrulama' |
91 | delete: | 91 | delete: |
92 | # title: Delete my account (danger zone !) | 92 | # title: Delete my account (a.k.a danger zone) |
93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. | 93 | # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. |
94 | # confirm: Are you really sure? (it can't be UNDONE) | 94 | # confirm: Are you really sure? (THIS CAN'T BE UNDONE) |
95 | # button: Delete my account | 95 | # button: Delete my account |
96 | reset: | ||
97 | # title: Reset area (a.k.a danger zone) | ||
98 | # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE. | ||
99 | # annotations: Remove ALL annotations | ||
100 | # tags: Remove ALL tags | ||
101 | # entries: Remove ALL entries | ||
102 | # confirm: Are you really really sure? (THIS CAN'T BE UNDONE) | ||
96 | form_password: | 103 | form_password: |
97 | old_password_label: 'Eski şifre' | 104 | old_password_label: 'Eski şifre' |
98 | new_password_label: 'Yeni şifre' | 105 | new_password_label: 'Yeni şifre' |
@@ -461,6 +468,9 @@ flashes: | |||
461 | tagging_rules_deleted: 'Tagging rule deleted' | 468 | tagging_rules_deleted: 'Tagging rule deleted' |
462 | user_added: 'User "%username%" added' | 469 | user_added: 'User "%username%" added' |
463 | rss_token_updated: 'RSS token updated' | 470 | rss_token_updated: 'RSS token updated' |
471 | # annotations_reset: Annotations reset | ||
472 | # tags_reset: Tags reset | ||
473 | # entries_reset: Entries reset | ||
464 | entry: | 474 | entry: |
465 | notice: | 475 | notice: |
466 | entry_already_saved: 'Entry already saved on %date%' | 476 | entry_already_saved: 'Entry already saved on %date%' |
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 8434508d..79826e0f 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 | |||
@@ -168,6 +168,22 @@ | |||
168 | {{ form_widget(form.user._token) }} | 168 | {{ form_widget(form.user._token) }} |
169 | </form> | 169 | </form> |
170 | 170 | ||
171 | <br /><hr /><br /> | ||
172 | |||
173 | <div class="row"> | ||
174 | <h5>{{ 'config.reset.title'|trans }}</h5> | ||
175 | <p>{{ 'config.reset.description'|trans }}</p> | ||
176 | <a href="{{ path('config_reset', { type: 'annotations'}) }}" onclick="return confirm('{{ 'config.reset.confirm'|trans|escape('js') }}')" class="waves-effect waves-light btn red"> | ||
177 | {{ 'config.reset.annotations'|trans }} | ||
178 | </a> | ||
179 | <a href="{{ path('config_reset', { type: 'tags'}) }}" onclick="return confirm('{{ 'config.reset.confirm'|trans|escape('js') }}')" class="waves-effect waves-light btn red"> | ||
180 | {{ 'config.reset.tags'|trans }} | ||
181 | </a> | ||
182 | <a href="{{ path('config_reset', { type: 'entries'}) }}" onclick="return confirm('{{ 'config.reset.confirm'|trans|escape('js') }}')" class="waves-effect waves-light btn red"> | ||
183 | {{ 'config.reset.entries'|trans }} | ||
184 | </a> | ||
185 | </div> | ||
186 | |||
171 | {% if enabled_users > 1 %} | 187 | {% if enabled_users > 1 %} |
172 | <br /><hr /><br /> | 188 | <br /><hr /><br /> |
173 | 189 | ||
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index 5faa0130..8d0644d1 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php | |||
@@ -5,6 +5,9 @@ namespace Tests\Wallabag\CoreBundle\Controller; | |||
5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | 5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; |
6 | use Wallabag\CoreBundle\Entity\Config; | 6 | use Wallabag\CoreBundle\Entity\Config; |
7 | use Wallabag\UserBundle\Entity\User; | 7 | use Wallabag\UserBundle\Entity\User; |
8 | use Wallabag\CoreBundle\Entity\Entry; | ||
9 | use Wallabag\CoreBundle\Entity\Tag; | ||
10 | use Wallabag\AnnotationBundle\Entity\Annotation; | ||
8 | 11 | ||
9 | class ConfigControllerTest extends WallabagCoreTestCase | 12 | class ConfigControllerTest extends WallabagCoreTestCase |
10 | { | 13 | { |
@@ -690,4 +693,146 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
690 | 693 | ||
691 | $this->assertEmpty($entries); | 694 | $this->assertEmpty($entries); |
692 | } | 695 | } |
696 | |||
697 | public function testReset() | ||
698 | { | ||
699 | $this->logInAs('empty'); | ||
700 | $client = $this->getClient(); | ||
701 | |||
702 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | ||
703 | |||
704 | $user = static::$kernel->getContainer()->get('security.token_storage')->getToken()->getUser(); | ||
705 | |||
706 | $tag = new Tag(); | ||
707 | $tag->setLabel('super'); | ||
708 | $em->persist($tag); | ||
709 | |||
710 | $entry = new Entry($user); | ||
711 | $entry->setUrl('http://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html'); | ||
712 | $entry->setContent('Youhou'); | ||
713 | $entry->setTitle('Youhou'); | ||
714 | $entry->addTag($tag); | ||
715 | $em->persist($entry); | ||
716 | |||
717 | $entry2 = new Entry($user); | ||
718 | $entry2->setUrl('http://www.lemonde.de/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html'); | ||
719 | $entry2->setContent('Youhou'); | ||
720 | $entry2->setTitle('Youhou'); | ||
721 | $entry2->addTag($tag); | ||
722 | $em->persist($entry2); | ||
723 | |||
724 | $annotation = new Annotation($user); | ||
725 | $annotation->setText('annotated'); | ||
726 | $annotation->setQuote('annotated'); | ||
727 | $annotation->setRanges([]); | ||
728 | $annotation->setEntry($entry); | ||
729 | $em->persist($annotation); | ||
730 | |||
731 | $em->flush(); | ||
732 | |||
733 | // reset annotations | ||
734 | $crawler = $client->request('GET', '/config#set3'); | ||
735 | |||
736 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
737 | |||
738 | $crawler = $client->click($crawler->selectLink('config.reset.annotations')->link()); | ||
739 | |||
740 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
741 | $this->assertContains('flashes.config.notice.annotations_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]); | ||
742 | |||
743 | $annotationsReset = $em | ||
744 | ->getRepository('WallabagAnnotationBundle:Annotation') | ||
745 | ->findAnnotationsByPageId($entry->getId(), $user->getId()); | ||
746 | |||
747 | $this->assertEmpty($annotationsReset, 'Annotations were reset'); | ||
748 | |||
749 | // reset tags | ||
750 | $crawler = $client->request('GET', '/config#set3'); | ||
751 | |||
752 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
753 | |||
754 | $crawler = $client->click($crawler->selectLink('config.reset.tags')->link()); | ||
755 | |||
756 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
757 | $this->assertContains('flashes.config.notice.tags_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]); | ||
758 | |||
759 | $tagReset = $em | ||
760 | ->getRepository('WallabagCoreBundle:Tag') | ||
761 | ->countAllTags($user->getId()); | ||
762 | |||
763 | $this->assertEquals(0, $tagReset, 'Tags were reset'); | ||
764 | |||
765 | // reset entries | ||
766 | $crawler = $client->request('GET', '/config#set3'); | ||
767 | |||
768 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
769 | |||
770 | $crawler = $client->click($crawler->selectLink('config.reset.entries')->link()); | ||
771 | |||
772 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
773 | $this->assertContains('flashes.config.notice.entries_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]); | ||
774 | |||
775 | $entryReset = $em | ||
776 | ->getRepository('WallabagCoreBundle:Entry') | ||
777 | ->countAllEntriesByUsername($user->getId()); | ||
778 | |||
779 | $this->assertEquals(0, $entryReset, 'Entries were reset'); | ||
780 | } | ||
781 | |||
782 | public function testResetEntriesCascade() | ||
783 | { | ||
784 | $this->logInAs('empty'); | ||
785 | $client = $this->getClient(); | ||
786 | |||
787 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | ||
788 | |||
789 | $user = static::$kernel->getContainer()->get('security.token_storage')->getToken()->getUser(); | ||
790 | |||
791 | $tag = new Tag(); | ||
792 | $tag->setLabel('super'); | ||
793 | $em->persist($tag); | ||
794 | |||
795 | $entry = new Entry($user); | ||
796 | $entry->setUrl('http://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html'); | ||
797 | $entry->setContent('Youhou'); | ||
798 | $entry->setTitle('Youhou'); | ||
799 | $entry->addTag($tag); | ||
800 | $em->persist($entry); | ||
801 | |||
802 | $annotation = new Annotation($user); | ||
803 | $annotation->setText('annotated'); | ||
804 | $annotation->setQuote('annotated'); | ||
805 | $annotation->setRanges([]); | ||
806 | $annotation->setEntry($entry); | ||
807 | $em->persist($annotation); | ||
808 | |||
809 | $em->flush(); | ||
810 | |||
811 | $crawler = $client->request('GET', '/config#set3'); | ||
812 | |||
813 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
814 | |||
815 | $crawler = $client->click($crawler->selectLink('config.reset.entries')->link()); | ||
816 | |||
817 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
818 | $this->assertContains('flashes.config.notice.entries_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]); | ||
819 | |||
820 | $entryReset = $em | ||
821 | ->getRepository('WallabagCoreBundle:Entry') | ||
822 | ->countAllEntriesByUsername($user->getId()); | ||
823 | |||
824 | $this->assertEquals(0, $entryReset, 'Entries were reset'); | ||
825 | |||
826 | $tagReset = $em | ||
827 | ->getRepository('WallabagCoreBundle:Tag') | ||
828 | ->countAllTags($user->getId()); | ||
829 | |||
830 | $this->assertEquals(0, $tagReset, 'Tags were reset'); | ||
831 | |||
832 | $annotationsReset = $em | ||
833 | ->getRepository('WallabagAnnotationBundle:Annotation') | ||
834 | ->findAnnotationsByPageId($entry->getId(), $user->getId()); | ||
835 | |||
836 | $this->assertEmpty($annotationsReset, 'Annotations were reset'); | ||
837 | } | ||
693 | } | 838 | } |