]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #3266 from egilli/export-domain-as-author
authorJérémy Benoist <j0k3r@users.noreply.github.com>
Tue, 11 Jul 2017 07:21:49 +0000 (09:21 +0200)
committerGitHub <noreply@github.com>
Tue, 11 Jul 2017 07:21:49 +0000 (09:21 +0200)
Use the article publisher as author for exported files

app/config/config.yml
src/Wallabag/AnnotationBundle/Entity/Annotation.php
src/Wallabag/ApiBundle/Controller/DeveloperController.php
src/Wallabag/CoreBundle/Entity/Entry.php
src/Wallabag/CoreBundle/Entity/SiteCredential.php
src/Wallabag/CoreBundle/Helper/EntityTimestampsTrait.php [new file with mode: 0644]
src/Wallabag/UserBundle/Entity/User.php
tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php

index 2bc5e3b359292de4e5ff477d2fc976b81ab484f0..d37ed227b4db44e6937b3bd3c4d9639f0c2ae75c 100644 (file)
@@ -110,7 +110,7 @@ fos_rest:
             epub: true
             mobi: true
         templating_formats:
-            html: true
+            html: false
         force_redirects:
             html: true
         failed_validation: HTTP_BAD_REQUEST
index 04d83001777cefee8f80c18a2ac00a3359b62165..a180d504786c866686a70e34b8510d133e9e3b11 100644 (file)
@@ -10,6 +10,7 @@ use JMS\Serializer\Annotation\SerializedName;
 use JMS\Serializer\Annotation\VirtualProperty;
 use Symfony\Component\Validator\Constraints as Assert;
 use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
 use Wallabag\UserBundle\Entity\User;
 
 /**
@@ -22,6 +23,8 @@ use Wallabag\UserBundle\Entity\User;
  */
 class Annotation
 {
+    use EntityTimestampsTrait;
+
     /**
      * @var int
      *
@@ -133,18 +136,6 @@ class Annotation
         return $this->text;
     }
 
-    /**
-     * @ORM\PrePersist
-     * @ORM\PreUpdate
-     */
-    public function timestamps()
-    {
-        if (null === $this->createdAt) {
-            $this->createdAt = new \DateTime();
-        }
-        $this->updatedAt = new \DateTime();
-    }
-
     /**
      * Get created.
      *
index c8a1c6355b9f11a1b7a15dc4acd13eb282811b73..c7178017ef349f7a95e0eb35d28a3f93dd2e75a2 100644 (file)
@@ -43,7 +43,7 @@ class DeveloperController extends Controller
         $clientForm->handleRequest($request);
 
         if ($clientForm->isSubmitted() && $clientForm->isValid()) {
-            $client->setAllowedGrantTypes(['client_credentials', 'token', 'authorization_code', 'password', 'refresh_token']);
+            $client->setAllowedGrantTypes(['token', 'authorization_code', 'password', 'refresh_token']);
             $em->persist($client);
             $em->flush();
 
index cba72d31e07385ba736638df84c14862a31cf5a1..61d01bdcdadd5f0a52ceb3e66f08ae1eb0228cb9 100644 (file)
@@ -12,6 +12,7 @@ use JMS\Serializer\Annotation\VirtualProperty;
 use JMS\Serializer\Annotation\XmlRoot;
 use Symfony\Component\Validator\Constraints as Assert;
 use Wallabag\AnnotationBundle\Entity\Annotation;
+use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
 use Wallabag\UserBundle\Entity\User;
 
 /**
@@ -32,6 +33,8 @@ use Wallabag\UserBundle\Entity\User;
  */
 class Entry
 {
+    use EntityTimestampsTrait;
+
     /** @Serializer\XmlAttribute */
     /**
      * @var int
@@ -472,19 +475,6 @@ class Entry
         return $this->updatedAt;
     }
 
-    /**
-     * @ORM\PrePersist
-     * @ORM\PreUpdate
-     */
-    public function timestamps()
-    {
-        if (null === $this->createdAt) {
-            $this->createdAt = new \DateTime();
-        }
-
-        $this->updatedAt = new \DateTime();
-    }
-
     /**
      * @return ArrayCollection<Annotation>
      */
index 4d6557c59986845bd6046d6268db8eb94372a203..ac714359d6b817b5fc7a901ae84dc1e85cac52e6 100644 (file)
@@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Entity;
 
 use Doctrine\ORM\Mapping as ORM;
 use Symfony\Component\Validator\Constraints as Assert;
+use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
 use Wallabag\UserBundle\Entity\User;
 
 /**
@@ -15,6 +16,8 @@ use Wallabag\UserBundle\Entity\User;
  */
 class SiteCredential
 {
+    use EntityTimestampsTrait;
+
     /**
      * @var int
      *
@@ -182,14 +185,4 @@ class SiteCredential
     {
         return $this->user;
     }
-
-    /**
-     * @ORM\PrePersist
-     */
-    public function timestamps()
-    {
-        if (null === $this->createdAt) {
-            $this->createdAt = new \DateTime();
-        }
-    }
 }
diff --git a/src/Wallabag/CoreBundle/Helper/EntityTimestampsTrait.php b/src/Wallabag/CoreBundle/Helper/EntityTimestampsTrait.php
new file mode 100644 (file)
index 0000000..1b1ff54
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+namespace Wallabag\CoreBundle\Helper;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Trait to handle created & updated date of an Entity.
+ */
+trait EntityTimestampsTrait
+{
+    /**
+     * @ORM\PrePersist
+     * @ORM\PreUpdate
+     */
+    public function timestamps()
+    {
+        if (null === $this->createdAt) {
+            $this->createdAt = new \DateTime();
+        }
+
+        $this->updatedAt = new \DateTime();
+    }
+}
index 53c327f9b92baad663aea08adaf80f4e5f4993f5..48446e3c1a6e64be30725ac03b77e2a636313fd4 100644 (file)
@@ -15,6 +15,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
 use Wallabag\ApiBundle\Entity\Client;
 use Wallabag\CoreBundle\Entity\Config;
 use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
 
 /**
  * User.
@@ -29,6 +30,8 @@ use Wallabag\CoreBundle\Entity\Entry;
  */
 class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterface
 {
+    use EntityTimestampsTrait;
+
     /** @Serializer\XmlAttribute */
     /**
      * @var int
@@ -138,19 +141,6 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
         $this->roles = ['ROLE_USER'];
     }
 
-    /**
-     * @ORM\PrePersist
-     * @ORM\PreUpdate
-     */
-    public function timestamps()
-    {
-        if (null === $this->createdAt) {
-            $this->createdAt = new \DateTime();
-        }
-
-        $this->updatedAt = new \DateTime();
-    }
-
     /**
      * Set name.
      *
index 2caeccf5f0fc8bc9275fa79e972c0a4ca7f3e6d2..e9e5ee3b1fc575ba9ceca4476e239c8b983c2a10 100644 (file)
@@ -34,7 +34,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase
         $this->assertContains('My app', $alert[0]);
     }
 
-    public function testCreateTokenFromPasswords()
+    public function testCreateToken()
     {
         $client = $this->getClient();
         $apiClient = $this->createApiClientForUser('admin');
@@ -56,26 +56,6 @@ class DeveloperControllerTest extends WallabagCoreTestCase
         $this->assertArrayHasKey('refresh_token', $data);
     }
 
-    public function testCreateTokenFromClientCredentialsOnly()
-    {
-        $client = $this->getClient();
-        $apiClient = $this->createApiClientForUser('admin', ['client_credentials']);
-
-        $client->request('POST', '/oauth/v2/token', [
-            'grant_type' => 'client_credentials',
-            'client_id' => $apiClient->getPublicId(),
-            'client_secret' => $apiClient->getSecret(),
-        ]);
-
-        $this->assertSame(200, $client->getResponse()->getStatusCode());
-
-        $data = json_decode($client->getResponse()->getContent(), true);
-        $this->assertArrayHasKey('access_token', $data);
-        $this->assertArrayHasKey('expires_in', $data);
-        $this->assertArrayHasKey('token_type', $data);
-        // Client Credentials created-clients have no refresh tokens
-    }
-
     public function testListingClient()
     {
         $this->logInAs('admin');