From c43e7daefedea7873bea74bc84214e2e36c0c5ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 18 Mar 2016 10:28:26 +0100 Subject: [PATCH 001/179] initial commit --- ChillEventBundle.php | 9 +++ Controller/DefaultController.php | 13 +++++ DependencyInjection/ChillEventExtension.php | 45 +++++++++++++++ DependencyInjection/Configuration.php | 29 ++++++++++ Resources/config/routing.yml | 3 + Resources/config/services.yml | 4 ++ Resources/views/Default/index.html.twig | 1 + Tests/Controller/DefaultControllerTest.php | 17 ++++++ composer.json | 61 +++++++++++++++++++++ 9 files changed, 182 insertions(+) create mode 100644 ChillEventBundle.php create mode 100644 Controller/DefaultController.php create mode 100644 DependencyInjection/ChillEventExtension.php create mode 100644 DependencyInjection/Configuration.php create mode 100644 Resources/config/routing.yml create mode 100644 Resources/config/services.yml create mode 100644 Resources/views/Default/index.html.twig create mode 100644 Tests/Controller/DefaultControllerTest.php create mode 100644 composer.json diff --git a/ChillEventBundle.php b/ChillEventBundle.php new file mode 100644 index 000000000..dc040dac6 --- /dev/null +++ b/ChillEventBundle.php @@ -0,0 +1,9 @@ +render('ChillEventBundle:Default:index.html.twig', array('name' => $name)); + } +} diff --git a/DependencyInjection/ChillEventExtension.php b/DependencyInjection/ChillEventExtension.php new file mode 100644 index 000000000..89eb98c57 --- /dev/null +++ b/DependencyInjection/ChillEventExtension.php @@ -0,0 +1,45 @@ +processConfiguration($configuration, $configs); + + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.yml'); + } + + /* (non-PHPdoc) + * @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend() + */ + public function prepend(ContainerBuilder $container) + { + + //add routes for custom bundle + $container->prependExtensionConfig('chill_main', array( + 'routing' => array( + 'resources' => array( + '@ChillEventBundle/Resources/config/routing.yml' + ) + ) + )); + } +} diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php new file mode 100644 index 000000000..26441ce71 --- /dev/null +++ b/DependencyInjection/Configuration.php @@ -0,0 +1,29 @@ +root('chill_event'); + + // Here you should define the parameters that are allowed to + // configure your bundle. See the documentation linked above for + // more information on that topic. + + return $treeBuilder; + } +} diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml new file mode 100644 index 000000000..712a131e6 --- /dev/null +++ b/Resources/config/routing.yml @@ -0,0 +1,3 @@ +chill_event_homepage: + path: /hello/{name} + defaults: { _controller: ChillEventBundle:Default:index } diff --git a/Resources/config/services.yml b/Resources/config/services.yml new file mode 100644 index 000000000..d2cfb62f0 --- /dev/null +++ b/Resources/config/services.yml @@ -0,0 +1,4 @@ +services: +# chill_event.example: +# class: Chill\EventBundle\Example +# arguments: [@service_id, "plain_value", %parameter%] diff --git a/Resources/views/Default/index.html.twig b/Resources/views/Default/index.html.twig new file mode 100644 index 000000000..4ce626e9b --- /dev/null +++ b/Resources/views/Default/index.html.twig @@ -0,0 +1 @@ +Hello {{ name }}! diff --git a/Tests/Controller/DefaultControllerTest.php b/Tests/Controller/DefaultControllerTest.php new file mode 100644 index 000000000..5c2a813f4 --- /dev/null +++ b/Tests/Controller/DefaultControllerTest.php @@ -0,0 +1,17 @@ +request('GET', '/hello/Fabien'); + + $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0); + } +} diff --git a/composer.json b/composer.json new file mode 100644 index 000000000..14fc5af95 --- /dev/null +++ b/composer.json @@ -0,0 +1,61 @@ +{ + "name": "chill-project/event", + "description": "This bundle extend chill software. This bundle allow to define event and participation to those events.", + "type": "symfony-bundle", + "license": "AGPL-3.0", + "keywords" : ["chill", "social work"], + "homepage" : "https://git.framasoft.org/Chill-project/Chill-Group", + "autoload": { + "psr-4": { "Chill\\EventBundle\\": "" } + }, + "support": { + "issues": "https://git.framasoft.org/Chill-project/Chill-Event/issues", + "source": "https://git.framasoft.org/Chill-project/Chill-Event", + "docs" : "http://docs.chill.social", + "email": "dev@listes.chill.social" + }, + "authors": [ + { + "name": "Champs-Libres", + "email": "info@champs-libres.coop" + } + ], + "require": { + "twig/extensions": "^1.2", + "symfony/assetic-bundle": "~2.3", + "symfony/framework-bundle": "~2.7", + "symfony/yaml": "~2.8", + "symfony/symfony": "~2.8", + "doctrine/dbal": "~2.5", + "doctrine/orm": "~2.4", + "doctrine/common": "~2.4", + "doctrine/doctrine-bundle": "~1.2", + "chill-project/main": "dev-master@dev", + "chill-project/person": "dev-master@dev", + "champs-libres/composer-bundle-migration": "~1.0", + "doctrine/doctrine-migrations-bundle": "~1.1", + "chill-project/custom-fields": "dev-master@dev", + "doctrine/migrations": "~1.0", + "monolog/monolog": "^1.14" + }, + "require-dev": { + "doctrine/doctrine-fixtures-bundle": "~2.2", + "fzaninotto/faker": "~1", + "symfony/monolog-bundle": "^2.7", + "sensio/generator-bundle": "^2.5" + }, + "suggest" : { + "chill-project/group": "dev-master@dev" + }, + "scripts": { + "post-install-cmd": [ + "ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations" + ], + "post-update-cmd": [ + "ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations" + ] + }, + "extra": { + "app-migrations-dir": "Resources/test/Fixtures/App/DoctrineMigrations" + } +} From f3b00ac69b2c0ac250ca0e608e0e23c4f10a6108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 18 Mar 2016 10:31:17 +0100 Subject: [PATCH 002/179] add license and readme --- LICENSE.txt | 661 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 16 ++ 2 files changed, 677 insertions(+) create mode 100644 LICENSE.txt create mode 100644 README.md diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 000000000..dba13ed2d --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md new file mode 100644 index 000000000..2aad96db5 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +Chill Event Bundle +==================== + +This bundle extend [chill software](https://www.chill.social). This bundle allow to define event and participation to those events. + +Documentation & installation +============================ + +This bundle can be installed with the Chill software. + +Read documentation here : http://chill.readthedocs.org + +Issues and bug tracking +======================= + +The issues tracker is here : https://git.framasoft.org/Chill-project/Chill-Event/issues From 11d58a457ae3affeecb57b010c503a2a0872d745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 18 Mar 2016 11:22:09 +0100 Subject: [PATCH 003/179] initialize entities --- Entity/Event.php | 130 +++++++++++++ Entity/EventType.php | 169 +++++++++++++++++ Entity/Participation.php | 171 ++++++++++++++++++ Entity/Role.php | 113 ++++++++++++ Entity/Status.php | 114 ++++++++++++ Resources/config/doctrine/Event.orm.yml | 20 ++ Resources/config/doctrine/EventType.orm.yml | 22 +++ .../config/doctrine/Participation.orm.yml | 23 +++ Resources/config/doctrine/Role.orm.yml | 19 ++ Resources/config/doctrine/Status.orm.yml | 19 ++ 10 files changed, 800 insertions(+) create mode 100644 Entity/Event.php create mode 100644 Entity/EventType.php create mode 100644 Entity/Participation.php create mode 100644 Entity/Role.php create mode 100644 Entity/Status.php create mode 100644 Resources/config/doctrine/Event.orm.yml create mode 100644 Resources/config/doctrine/EventType.orm.yml create mode 100644 Resources/config/doctrine/Participation.orm.yml create mode 100644 Resources/config/doctrine/Role.orm.yml create mode 100644 Resources/config/doctrine/Status.orm.yml diff --git a/Entity/Event.php b/Entity/Event.php new file mode 100644 index 000000000..d3e6a8881 --- /dev/null +++ b/Entity/Event.php @@ -0,0 +1,130 @@ +participations = new \Doctrine\Common\Collections\ArrayCollection(); + } + + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set label + * + * @param string $label + * + * @return Event + */ + public function setLabel($label) + { + $this->label = $label; + + return $this; + } + + /** + * Get label + * + * @return string + */ + public function getLabel() + { + return $this->label; + } + + /** + * Set date + * + * @param \DateTime $date + * + * @return Event + */ + public function setDate($date) + { + $this->date = $date; + + return $this; + } + + /** + * Get date + * + * @return \DateTime + */ + public function getDate() + { + return $this->date; + } + + /** + * Add participation + * + * @param \Chill\EventBundle\Entity\Participation $participation + * + * @return Event + */ + public function addParticipation(\Chill\EventBundle\Entity\Participation $participation) + { + $this->participations[] = $participation; + + return $this; + } + + /** + * Remove participation + * + * @param \Chill\EventBundle\Entity\Participation $participation + */ + public function removeParticipation(\Chill\EventBundle\Entity\Participation $participation) + { + $this->participations->removeElement($participation); + } + + /** + * Get participations + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getParticipations() + { + return $this->participations; + } +} diff --git a/Entity/EventType.php b/Entity/EventType.php new file mode 100644 index 000000000..64c240b53 --- /dev/null +++ b/Entity/EventType.php @@ -0,0 +1,169 @@ +id; + } + + /** + * Set label + * + * @param array $label + * + * @return EventType + */ + public function setLabel($label) + { + $this->label = $label; + + return $this; + } + + /** + * Get label + * + * @return array + */ + public function getLabel() + { + return $this->label; + } + + /** + * Set active + * + * @param boolean $active + * + * @return EventType + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } + /** + * @var \Doctrine\Common\Collections\Collection + */ + private $roles; + + /** + * @var \Doctrine\Common\Collections\Collection + */ + private $statuses; + + /** + * Constructor + */ + public function __construct() + { + $this->roles = new \Doctrine\Common\Collections\ArrayCollection(); + $this->statuses = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Add role + * + * @param \Chill\EventBundle\Entity\Role $role + * + * @return EventType + */ + public function addRole(\Chill\EventBundle\Entity\Role $role) + { + $this->roles[] = $role; + + return $this; + } + + /** + * Remove role + * + * @param \Chill\EventBundle\Entity\Role $role + */ + public function removeRole(\Chill\EventBundle\Entity\Role $role) + { + $this->roles->removeElement($role); + } + + /** + * Get roles + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getRoles() + { + return $this->roles; + } + + /** + * Add status + * + * @param \Chill\EventBundle\Entity\Status $status + * + * @return EventType + */ + public function addStatus(\Chill\EventBundle\Entity\Status $status) + { + $this->statuses[] = $status; + + return $this; + } + + /** + * Remove status + * + * @param \Chill\EventBundle\Entity\Status $status + */ + public function removeStatus(\Chill\EventBundle\Entity\Status $status) + { + $this->statuses->removeElement($status); + } + + /** + * Get statuses + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getStatuses() + { + return $this->statuses; + } +} diff --git a/Entity/Participation.php b/Entity/Participation.php new file mode 100644 index 000000000..2c6fdb2f5 --- /dev/null +++ b/Entity/Participation.php @@ -0,0 +1,171 @@ +id; + } + + /** + * Set lastUpdate + * + * @param \DateTime $lastUpdate + * + * @return Participation + */ + public function setLastUpdate($lastUpdate) + { + $this->lastUpdate = $lastUpdate; + + return $this; + } + + /** + * Get lastUpdate + * + * @return \DateTime + */ + public function getLastUpdate() + { + return $this->lastUpdate; + } + + + /** + * Set event + * + * @param \Chill\EventBundle\Entity\Event $event + * + * @return Participation + */ + public function setEvent(\Chill\EventBundle\Entity\Event $event = null) + { + $this->event = $event; + + return $this; + } + + /** + * Get event + * + * @return \Chill\EventBundle\Entity\Event + */ + public function getEvent() + { + return $this->event; + } + + /** + * Set person + * + * @param \Chill\PersonBundle\Entity\Person $person + * + * @return Participation + */ + public function setPerson(\Chill\PersonBundle\Entity\Person $person = null) + { + $this->person = $person; + + return $this; + } + + /** + * Get person + * + * @return \Chill\PersonBundle\Entity\Person + */ + public function getPerson() + { + return $this->person; + } + + /** + * Set role + * + * @param \Chill\EventBundle\Entity\Role $role + * + * @return Participation + */ + public function setRole(\Chill\EventBundle\Entity\Role $role = null) + { + $this->role = $role; + + return $this; + } + + /** + * Get role + * + * @return \Chill\EventBundle\Entity\Role + */ + public function getRole() + { + return $this->role; + } + + /** + * Set status + * + * @param \Chill\EventBundle\Entity\Status $status + * + * @return Participation + */ + public function setStatus(\Chill\EventBundle\Entity\Status $status = null) + { + $this->status = $status; + + return $this; + } + + /** + * Get status + * + * @return \Chill\EventBundle\Entity\Status + */ + public function getStatus() + { + return $this->status; + } +} diff --git a/Entity/Role.php b/Entity/Role.php new file mode 100644 index 000000000..fe98414ab --- /dev/null +++ b/Entity/Role.php @@ -0,0 +1,113 @@ +id; + } + + /** + * Set label + * + * @param array $label + * + * @return Role + */ + public function setLabel($label) + { + $this->label = $label; + + return $this; + } + + /** + * Get label + * + * @return array + */ + public function getLabel() + { + return $this->label; + } + + /** + * Set active + * + * @param boolean $active + * + * @return Role + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } + + + /** + * Set type + * + * @param \Chill\EventBundle\Entity\EventType $type + * + * @return Role + */ + public function setType(\Chill\EventBundle\Entity\EventType $type = null) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return \Chill\EventBundle\Entity\EventType + */ + public function getType() + { + return $this->type; + } +} diff --git a/Entity/Status.php b/Entity/Status.php new file mode 100644 index 000000000..d39a325c3 --- /dev/null +++ b/Entity/Status.php @@ -0,0 +1,114 @@ +id; + } + + /** + * Set label + * + * @param array $label + * + * @return Status + */ + public function setLabel($label) + { + $this->label = $label; + + return $this; + } + + /** + * Get label + * + * @return array + */ + public function getLabel() + { + return $this->label; + } + + + /** + * Set active + * + * @param boolean $active + * + * @return Status + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } + + + /** + * Set type + * + * @param \Chill\EventBundle\Entity\EventType $type + * + * @return Status + */ + public function setType(\Chill\EventBundle\Entity\EventType $type = null) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return \Chill\EventBundle\Entity\EventType + */ + public function getType() + { + return $this->type; + } +} diff --git a/Resources/config/doctrine/Event.orm.yml b/Resources/config/doctrine/Event.orm.yml new file mode 100644 index 000000000..3bc880597 --- /dev/null +++ b/Resources/config/doctrine/Event.orm.yml @@ -0,0 +1,20 @@ +Chill\EventBundle\Entity\Event: + type: entity + table: chill_event_event + id: + id: + type: integer + id: true + generator: + strategy: AUTO + fields: + label: + type: string + length: '150' + date: + type: date + oneToMany: + participations: + targetEntity: Chill\EventBundle\Entity\Participation + mappedBy: event + lifecycleCallbacks: { } diff --git a/Resources/config/doctrine/EventType.orm.yml b/Resources/config/doctrine/EventType.orm.yml new file mode 100644 index 000000000..17bc5cadb --- /dev/null +++ b/Resources/config/doctrine/EventType.orm.yml @@ -0,0 +1,22 @@ +Chill\EventBundle\Entity\EventType: + type: entity + table: chill_event_event_type + id: + id: + type: integer + id: true + generator: + strategy: AUTO + fields: + label: + type: json_array + active: + type: boolean + oneToMany: + roles: + targetEntity: Chill\EventBundle\Entity\Role + mappedBy: type + statuses: + targetEntity: Chill\EventBundle\Entity\Status + mappedBy: type + lifecycleCallbacks: { } diff --git a/Resources/config/doctrine/Participation.orm.yml b/Resources/config/doctrine/Participation.orm.yml new file mode 100644 index 000000000..24858afc4 --- /dev/null +++ b/Resources/config/doctrine/Participation.orm.yml @@ -0,0 +1,23 @@ +Chill\EventBundle\Entity\Participation: + type: entity + table: chill_event_participation + id: + id: + type: integer + id: true + generator: + strategy: AUTO + fields: + lastUpdate: + type: datetime + manyToOne: + event: + targetEntity: Chill\EventBundle\Entity\Event + inversedBy: participations + person: + targetEntity: Chill\PersonBundle\Entity\Person + role: + targetEntity: Chill\EventBundle\Entity\Role + status: + targetEntity: Chill\EventBundle\Entity\Status + lifecycleCallbacks: { } diff --git a/Resources/config/doctrine/Role.orm.yml b/Resources/config/doctrine/Role.orm.yml new file mode 100644 index 000000000..8d1723c37 --- /dev/null +++ b/Resources/config/doctrine/Role.orm.yml @@ -0,0 +1,19 @@ +Chill\EventBundle\Entity\Role: + type: entity + table: chill_event_role + id: + id: + type: integer + id: true + generator: + strategy: AUTO + fields: + label: + type: json_array + active: + type: boolean + manyToOne: + type: + targetEntity: Chill\EventBundle\Entity\EventType + inversedBy: roles + lifecycleCallbacks: { } diff --git a/Resources/config/doctrine/Status.orm.yml b/Resources/config/doctrine/Status.orm.yml new file mode 100644 index 000000000..2849b7522 --- /dev/null +++ b/Resources/config/doctrine/Status.orm.yml @@ -0,0 +1,19 @@ +Chill\EventBundle\Entity\Status: + type: entity + table: chill_event_status + id: + id: + type: integer + id: true + generator: + strategy: AUTO + fields: + label: + type: json_array + active: + type: boolean + manyToOne: + type: + targetEntity: Chill\EventBundle\Entity\EventType + inversedBy: statuses + lifecycleCallbacks: { } From cd7e9a9e2bcd7d280704fb01ef49257ca2e64d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 18 Mar 2016 11:33:59 +0100 Subject: [PATCH 004/179] add migration file --- .../migrations/Version20160318111334.php | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 Resources/migrations/Version20160318111334.php diff --git a/Resources/migrations/Version20160318111334.php b/Resources/migrations/Version20160318111334.php new file mode 100644 index 000000000..6ab4d5004 --- /dev/null +++ b/Resources/migrations/Version20160318111334.php @@ -0,0 +1,116 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('CREATE SEQUENCE chill_event_event_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_event_role_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_event_status_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_event_event_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_event_participation_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_event_event_type (' + . 'id INT NOT NULL, label JSON NOT NULL, ' + . 'active BOOLEAN NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_event_role (' + . 'id INT NOT NULL, ' + . 'type_id INT DEFAULT NULL, ' + . 'label JSON NOT NULL, ' + . 'active BOOLEAN NOT NULL, ' + . 'PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_AA714E54C54C8C93 ON chill_event_role (type_id)'); + $this->addSql('CREATE TABLE chill_event_status (id INT NOT NULL, ' + . 'type_id INT DEFAULT NULL, ' + . 'label JSON NOT NULL, ' + . 'active BOOLEAN NOT NULL, ' + . 'PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_A6CC85D0C54C8C93 ON chill_event_status (type_id)'); + $this->addSql('CREATE TABLE chill_event_event (' + . 'id INT NOT NULL, ' + . 'label VARCHAR(150) NOT NULL, ' + . 'date DATE NOT NULL, ' + . 'PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_event_participation (' + . 'id INT NOT NULL, ' + . 'event_id INT DEFAULT NULL, ' + . 'person_id INT DEFAULT NULL, ' + . 'role_id INT DEFAULT NULL, ' + . 'status_id INT DEFAULT NULL, ' + . 'lastUpdate TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, ' + . 'PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_4E7768AC71F7E88B ON chill_event_participation (event_id)'); + $this->addSql('CREATE INDEX IDX_4E7768AC217BBB47 ON chill_event_participation (person_id)'); + $this->addSql('CREATE INDEX IDX_4E7768ACD60322AC ON chill_event_participation (role_id)'); + $this->addSql('CREATE INDEX IDX_4E7768AC6BF700BD ON chill_event_participation (status_id)'); + $this->addSql('ALTER TABLE chill_event_role ' + . 'ADD CONSTRAINT FK_AA714E54C54C8C93 FOREIGN KEY (type_id) ' + . 'REFERENCES chill_event_event_type (id) ' + . 'NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_event_status ' + . 'ADD CONSTRAINT FK_A6CC85D0C54C8C93 ' + . 'FOREIGN KEY (type_id) ' + . 'REFERENCES chill_event_event_type (id) ' + . 'NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_event_participation ' + . 'ADD CONSTRAINT FK_4E7768AC71F7E88B ' + . 'FOREIGN KEY (event_id) ' + . 'REFERENCES chill_event_event (id) ' + . 'NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_event_participation ' + . 'ADD CONSTRAINT FK_4E7768AC217BBB47 ' + . 'FOREIGN KEY (person_id) ' + . 'REFERENCES Person (id) ' + . 'NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_event_participation ' + . 'ADD CONSTRAINT FK_4E7768ACD60322AC ' + . 'FOREIGN KEY (role_id) ' + . 'REFERENCES chill_event_role (id) ' + . 'NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_event_participation ' + . 'ADD CONSTRAINT FK_4E7768AC6BF700BD ' + . 'FOREIGN KEY (status_id) ' + . 'REFERENCES chill_event_status (id) ' + . 'NOT DEFERRABLE INITIALLY IMMEDIATE'); + + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_event_role DROP CONSTRAINT FK_AA714E54C54C8C93'); + $this->addSql('ALTER TABLE chill_event_status DROP CONSTRAINT FK_A6CC85D0C54C8C93'); + $this->addSql('ALTER TABLE chill_event_participation DROP CONSTRAINT FK_4E7768ACD60322AC'); + $this->addSql('ALTER TABLE chill_event_participation DROP CONSTRAINT FK_4E7768AC6BF700BD'); + $this->addSql('ALTER TABLE chill_event_participation DROP CONSTRAINT FK_4E7768AC71F7E88B'); + $this->addSql('DROP SEQUENCE chill_event_event_type_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_event_role_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_event_status_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_event_event_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_event_participation_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_event_event_type'); + $this->addSql('DROP TABLE chill_event_role'); + $this->addSql('DROP TABLE chill_event_status'); + $this->addSql('DROP TABLE chill_event_event'); + $this->addSql('DROP TABLE chill_event_participation'); + + } +} From 9512528018a2e81859c4e7f2be965684fa9f78ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 18 Mar 2016 11:34:25 +0100 Subject: [PATCH 005/179] add basic crud for admin --- .gitignore | 21 ++ Controller/EventTypeController.php | 224 +++++++++++++++++++ Controller/RoleController.php | 224 +++++++++++++++++++ Controller/StatusController.php | 224 +++++++++++++++++++ DependencyInjection/ChillEventExtension.php | 2 +- Form/EventTypeType.php | 40 ++++ Form/RoleType.php | 41 ++++ Form/StatusType.php | 41 ++++ Resources/config/routing.yml | 15 +- Resources/config/routing/eventtype.yml | 30 +++ Resources/config/routing/role.yml | 30 +++ Resources/config/routing/status.yml | 30 +++ Resources/views/EventType/edit.html.twig | 16 ++ Resources/views/EventType/index.html.twig | 43 ++++ Resources/views/EventType/new.html.twig | 15 ++ Resources/views/EventType/show.html.twig | 36 +++ Resources/views/Role/edit.html.twig | 16 ++ Resources/views/Role/index.html.twig | 43 ++++ Resources/views/Role/new.html.twig | 15 ++ Resources/views/Role/show.html.twig | 36 +++ Resources/views/Status/edit.html.twig | 16 ++ Resources/views/Status/index.html.twig | 43 ++++ Resources/views/Status/new.html.twig | 15 ++ Resources/views/Status/show.html.twig | 36 +++ Tests/Controller/EventTypeControllerTest.php | 55 +++++ Tests/Controller/RoleControllerTest.php | 55 +++++ Tests/Controller/StatusControllerTest.php | 55 +++++ 27 files changed, 1413 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 Controller/EventTypeController.php create mode 100644 Controller/RoleController.php create mode 100644 Controller/StatusController.php create mode 100644 Form/EventTypeType.php create mode 100644 Form/RoleType.php create mode 100644 Form/StatusType.php create mode 100644 Resources/config/routing/eventtype.yml create mode 100644 Resources/config/routing/role.yml create mode 100644 Resources/config/routing/status.yml create mode 100644 Resources/views/EventType/edit.html.twig create mode 100644 Resources/views/EventType/index.html.twig create mode 100644 Resources/views/EventType/new.html.twig create mode 100644 Resources/views/EventType/show.html.twig create mode 100644 Resources/views/Role/edit.html.twig create mode 100644 Resources/views/Role/index.html.twig create mode 100644 Resources/views/Role/new.html.twig create mode 100644 Resources/views/Role/show.html.twig create mode 100644 Resources/views/Status/edit.html.twig create mode 100644 Resources/views/Status/index.html.twig create mode 100644 Resources/views/Status/new.html.twig create mode 100644 Resources/views/Status/show.html.twig create mode 100644 Tests/Controller/EventTypeControllerTest.php create mode 100644 Tests/Controller/RoleControllerTest.php create mode 100644 Tests/Controller/StatusControllerTest.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..9f103fd7c --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +*~ +# MacOS +.DS_Store + +# Bootstrap +app/bootstrap* + +# Symfony directories +vendor/* +*/logs/* +*/cache/* +web/uploads/* +web/bundles/* + +# Configuration files +app/config/parameters.ini +app/config/parameters.yml +Tests/Fixtures/App/config/parameters.yml + +#composer +composer.lock diff --git a/Controller/EventTypeController.php b/Controller/EventTypeController.php new file mode 100644 index 000000000..cbe28999b --- /dev/null +++ b/Controller/EventTypeController.php @@ -0,0 +1,224 @@ +getDoctrine()->getManager(); + + $entities = $em->getRepository('ChillEventBundle:EventType')->findAll(); + + return $this->render('ChillEventBundle:EventType:index.html.twig', array( + 'entities' => $entities, + )); + } + /** + * Creates a new EventType entity. + * + */ + public function createAction(Request $request) + { + $entity = new EventType(); + $form = $this->createCreateForm($entity); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($entity); + $em->flush(); + + return $this->redirect($this->generateUrl('{_locale}_admin_show', array('id' => $entity->getId()))); + } + + return $this->render('ChillEventBundle:EventType:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Creates a form to create a EventType entity. + * + * @param EventType $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createCreateForm(EventType $entity) + { + $form = $this->createForm(new EventTypeType(), $entity, array( + 'action' => $this->generateUrl('{_locale}_admin_create'), + 'method' => 'POST', + )); + + $form->add('submit', 'submit', array('label' => 'Create')); + + return $form; + } + + /** + * Displays a form to create a new EventType entity. + * + */ + public function newAction() + { + $entity = new EventType(); + $form = $this->createCreateForm($entity); + + return $this->render('ChillEventBundle:EventType:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Finds and displays a EventType entity. + * + */ + public function showAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:EventType')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find EventType entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:EventType:show.html.twig', array( + 'entity' => $entity, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing EventType entity. + * + */ + public function editAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:EventType')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find EventType entity.'); + } + + $editForm = $this->createEditForm($entity); + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:EventType:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Creates a form to edit a EventType entity. + * + * @param EventType $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createEditForm(EventType $entity) + { + $form = $this->createForm(new EventTypeType(), $entity, array( + 'action' => $this->generateUrl('{_locale}_admin_update', array('id' => $entity->getId())), + 'method' => 'PUT', + )); + + $form->add('submit', 'submit', array('label' => 'Update')); + + return $form; + } + /** + * Edits an existing EventType entity. + * + */ + public function updateAction(Request $request, $id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:EventType')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find EventType entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + $editForm = $this->createEditForm($entity); + $editForm->handleRequest($request); + + if ($editForm->isValid()) { + $em->flush(); + + return $this->redirect($this->generateUrl('{_locale}_admin_edit', array('id' => $id))); + } + + return $this->render('ChillEventBundle:EventType:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + /** + * Deletes a EventType entity. + * + */ + public function deleteAction(Request $request, $id) + { + $form = $this->createDeleteForm($id); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $entity = $em->getRepository('ChillEventBundle:EventType')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find EventType entity.'); + } + + $em->remove($entity); + $em->flush(); + } + + return $this->redirect($this->generateUrl('{_locale}_admin')); + } + + /** + * Creates a form to delete a EventType entity by id. + * + * @param mixed $id The entity id + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm($id) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('{_locale}_admin_delete', array('id' => $id))) + ->setMethod('DELETE') + ->add('submit', 'submit', array('label' => 'Delete')) + ->getForm() + ; + } +} diff --git a/Controller/RoleController.php b/Controller/RoleController.php new file mode 100644 index 000000000..3834e89a9 --- /dev/null +++ b/Controller/RoleController.php @@ -0,0 +1,224 @@ +getDoctrine()->getManager(); + + $entities = $em->getRepository('ChillEventBundle:Role')->findAll(); + + return $this->render('ChillEventBundle:Role:index.html.twig', array( + 'entities' => $entities, + )); + } + /** + * Creates a new Role entity. + * + */ + public function createAction(Request $request) + { + $entity = new Role(); + $form = $this->createCreateForm($entity); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($entity); + $em->flush(); + + return $this->redirect($this->generateUrl('{_locale}_admin_role_show', array('id' => $entity->getId()))); + } + + return $this->render('ChillEventBundle:Role:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Creates a form to create a Role entity. + * + * @param Role $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createCreateForm(Role $entity) + { + $form = $this->createForm(new RoleType(), $entity, array( + 'action' => $this->generateUrl('{_locale}_admin_role_create'), + 'method' => 'POST', + )); + + $form->add('submit', 'submit', array('label' => 'Create')); + + return $form; + } + + /** + * Displays a form to create a new Role entity. + * + */ + public function newAction() + { + $entity = new Role(); + $form = $this->createCreateForm($entity); + + return $this->render('ChillEventBundle:Role:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Finds and displays a Role entity. + * + */ + public function showAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Role')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Role entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:Role:show.html.twig', array( + 'entity' => $entity, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing Role entity. + * + */ + public function editAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Role')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Role entity.'); + } + + $editForm = $this->createEditForm($entity); + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:Role:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Creates a form to edit a Role entity. + * + * @param Role $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createEditForm(Role $entity) + { + $form = $this->createForm(new RoleType(), $entity, array( + 'action' => $this->generateUrl('{_locale}_admin_role_update', array('id' => $entity->getId())), + 'method' => 'PUT', + )); + + $form->add('submit', 'submit', array('label' => 'Update')); + + return $form; + } + /** + * Edits an existing Role entity. + * + */ + public function updateAction(Request $request, $id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Role')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Role entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + $editForm = $this->createEditForm($entity); + $editForm->handleRequest($request); + + if ($editForm->isValid()) { + $em->flush(); + + return $this->redirect($this->generateUrl('{_locale}_admin_role_edit', array('id' => $id))); + } + + return $this->render('ChillEventBundle:Role:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + /** + * Deletes a Role entity. + * + */ + public function deleteAction(Request $request, $id) + { + $form = $this->createDeleteForm($id); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $entity = $em->getRepository('ChillEventBundle:Role')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Role entity.'); + } + + $em->remove($entity); + $em->flush(); + } + + return $this->redirect($this->generateUrl('{_locale}_admin_role')); + } + + /** + * Creates a form to delete a Role entity by id. + * + * @param mixed $id The entity id + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm($id) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('{_locale}_admin_role_delete', array('id' => $id))) + ->setMethod('DELETE') + ->add('submit', 'submit', array('label' => 'Delete')) + ->getForm() + ; + } +} diff --git a/Controller/StatusController.php b/Controller/StatusController.php new file mode 100644 index 000000000..e0a57ba51 --- /dev/null +++ b/Controller/StatusController.php @@ -0,0 +1,224 @@ +getDoctrine()->getManager(); + + $entities = $em->getRepository('ChillEventBundle:Status')->findAll(); + + return $this->render('ChillEventBundle:Status:index.html.twig', array( + 'entities' => $entities, + )); + } + /** + * Creates a new Status entity. + * + */ + public function createAction(Request $request) + { + $entity = new Status(); + $form = $this->createCreateForm($entity); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($entity); + $em->flush(); + + return $this->redirect($this->generateUrl('fr_admin_event_status_show', array('id' => $entity->getId()))); + } + + return $this->render('ChillEventBundle:Status:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Creates a form to create a Status entity. + * + * @param Status $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createCreateForm(Status $entity) + { + $form = $this->createForm(new StatusType(), $entity, array( + 'action' => $this->generateUrl('fr_admin_event_status_create'), + 'method' => 'POST', + )); + + $form->add('submit', 'submit', array('label' => 'Create')); + + return $form; + } + + /** + * Displays a form to create a new Status entity. + * + */ + public function newAction() + { + $entity = new Status(); + $form = $this->createCreateForm($entity); + + return $this->render('ChillEventBundle:Status:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Finds and displays a Status entity. + * + */ + public function showAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Status')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Status entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:Status:show.html.twig', array( + 'entity' => $entity, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing Status entity. + * + */ + public function editAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Status')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Status entity.'); + } + + $editForm = $this->createEditForm($entity); + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:Status:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Creates a form to edit a Status entity. + * + * @param Status $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createEditForm(Status $entity) + { + $form = $this->createForm(new StatusType(), $entity, array( + 'action' => $this->generateUrl('fr_admin_event_status_update', array('id' => $entity->getId())), + 'method' => 'PUT', + )); + + $form->add('submit', 'submit', array('label' => 'Update')); + + return $form; + } + /** + * Edits an existing Status entity. + * + */ + public function updateAction(Request $request, $id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Status')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Status entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + $editForm = $this->createEditForm($entity); + $editForm->handleRequest($request); + + if ($editForm->isValid()) { + $em->flush(); + + return $this->redirect($this->generateUrl('fr_admin_event_status_edit', array('id' => $id))); + } + + return $this->render('ChillEventBundle:Status:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + /** + * Deletes a Status entity. + * + */ + public function deleteAction(Request $request, $id) + { + $form = $this->createDeleteForm($id); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $entity = $em->getRepository('ChillEventBundle:Status')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Status entity.'); + } + + $em->remove($entity); + $em->flush(); + } + + return $this->redirect($this->generateUrl('fr_admin_event_status')); + } + + /** + * Creates a form to delete a Status entity by id. + * + * @param mixed $id The entity id + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm($id) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('fr_admin_event_status_delete', array('id' => $id))) + ->setMethod('DELETE') + ->add('submit', 'submit', array('label' => 'Delete')) + ->getForm() + ; + } +} diff --git a/DependencyInjection/ChillEventExtension.php b/DependencyInjection/ChillEventExtension.php index 89eb98c57..1035659fd 100644 --- a/DependencyInjection/ChillEventExtension.php +++ b/DependencyInjection/ChillEventExtension.php @@ -13,7 +13,7 @@ use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; * * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} */ -class ChillEventExtension extends Extension +class ChillEventExtension extends Extension implements PrependExtensionInterface { /** * {@inheritdoc} diff --git a/Form/EventTypeType.php b/Form/EventTypeType.php new file mode 100644 index 000000000..02ec828e8 --- /dev/null +++ b/Form/EventTypeType.php @@ -0,0 +1,40 @@ +add('label') + ->add('active') + ; + } + + /** + * @param OptionsResolverInterface $resolver + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'Chill\EventBundle\Entity\EventType' + )); + } + + /** + * @return string + */ + public function getName() + { + return 'chill_eventbundle_eventtype'; + } +} diff --git a/Form/RoleType.php b/Form/RoleType.php new file mode 100644 index 000000000..293aec1d1 --- /dev/null +++ b/Form/RoleType.php @@ -0,0 +1,41 @@ +add('label') + ->add('active') + ->add('type') + ; + } + + /** + * @param OptionsResolverInterface $resolver + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'Chill\EventBundle\Entity\Role' + )); + } + + /** + * @return string + */ + public function getName() + { + return 'chill_eventbundle_role'; + } +} diff --git a/Form/StatusType.php b/Form/StatusType.php new file mode 100644 index 000000000..24bdcd604 --- /dev/null +++ b/Form/StatusType.php @@ -0,0 +1,41 @@ +add('label') + ->add('active') + ->add('type') + ; + } + + /** + * @param OptionsResolverInterface $resolver + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'Chill\EventBundle\Entity\Status' + )); + } + + /** + * @return string + */ + public function getName() + { + return 'chill_eventbundle_status'; + } +} diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 712a131e6..f6262b049 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,3 +1,12 @@ -chill_event_homepage: - path: /hello/{name} - defaults: { _controller: ChillEventBundle:Default:index } +chill_event_fr_admin_event_status: + resource: "@ChillEventBundle/Resources/config/routing/status.yml" + prefix: /{_locale}/admin/event/status + +chill_event_admin_role: + resource: "@ChillEventBundle/Resources/config/routing/role.yml" + prefix: /{_locale}/admin/event/role + +chill_event_admin_event_type: + resource: "@ChillEventBundle/Resources/config/routing/eventtype.yml" + prefix: /{_locale}/admin/event/event_type + diff --git a/Resources/config/routing/eventtype.yml b/Resources/config/routing/eventtype.yml new file mode 100644 index 000000000..cdf54fe85 --- /dev/null +++ b/Resources/config/routing/eventtype.yml @@ -0,0 +1,30 @@ +chill_event_admin: + path: / + defaults: { _controller: "ChillEventBundle:EventType:index" } + +chill_event_admin_show: + path: /{id}/show + defaults: { _controller: "ChillEventBundle:EventType:show" } + +chill_event_admin_new: + path: /new + defaults: { _controller: "ChillEventBundle:EventType:new" } + +chill_event_admin_create: + path: /create + defaults: { _controller: "ChillEventBundle:EventType:create" } + methods: POST + +chill_event_admin_edit: + path: /{id}/edit + defaults: { _controller: "ChillEventBundle:EventType:edit" } + +chill_event_admin_update: + path: /{id}/update + defaults: { _controller: "ChillEventBundle:EventType:update" } + methods: [POST, PUT] + +chill_event_admin_delete: + path: /{id}/delete + defaults: { _controller: "ChillEventBundle:EventType:delete" } + methods: [POST, DELETE] diff --git a/Resources/config/routing/role.yml b/Resources/config/routing/role.yml new file mode 100644 index 000000000..bfc51216d --- /dev/null +++ b/Resources/config/routing/role.yml @@ -0,0 +1,30 @@ +chill_event_admin_role: + path: / + defaults: { _controller: "ChillEventBundle:Role:index" } + +chill_event_admin_role_show: + path: /{id}/show + defaults: { _controller: "ChillEventBundle:Role:show" } + +chill_event_admin_role_new: + path: /new + defaults: { _controller: "ChillEventBundle:Role:new" } + +chill_event_admin_role_create: + path: /create + defaults: { _controller: "ChillEventBundle:Role:create" } + methods: POST + +chill_event_admin_role_edit: + path: /{id}/edit + defaults: { _controller: "ChillEventBundle:Role:edit" } + +chill_event_admin_role_update: + path: /{id}/update + defaults: { _controller: "ChillEventBundle:Role:update" } + methods: [POST, PUT] + +chill_event_admin_role_delete: + path: /{id}/delete + defaults: { _controller: "ChillEventBundle:Role:delete" } + methods: [POST, DELETE] diff --git a/Resources/config/routing/status.yml b/Resources/config/routing/status.yml new file mode 100644 index 000000000..396f72c39 --- /dev/null +++ b/Resources/config/routing/status.yml @@ -0,0 +1,30 @@ +fr_admin_event_status: + path: / + defaults: { _controller: "ChillEventBundle:Status:index" } + +fr_admin_event_status_show: + path: /{id}/show + defaults: { _controller: "ChillEventBundle:Status:show" } + +fr_admin_event_status_new: + path: /new + defaults: { _controller: "ChillEventBundle:Status:new" } + +fr_admin_event_status_create: + path: /create + defaults: { _controller: "ChillEventBundle:Status:create" } + methods: POST + +fr_admin_event_status_edit: + path: /{id}/edit + defaults: { _controller: "ChillEventBundle:Status:edit" } + +fr_admin_event_status_update: + path: /{id}/update + defaults: { _controller: "ChillEventBundle:Status:update" } + methods: [POST, PUT] + +fr_admin_event_status_delete: + path: /{id}/delete + defaults: { _controller: "ChillEventBundle:Status:delete" } + methods: [POST, DELETE] diff --git a/Resources/views/EventType/edit.html.twig b/Resources/views/EventType/edit.html.twig new file mode 100644 index 000000000..5849fa686 --- /dev/null +++ b/Resources/views/EventType/edit.html.twig @@ -0,0 +1,16 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

EventType edit

+ + {{ form(edit_form) }} + + +{% endblock %} diff --git a/Resources/views/EventType/index.html.twig b/Resources/views/EventType/index.html.twig new file mode 100644 index 000000000..72c47e279 --- /dev/null +++ b/Resources/views/EventType/index.html.twig @@ -0,0 +1,43 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

EventType list

+ + + + + + + + + + + + {% for entity in entities %} + + + + + + + {% endfor %} + +
IdLabelActiveActions
{{ entity.id }}{{ entity.label }}{{ entity.active }} + +
+ + + {% endblock %} diff --git a/Resources/views/EventType/new.html.twig b/Resources/views/EventType/new.html.twig new file mode 100644 index 000000000..4e097dd92 --- /dev/null +++ b/Resources/views/EventType/new.html.twig @@ -0,0 +1,15 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

EventType creation

+ + {{ form(form) }} + + +{% endblock %} diff --git a/Resources/views/EventType/show.html.twig b/Resources/views/EventType/show.html.twig new file mode 100644 index 000000000..818e30fa9 --- /dev/null +++ b/Resources/views/EventType/show.html.twig @@ -0,0 +1,36 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

EventType

+ + + + + + + + + + + + + + + + +
Id{{ entity.id }}
Label{{ entity.label }}
Active{{ entity.active }}
+ + +{% endblock %} diff --git a/Resources/views/Role/edit.html.twig b/Resources/views/Role/edit.html.twig new file mode 100644 index 000000000..1bf9dc66d --- /dev/null +++ b/Resources/views/Role/edit.html.twig @@ -0,0 +1,16 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Role edit

+ + {{ form(edit_form) }} + + +{% endblock %} diff --git a/Resources/views/Role/index.html.twig b/Resources/views/Role/index.html.twig new file mode 100644 index 000000000..dcfda2a25 --- /dev/null +++ b/Resources/views/Role/index.html.twig @@ -0,0 +1,43 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Role list

+ + + + + + + + + + + + {% for entity in entities %} + + + + + + + {% endfor %} + +
IdLabelActiveActions
{{ entity.id }}{{ entity.label }}{{ entity.active }} + +
+ + + {% endblock %} diff --git a/Resources/views/Role/new.html.twig b/Resources/views/Role/new.html.twig new file mode 100644 index 000000000..a9ea41a1b --- /dev/null +++ b/Resources/views/Role/new.html.twig @@ -0,0 +1,15 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Role creation

+ + {{ form(form) }} + + +{% endblock %} diff --git a/Resources/views/Role/show.html.twig b/Resources/views/Role/show.html.twig new file mode 100644 index 000000000..a212c2f6d --- /dev/null +++ b/Resources/views/Role/show.html.twig @@ -0,0 +1,36 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Role

+ + + + + + + + + + + + + + + + +
Id{{ entity.id }}
Label{{ entity.label }}
Active{{ entity.active }}
+ + +{% endblock %} diff --git a/Resources/views/Status/edit.html.twig b/Resources/views/Status/edit.html.twig new file mode 100644 index 000000000..f9c2f7bda --- /dev/null +++ b/Resources/views/Status/edit.html.twig @@ -0,0 +1,16 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Status edit

+ + {{ form(edit_form) }} + + +{% endblock %} diff --git a/Resources/views/Status/index.html.twig b/Resources/views/Status/index.html.twig new file mode 100644 index 000000000..e5ec9e480 --- /dev/null +++ b/Resources/views/Status/index.html.twig @@ -0,0 +1,43 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Status list

+ + + + + + + + + + + + {% for entity in entities %} + + + + + + + {% endfor %} + +
IdLabelActiveActions
{{ entity.id }}{{ entity.label }}{{ entity.active }} + +
+ + + {% endblock %} diff --git a/Resources/views/Status/new.html.twig b/Resources/views/Status/new.html.twig new file mode 100644 index 000000000..7cd7093b1 --- /dev/null +++ b/Resources/views/Status/new.html.twig @@ -0,0 +1,15 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Status creation

+ + {{ form(form) }} + + +{% endblock %} diff --git a/Resources/views/Status/show.html.twig b/Resources/views/Status/show.html.twig new file mode 100644 index 000000000..7b0dd4049 --- /dev/null +++ b/Resources/views/Status/show.html.twig @@ -0,0 +1,36 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Status

+ + + + + + + + + + + + + + + + +
Id{{ entity.id }}
Label{{ entity.label }}
Active{{ entity.active }}
+ + +{% endblock %} diff --git a/Tests/Controller/EventTypeControllerTest.php b/Tests/Controller/EventTypeControllerTest.php new file mode 100644 index 000000000..2075dfdbe --- /dev/null +++ b/Tests/Controller/EventTypeControllerTest.php @@ -0,0 +1,55 @@ +request('GET', '/{_locale}/admin/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /{_locale}/admin/"); + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Create')->form(array( + 'chill_eventbundle_eventtype[field_name]' => 'Test', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check data in the show view + $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")'); + + // Edit the entity + $crawler = $client->click($crawler->selectLink('Edit')->link()); + + $form = $crawler->selectButton('Update')->form(array( + 'chill_eventbundle_eventtype[field_name]' => 'Foo', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check the element contains an attribute with value equals "Foo" + $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]'); + + // Delete the entity + $client->submit($crawler->selectButton('Delete')->form()); + $crawler = $client->followRedirect(); + + // Check the entity has been delete on the list + $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent()); + } + + */ +} diff --git a/Tests/Controller/RoleControllerTest.php b/Tests/Controller/RoleControllerTest.php new file mode 100644 index 000000000..39d21ff7b --- /dev/null +++ b/Tests/Controller/RoleControllerTest.php @@ -0,0 +1,55 @@ +request('GET', '/{_locale}/admin/role/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /{_locale}/admin/role/"); + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Create')->form(array( + 'chill_eventbundle_role[field_name]' => 'Test', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check data in the show view + $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")'); + + // Edit the entity + $crawler = $client->click($crawler->selectLink('Edit')->link()); + + $form = $crawler->selectButton('Update')->form(array( + 'chill_eventbundle_role[field_name]' => 'Foo', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check the element contains an attribute with value equals "Foo" + $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]'); + + // Delete the entity + $client->submit($crawler->selectButton('Delete')->form()); + $crawler = $client->followRedirect(); + + // Check the entity has been delete on the list + $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent()); + } + + */ +} diff --git a/Tests/Controller/StatusControllerTest.php b/Tests/Controller/StatusControllerTest.php new file mode 100644 index 000000000..fc2c94259 --- /dev/null +++ b/Tests/Controller/StatusControllerTest.php @@ -0,0 +1,55 @@ +request('GET', '/fr/admin/event/status/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /fr/admin/event/status/"); + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Create')->form(array( + 'chill_eventbundle_status[field_name]' => 'Test', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check data in the show view + $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")'); + + // Edit the entity + $crawler = $client->click($crawler->selectLink('Edit')->link()); + + $form = $crawler->selectButton('Update')->form(array( + 'chill_eventbundle_status[field_name]' => 'Foo', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check the element contains an attribute with value equals "Foo" + $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]'); + + // Delete the entity + $client->submit($crawler->selectButton('Delete')->form()); + $crawler = $client->followRedirect(); + + // Check the entity has been delete on the list + $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent()); + } + + */ +} From d7fc04cdaa478b48c41d072157ab38b202c167e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 22 Mar 2016 09:59:00 +0100 Subject: [PATCH 006/179] add fixtures for events fix #17 --- DataFixtures/ORM/LoadEventTypes.php | 97 +++++++++++++++++++++++++ DataFixtures/ORM/LoadParticipation.php | 92 +++++++++++++++++++++++ Entity/Event.php | 50 ++++++++++++- Entity/EventType.php | 36 ++++----- Entity/Participation.php | 19 ++++- Resources/config/doctrine/Event.orm.yml | 5 ++ 6 files changed, 278 insertions(+), 21 deletions(-) create mode 100644 DataFixtures/ORM/LoadEventTypes.php create mode 100644 DataFixtures/ORM/LoadParticipation.php diff --git a/DataFixtures/ORM/LoadEventTypes.php b/DataFixtures/ORM/LoadEventTypes.php new file mode 100644 index 000000000..38e171d97 --- /dev/null +++ b/DataFixtures/ORM/LoadEventTypes.php @@ -0,0 +1,97 @@ + + * @author Champs Libres + */ +class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface +{ + public static $refs = array(); + + public function getOrder() + { + return 30000; + } + + public function load(ObjectManager $manager) + { + $type = (new EventType()) + ->setActive(true) + ->setLabel(array('fr' => 'Échange de savoirs', 'en' => 'Exchange of knowledge')) + ; + $manager->persist($type); + $this->addReference('event_type_knowledge', $type); + self::$refs[] = 'event_type_knowledge'; + + $role = (new Role()) + ->setActive(true) + ->setLabel(array('fr' => 'Participant', 'nl' => 'Deelneemer', 'en' => 'Participant')) + ->setType($type) + ; + $manager->persist($role); + + $role = (new Role()) + ->setActive(true) + ->setLabel(array('fr' => 'Animateur')) + ->setType($type); + $manager->persist($role); + + $status = (new Status()) + ->setActive(true) + ->setLabel(array('fr' => 'Inscrit')) + ->setType($type); + $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setLabel(array('fr' => 'Présent')) + ->setType($type) + ; + $manager->persist($status); + + + $type = (new EventType()) + ->setActive(true) + ->setLabel(array('fr' => 'Formation', 'en' => 'Course', 'nl' => 'Opleiding')) + ; + $manager->persist($type); + $this->addReference('event_type_course', $type); + self::$refs[] = 'event_type_course'; + + $role = (new Role()) + ->setActive(true) + ->setLabel(array('fr' => 'Participant', 'nl' => 'Deelneemer', 'en' => 'Participant')) + ->setType($type) + ; + $manager->persist($role); + + $status = (new Status()) + ->setActive(true) + ->setLabel(array('fr' => 'Inscrit')) + ->setType($type) + ; + $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setLabel(array('fr' => 'En liste d\'attente')) + ->setType($type) + ; + $manager->persist($status); + + $manager->flush(); + } + +} diff --git a/DataFixtures/ORM/LoadParticipation.php b/DataFixtures/ORM/LoadParticipation.php new file mode 100644 index 000000000..618b44d7c --- /dev/null +++ b/DataFixtures/ORM/LoadParticipation.php @@ -0,0 +1,92 @@ + + * @author Champs Libres + */ +class LoadParticipation extends AbstractFixture implements OrderedFixtureInterface +{ + /** + * + * @var \Faker\Generator + */ + protected $faker; + + public function __construct() + { + $this->faker = \Faker\Factory::create('fr_FR'); + } + + public function getOrder() + { + return 30010; + } + + public function load(ObjectManager $manager) + { + $centers = $manager->getRepository('ChillMainBundle:Center') + ->findAll(); + + foreach($centers as $center) { + + $people = $manager->getRepository('ChillPersonBundle:Person') + ->findBy(array('center' => $center)); + $events = $this->createEvents($center, $manager); + + /* @var $person \Chill\PersonBundle\Entity\Person */ + foreach ($people as $person) { + $nb = rand(0,3); + + for ($i=0; $i<$nb; $i++) { + $event = $events[array_rand($events)]; + $role = $event->getType()->getRoles()->get( + array_rand($event->getType()->getRoles()->toArray())); + $status = $event->getType()->getStatuses()->get( + array_rand($event->getType()->getStatuses()->toArray())); + + $participation = (new Participation()) + ->setPerson($person) + ->setRole($role) + ->setStatus($status) + ->setEvent($event) + ; + $manager->persist($participation); + } + } + } + + $manager->flush(); + + + } + + public function createEvents(Center $center, ObjectManager $manager) + { + $expectedNumber = 20; + $events = array(); + + for($i=0; $i<$expectedNumber; $i++) { + $event = (new Event()) + ->setDate($this->faker->dateTimeBetween('-2 years', '+6 months')) + ->setLabel($this->faker->words(rand(2,4), true)) + ->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)])) + ->setCenter($center) + ; + $manager->persist($event); + $events[] = $event; + } + + return $events; + } +} diff --git a/Entity/Event.php b/Entity/Event.php index d3e6a8881..ec8c16f43 100644 --- a/Entity/Event.php +++ b/Entity/Event.php @@ -22,6 +22,18 @@ class Event */ private $date; + /** + * + * @var \Chill\MainBundle\Entity\Center + */ + private $center; + + /** + * + * @var EventType + */ + private $type; + /** * @var \Doctrine\Common\Collections\Collection */ @@ -77,7 +89,7 @@ class Event * * @return Event */ - public function setDate($date) + public function setDate(\DateTime $date) { $this->date = $date; @@ -93,6 +105,42 @@ class Event { return $this->date; } + + public function setCenter(\Chill\MainBundle\Entity\Center $center) + { + $this->center = $center; + + return $this; + } + + /** + * + * @return EventType + */ + public function getType() + { + return $this->type; + } + + /** + * + * @param \Chill\EventBundle\Entity\EventType $type + * @return \Chill\EventBundle\Entity\Event + */ + public function setType(EventType $type) + { + $this->type = $type; + return $this; + } + + /** + * + * @return \Chill\MainBundle\Entity\Center + */ + public function getCenter() + { + return $this->center; + } /** * Add participation diff --git a/Entity/EventType.php b/Entity/EventType.php index 64c240b53..e7646c03a 100644 --- a/Entity/EventType.php +++ b/Entity/EventType.php @@ -21,7 +21,25 @@ class EventType * @var boolean */ private $active; + + /** + * @var \Doctrine\Common\Collections\Collection + */ + private $roles; + /** + * @var \Doctrine\Common\Collections\Collection + */ + private $statuses; + + /** + * Constructor + */ + public function __construct() + { + $this->roles = new \Doctrine\Common\Collections\ArrayCollection(); + $this->statuses = new \Doctrine\Common\Collections\ArrayCollection(); + } /** * Get id @@ -80,24 +98,6 @@ class EventType { return $this->active; } - /** - * @var \Doctrine\Common\Collections\Collection - */ - private $roles; - - /** - * @var \Doctrine\Common\Collections\Collection - */ - private $statuses; - - /** - * Constructor - */ - public function __construct() - { - $this->roles = new \Doctrine\Common\Collections\ArrayCollection(); - $this->statuses = new \Doctrine\Common\Collections\ArrayCollection(); - } /** * Add role diff --git a/Entity/Participation.php b/Entity/Participation.php index 2c6fdb2f5..cc8b8544e 100644 --- a/Entity/Participation.php +++ b/Entity/Participation.php @@ -55,9 +55,9 @@ class Participation * * @return Participation */ - public function setLastUpdate($lastUpdate) + protected function update() { - $this->lastUpdate = $lastUpdate; + $this->lastUpdate = new \DateTime('now'); return $this; } @@ -82,6 +82,10 @@ class Participation */ public function setEvent(\Chill\EventBundle\Entity\Event $event = null) { + if ($this->event !== $event) { + $this->update(); + } + $this->event = $event; return $this; @@ -106,6 +110,10 @@ class Participation */ public function setPerson(\Chill\PersonBundle\Entity\Person $person = null) { + if ($person !== $this->person) { + $this->update(); + } + $this->person = $person; return $this; @@ -130,6 +138,9 @@ class Participation */ public function setRole(\Chill\EventBundle\Entity\Role $role = null) { + if ($role !== $this->role) { + $this->update(); + } $this->role = $role; return $this; @@ -154,6 +165,10 @@ class Participation */ public function setStatus(\Chill\EventBundle\Entity\Status $status = null) { + if ($this->status !== $status) { + $this->update(); + } + $this->status = $status; return $this; diff --git a/Resources/config/doctrine/Event.orm.yml b/Resources/config/doctrine/Event.orm.yml index 3bc880597..b4325981c 100644 --- a/Resources/config/doctrine/Event.orm.yml +++ b/Resources/config/doctrine/Event.orm.yml @@ -17,4 +17,9 @@ Chill\EventBundle\Entity\Event: participations: targetEntity: Chill\EventBundle\Entity\Participation mappedBy: event + manyToOne: + center: + targetEntity: Chill\MainBundle\Entity\Center + type: + targetEntity: Chill\EventBundle\Entity\EventType lifecycleCallbacks: { } From e66a855c0a4b37b0a789c97736ad0e7a7ed15684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 22 Mar 2016 12:36:11 +0100 Subject: [PATCH 007/179] adding a scope/circle to events ref #1 --- DataFixtures/ORM/LoadParticipation.php | 6 ++++ Entity/Event.php | 37 +++++++++++++++++++++++++ Resources/config/doctrine/Event.orm.yml | 2 ++ 3 files changed, 45 insertions(+) diff --git a/DataFixtures/ORM/LoadParticipation.php b/DataFixtures/ORM/LoadParticipation.php index 618b44d7c..98f19a82e 100644 --- a/DataFixtures/ORM/LoadParticipation.php +++ b/DataFixtures/ORM/LoadParticipation.php @@ -8,6 +8,7 @@ use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Chill\EventBundle\Entity\Participation; use Chill\MainBundle\Entity\Center; use Chill\EventBundle\Entity\Event; +use Chill\MainBundle\DataFixtures\ORM\LoadScopes; /** * Load Events and Participation @@ -82,6 +83,11 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa ->setLabel($this->faker->words(rand(2,4), true)) ->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)])) ->setCenter($center) + ->setCircle( + $this->getReference( + LoadScopes::$references[array_rand(LoadScopes::$references)] + ) + ) ; $manager->persist($event); $events[] = $event; diff --git a/Entity/Event.php b/Entity/Event.php index ec8c16f43..763f27f56 100644 --- a/Entity/Event.php +++ b/Entity/Event.php @@ -34,6 +34,12 @@ class Event */ private $type; + /** + * + * @var \Chill\MainBundle\Entity\Scope + */ + private $circle; + /** * @var \Doctrine\Common\Collections\Collection */ @@ -141,7 +147,38 @@ class Event { return $this->center; } + + /** + * + * @return \Chill\MainBundle\Entity\Scope + */ + public function getCircle() + { + return $this->circle; + } + /** + * + * @param \Chill\MainBundle\Entity\Scope $circle + * @return \Chill\EventBundle\Entity\Event + */ + public function setCircle(\Chill\MainBundle\Entity\Scope $circle) + { + $this->circle = $circle; + return $this; + } + + /** + * + * @deprecated + * @return \Chill\MainBundle\Entity\Scope + */ + public function getScope() + { + return $this->getCircle(); + } + + /** * Add participation * diff --git a/Resources/config/doctrine/Event.orm.yml b/Resources/config/doctrine/Event.orm.yml index b4325981c..ae69e2f06 100644 --- a/Resources/config/doctrine/Event.orm.yml +++ b/Resources/config/doctrine/Event.orm.yml @@ -22,4 +22,6 @@ Chill\EventBundle\Entity\Event: targetEntity: Chill\MainBundle\Entity\Center type: targetEntity: Chill\EventBundle\Entity\EventType + circle: + targetEntity: Chill\MainBundle\Entity\Scope lifecycleCallbacks: { } From b89ed5d534593458389c1022095bceee04376641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 22 Mar 2016 14:00:48 +0100 Subject: [PATCH 008/179] add link to scope, center, type on Event --- .../migrations/Version20160318111334.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Resources/migrations/Version20160318111334.php b/Resources/migrations/Version20160318111334.php index 6ab4d5004..fe23df743 100644 --- a/Resources/migrations/Version20160318111334.php +++ b/Resources/migrations/Version20160318111334.php @@ -43,6 +43,9 @@ class Version20160318111334 extends AbstractMigration . 'id INT NOT NULL, ' . 'label VARCHAR(150) NOT NULL, ' . 'date DATE NOT NULL, ' + . 'center_id INT DEFAULT NULL, ' + . 'type_id INT DEFAULT NULL, ' + . 'circle_id INT DEFAULT NULL, ' . 'PRIMARY KEY(id))'); $this->addSql('CREATE TABLE chill_event_participation (' . 'id INT NOT NULL, ' @@ -56,6 +59,21 @@ class Version20160318111334 extends AbstractMigration $this->addSql('CREATE INDEX IDX_4E7768AC217BBB47 ON chill_event_participation (person_id)'); $this->addSql('CREATE INDEX IDX_4E7768ACD60322AC ON chill_event_participation (role_id)'); $this->addSql('CREATE INDEX IDX_4E7768AC6BF700BD ON chill_event_participation (status_id)'); + $this->addSql('CREATE INDEX IDX_FA320FC85932F377 ON chill_event_event (center_id)'); + $this->addSql('CREATE INDEX IDX_FA320FC8C54C8C93 ON chill_event_event (type_id)'); + $this->addSql('CREATE INDEX IDX_FA320FC870EE2FF6 ON chill_event_event (circle_id)'); + + $this->addSql('ALTER TABLE chill_event_event ' + . 'ADD CONSTRAINT FK_FA320FC85932F377 FOREIGN KEY (center_id) ' + . 'REFERENCES centers (id) ' + . 'NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_event_event ' + . 'ADD CONSTRAINT FK_FA320FC870EE2FF6 FOREIGN KEY (circle_id) ' + . 'REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_event_event ' + . 'ADD CONSTRAINT FK_FA320FC8C54C8C93 FOREIGN KEY (type_id) ' + . 'REFERENCES chill_event_event_type (id) ' + . 'NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE chill_event_role ' . 'ADD CONSTRAINT FK_AA714E54C54C8C93 FOREIGN KEY (type_id) ' . 'REFERENCES chill_event_event_type (id) ' @@ -101,6 +119,13 @@ class Version20160318111334 extends AbstractMigration $this->addSql('ALTER TABLE chill_event_participation DROP CONSTRAINT FK_4E7768ACD60322AC'); $this->addSql('ALTER TABLE chill_event_participation DROP CONSTRAINT FK_4E7768AC6BF700BD'); $this->addSql('ALTER TABLE chill_event_participation DROP CONSTRAINT FK_4E7768AC71F7E88B'); + // drop center_id constraint + $this->addSql('ALTER TABLE chill_event_event DROP CONSTRAINT FK_FA320FC85932F377'); + // drop type_id constraint + $this->addSql('ALTER TABLE chill_event_event DROP CONSTRAINT FK_FA320FC8C54C8C93'); + // drop circle_id constraint + $this->addSql('ALTER TABLE chill_event_event DROP CONSTRAINT FK_FA320FC870EE2FF6'); + $this->addSql('DROP SEQUENCE chill_event_event_type_id_seq CASCADE'); $this->addSql('DROP SEQUENCE chill_event_role_id_seq CASCADE'); $this->addSql('DROP SEQUENCE chill_event_status_id_seq CASCADE'); From 1acf3a468565841c491058378e98dae1d547b228 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 22 Mar 2016 14:49:19 +0100 Subject: [PATCH 009/179] Adding layout for event-vue --- Resources/views/layout.html.twig | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Resources/views/layout.html.twig diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig new file mode 100644 index 000000000..cbe1b9b47 --- /dev/null +++ b/Resources/views/layout.html.twig @@ -0,0 +1,31 @@ +{# + * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + / + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} + +{% extends "ChillMainBundle::layoutWithVerticalMenu.html.twig" %} + +{% block vertical_menu_content %} + {{ chill_menu('event', { + 'layout': 'ChillMainBundle::Menu/verticalMenu.html.twig', + }) }} +{% endblock %} + +{% block layout_wvm_content %} + {% block event_content %} +

{{ 'Event Menu' |trans }}

+ {% endblock %} +{% endblock %} From 6d2bb8ca1dce3da11f2547cd5d224ad928f7d9e9 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 22 Mar 2016 15:35:21 +0100 Subject: [PATCH 010/179] Correction of the comment & H1 title --- Resources/views/layout.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index cbe1b9b47..091092cf6 100644 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -25,7 +25,7 @@ {% endblock %} {% block layout_wvm_content %} - {% block event_content %} -

{{ 'Event Menu' |trans }}

+ {% block event_content %}} +

{{ 'Event' |trans }}

{% endblock %} {% endblock %} From 55a2c667939ff51d88366eba81940bd97d4b6597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 22 Mar 2016 17:01:25 +0100 Subject: [PATCH 011/179] adding a basic search page, which create event list ref #10 ref #18 --- DataFixtures/ORM/LoadRolesACL.php | 84 ++++++++++++ DependencyInjection/ChillEventExtension.php | 36 ++++- Resources/config/services.yml | 4 - Resources/config/services/authorization.yml | 8 ++ Resources/config/services/repositories.yml | 6 + Resources/config/services/search.yml | 11 ++ Resources/translations/messages.fr.yml | 11 ++ Resources/views/Event/list.html.twig | 43 ++++++ Search/EventSearch.php | 143 ++++++++++++++++++++ Security/Authorization/EventVoter.php | 63 +++++++++ 10 files changed, 402 insertions(+), 7 deletions(-) create mode 100644 DataFixtures/ORM/LoadRolesACL.php delete mode 100644 Resources/config/services.yml create mode 100644 Resources/config/services/authorization.yml create mode 100644 Resources/config/services/repositories.yml create mode 100644 Resources/config/services/search.yml create mode 100644 Resources/translations/messages.fr.yml create mode 100644 Resources/views/Event/list.html.twig create mode 100644 Search/EventSearch.php create mode 100644 Security/Authorization/EventVoter.php diff --git a/DataFixtures/ORM/LoadRolesACL.php b/DataFixtures/ORM/LoadRolesACL.php new file mode 100644 index 000000000..c0236d25c --- /dev/null +++ b/DataFixtures/ORM/LoadRolesACL.php @@ -0,0 +1,84 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + + +namespace Chill\EventBundle\DataFixtures\ORM; + +use Doctrine\Common\DataFixtures\AbstractFixture; +use Doctrine\Common\DataFixtures\OrderedFixtureInterface; +use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; +use Chill\MainBundle\Entity\RoleScope; +use Chill\MainBundle\DataFixtures\ORM\LoadScopes; +use Doctrine\Common\Persistence\ObjectManager; + +/** + * Add roles to existing groups + * + * @author Julien Fastré + * @author Champs Libres + */ +class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface +{ + public function load(ObjectManager $manager) + { + foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { + $permissionsGroup = $this->getReference($permissionsGroupRef); + foreach (LoadScopes::$references as $scopeRef){ + $scope = $this->getReference($scopeRef); + //create permission group + switch ($permissionsGroup->getName()) { + case 'social': + if ($scope->getName()['en'] === 'administrative') { + break 2; // we do not want any power on administrative + } + break; + case 'administrative': + case 'direction': + if (in_array($scope->getName()['en'], array('administrative', 'social'))) { + break 2; // we do not want any power on social or administrative + } + break; + } + + printf("Adding CHILL_EVENT_UPDATE & CHILL_EVENT_CREATE to %s " + . "permission group, scope '%s' \n", + $permissionsGroup->getName(), $scope->getName()['en']); + $roleScopeUpdate = (new RoleScope()) + ->setRole('CHILL_EVENT_UPDATE') + ->setScope($scope); + $permissionsGroup->addRoleScope($roleScopeUpdate); + $roleScopeCreate = (new RoleScope()) + ->setRole('CHILL_EVENT_CREATE') + ->setScope($scope); + $permissionsGroup->addRoleScope($roleScopeCreate); + $manager->persist($roleScopeUpdate); + $manager->persist($roleScopeCreate); + } + + } + + $manager->flush(); + } + + public function getOrder() + { + return 30011; + } + +} diff --git a/DependencyInjection/ChillEventExtension.php b/DependencyInjection/ChillEventExtension.php index 1035659fd..5933488f1 100644 --- a/DependencyInjection/ChillEventExtension.php +++ b/DependencyInjection/ChillEventExtension.php @@ -7,6 +7,7 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; +use Chill\EventBundle\Security\Authorization\EventVoter; /** * This is the class that loads and manages your bundle configuration @@ -23,8 +24,11 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.yml'); + $loader = new Loader\YamlFileLoader($container, + new FileLocator(__DIR__.'/../Resources/config/services')); + $loader->load('repositories.yml'); + $loader->load('search.yml'); + $loader->load('authorization.yml'); } /* (non-PHPdoc) @@ -32,7 +36,17 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface */ public function prepend(ContainerBuilder $container) { - + $this->prependAuthorization($container); + $this->prependRoute($container); + } + + /** + * add route to route loader for chill + * + * @param ContainerBuilder $container + */ + protected function prependRoute(ContainerBuilder $container) + { //add routes for custom bundle $container->prependExtensionConfig('chill_main', array( 'routing' => array( @@ -42,4 +56,20 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface ) )); } + + /** + * add authorization hierarchy + * + * @param ContainerBuilder $container + */ + protected function prependAuthorization(ContainerBuilder $container) + { + $container->prependExtensionConfig('security', array( + 'role_hierarchy' => array( + EventVoter::SEE_DETAILS => array(EventVoter::SEE), + EventVoter::UPDATE => array(EventVoter::SEE_DETAILS), + EventVoter::CREATE => array(EventVoter::SEE_DETAILS) + ) + )); + } } diff --git a/Resources/config/services.yml b/Resources/config/services.yml deleted file mode 100644 index d2cfb62f0..000000000 --- a/Resources/config/services.yml +++ /dev/null @@ -1,4 +0,0 @@ -services: -# chill_event.example: -# class: Chill\EventBundle\Example -# arguments: [@service_id, "plain_value", %parameter%] diff --git a/Resources/config/services/authorization.yml b/Resources/config/services/authorization.yml new file mode 100644 index 000000000..9adb5b087 --- /dev/null +++ b/Resources/config/services/authorization.yml @@ -0,0 +1,8 @@ +services: + chill_event.event_voter: + class: Chill\EventBundle\Security\Authorization\EventVoter + arguments: + - "@chill.main.security.authorization.helper" + tags: + - { name: chill.role } + - { name: security.voter } diff --git a/Resources/config/services/repositories.yml b/Resources/config/services/repositories.yml new file mode 100644 index 000000000..44e653cc0 --- /dev/null +++ b/Resources/config/services/repositories.yml @@ -0,0 +1,6 @@ +services: + chill_group.repository.event: + class: Doctrine\ORM\EntityRepository + factory: ['@doctrine.orm.entity_manager', getRepository] + arguments: + - 'Chill\EventBundle\Entity\Event' \ No newline at end of file diff --git a/Resources/config/services/search.yml b/Resources/config/services/search.yml new file mode 100644 index 000000000..99b455bae --- /dev/null +++ b/Resources/config/services/search.yml @@ -0,0 +1,11 @@ +services: + chill_event.search_events: + class: Chill\EventBundle\Search\EventSearch + arguments: + - "@security.token_storage" + - "@chill_group.repository.event" + - "@chill.main.security.authorization.helper" + - "@templating" + tags: + - { name: chill.search, alias: 'event_regular' } + diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml new file mode 100644 index 000000000..d579fd3a2 --- /dev/null +++ b/Resources/translations/messages.fr.yml @@ -0,0 +1,11 @@ +#events +Name: Nom +Date: Date +Event type : Type d'événement +See: Voir + + + +#search +Event search: Recherche d'événements +'%total% events match the search %pattern%' : '{0} Aucun événement ne correspond aux termes de recherche "%pattern%" | {1} Un événement a été trouvé par la recherche "%pattern%" | ]1,Inf] %total% événements correspondent aux termes de recherche "%pattern%".' diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig new file mode 100644 index 000000000..9e158b285 --- /dev/null +++ b/Resources/views/Event/list.html.twig @@ -0,0 +1,43 @@ +

{{ 'Event search'|trans }}

+ +

{% transchoice total with { '%pattern%' : pattern } %}%total% events match the search %pattern%{% endtranschoice %}

+ + +{% if events|length > 0 %} + + + + + + + + + + + {% for event in events %} + + + + + + + {% endfor %} + +
{{ 'Name'|trans }}{{ 'Date'|trans }}{{ 'Event type'|trans }} 
{{ event.label }}{{ event.date|localizeddate('long', 'none') }}{{ event.type.label|localize_translatable_string }} + +
+ +{% endif %} \ No newline at end of file diff --git a/Search/EventSearch.php b/Search/EventSearch.php new file mode 100644 index 000000000..c2b4e4e80 --- /dev/null +++ b/Search/EventSearch.php @@ -0,0 +1,143 @@ + + * @author Champs Libres + */ +class EventSearch extends AbstractSearch +{ + + /** + * + * @var EntityRepository + */ + private $er; + + /** + * + * @var \Chill\MainBundle\Entity\User + */ + private $user; + + /** + * + * @var AuthorizationHelper + */ + private $helper; + + /** + * + * @var TemplatingEngine + */ + private $templating; + + + public function __construct( + TokenStorageInterface $tokenStorage, + EntityRepository $eventRepository, + AuthorizationHelper $authorizationHelper, + TemplatingEngine $templating + ) + { + $this->user = $tokenStorage->getToken()->getUser(); + $this->er = $eventRepository; + $this->helper = $authorizationHelper; + $this->templating = $templating; + } + + public function supports($domain) + { + return 'event' === $domain or 'events' === $domain; + } + + public function isActiveByDefault() + { + return false; + } + + public function getOrder() + { + return 3000; + } + + public function renderResult(array $terms, $start = 0, $limit = 50, array $options = array()) + { + return $this->templating->render('ChillEventBundle:Event:list.html.twig', + array( + 'events' => $this->search($terms, $start, $limit, $options), + 'pattern' => $this->recomposePattern($terms, array(), $terms['_domain']), + 'total' => $this->count($terms) + )); + } + + protected function search(array $terms, $start, $limit, $options) + { + $qb = $this->er->createQueryBuilder('e'); + $qb->select('e'); + $this->composeQuery($qb, $terms) + ->setMaxResults($limit) + ->setFirstResult($start) + ->orderBy('e.date', 'DESC') + ; + + return $qb->getQuery()->getResult(); + } + + protected function count(array $terms) + { + $qb = $this->er->createQueryBuilder('e'); + $qb->select('COUNT(e)'); + $this->composeQuery($qb, $terms) + ; + + return $qb->getQuery()->getSingleScalarResult(); + } + + protected function composeQuery(QueryBuilder &$qb, $terms) + { + + // add security clauses + $reachableCenters = $this->helper + ->getReachableCenters($this->user, new Role('CHILL_EVENT_SEE')); + + if (count($reachableCenters) === 0) { + // add a clause to block all events + $where = $qb->expr()->isNull('e.center'); + $qb->andWhere($where); + } else { + + $n = 0; + $orWhere = $qb->expr()->orX(); + foreach ($reachableCenters as $center) { + $circles = $this->helper->getReachableScopes($this->user, + new Role('CHILL_EVENT_SEE'), $center); + $where = $qb->expr()->andX( + $qb->expr()->eq('e.center', ':center_'.$n), + $qb->expr()->in('e.circle', ':circle_'.$n) + ); + $qb->setParameter('center_'.$n, $center); + $qb->setParameter('circle_'.$n, $circles); + $orWhere->add($where); + } + + $qb->andWhere($orWhere); + } + + + + return $qb; + } +} diff --git a/Security/Authorization/EventVoter.php b/Security/Authorization/EventVoter.php new file mode 100644 index 000000000..23fcccf28 --- /dev/null +++ b/Security/Authorization/EventVoter.php @@ -0,0 +1,63 @@ + + * @author Champs Libres + */ +class EventVoter extends AbstractChillVoter implements ProvideRoleInterface +{ + + const SEE = 'CHILL_EVENT_SEE'; + const SEE_DETAILS = 'CHILL_EVENT_SEE_DETAILS'; + const CREATE = 'CHILL_EVENT_CREATE'; + const UPDATE = 'CHILL_EVENT_UPDATE'; + + protected $authorizationHelper; + + public function __construct(AuthorizationHelper $helper) + { + $this->authorizationHelper = $helper; + } + + protected function getSupportedAttributes() + { + return array(self::SEE, self::SEE_DETAILS, + self::CREATE, self::UPDATE); + } + + protected function getSupportedClasses() + { + return array(Event::class); + } + + protected function isGranted($attribute, $event, $user = null) + { + if (!$user instanceof User) { + return false; + } + + return $this->helper->userHasAccess($user, $event, $attribute); + } + + public function getRoles() + { + return $this->getSupportedAttributes(); + } + + public function getRolesWithoutScope() + { + return null; + } + +} From 4d02314770096ce492e23df83f1c4370275f69f1 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 22 Mar 2016 17:16:19 +0100 Subject: [PATCH 012/179] Event CRUD generated --- Controller/EventController.php | 224 +++++++++++++++++++++++ Form/EventType.php | 43 +++++ Resources/config/routing.yml | 4 + Resources/config/routing/event.yml | 30 +++ Resources/views/Event/edit.html.twig | 16 ++ Resources/views/Event/index.html.twig | 43 +++++ Resources/views/Event/new.html.twig | 15 ++ Resources/views/Event/show.html.twig | 36 ++++ Tests/Controller/EventControllerTest.php | 55 ++++++ 9 files changed, 466 insertions(+) create mode 100644 Controller/EventController.php create mode 100644 Form/EventType.php create mode 100644 Resources/config/routing/event.yml create mode 100644 Resources/views/Event/edit.html.twig create mode 100644 Resources/views/Event/index.html.twig create mode 100644 Resources/views/Event/new.html.twig create mode 100644 Resources/views/Event/show.html.twig create mode 100644 Tests/Controller/EventControllerTest.php diff --git a/Controller/EventController.php b/Controller/EventController.php new file mode 100644 index 000000000..b084218df --- /dev/null +++ b/Controller/EventController.php @@ -0,0 +1,224 @@ +getDoctrine()->getManager(); + + $entities = $em->getRepository('ChillEventBundle:Event')->findAll(); + + return $this->render('ChillEventBundle:Event:index.html.twig', array( + 'entities' => $entities, + )); + } + /** + * Creates a new Event entity. + * + */ + public function createAction(Request $request) + { + $entity = new Event(); + $form = $this->createCreateForm($entity); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($entity); + $em->flush(); + + return $this->redirect($this->generateUrl('event_show', array('id' => $entity->getId()))); + } + + return $this->render('ChillEventBundle:Event:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Creates a form to create a Event entity. + * + * @param Event $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createCreateForm(Event $entity) + { + $form = $this->createForm(new EventType(), $entity, array( + 'action' => $this->generateUrl('event_create'), + 'method' => 'POST', + )); + + $form->add('submit', 'submit', array('label' => 'Create')); + + return $form; + } + + /** + * Displays a form to create a new Event entity. + * + */ + public function newAction() + { + $entity = new Event(); + $form = $this->createCreateForm($entity); + + return $this->render('ChillEventBundle:Event:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Finds and displays a Event entity. + * + */ + public function showAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Event')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Event entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:Event:show.html.twig', array( + 'entity' => $entity, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing Event entity. + * + */ + public function editAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Event')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Event entity.'); + } + + $editForm = $this->createEditForm($entity); + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:Event:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Creates a form to edit a Event entity. + * + * @param Event $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createEditForm(Event $entity) + { + $form = $this->createForm(new EventType(), $entity, array( + 'action' => $this->generateUrl('event_update', array('id' => $entity->getId())), + 'method' => 'PUT', + )); + + $form->add('submit', 'submit', array('label' => 'Update')); + + return $form; + } + /** + * Edits an existing Event entity. + * + */ + public function updateAction(Request $request, $id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Event')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Event entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + $editForm = $this->createEditForm($entity); + $editForm->handleRequest($request); + + if ($editForm->isValid()) { + $em->flush(); + + return $this->redirect($this->generateUrl('event_edit', array('id' => $id))); + } + + return $this->render('ChillEventBundle:Event:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + /** + * Deletes a Event entity. + * + */ + public function deleteAction(Request $request, $id) + { + $form = $this->createDeleteForm($id); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $entity = $em->getRepository('ChillEventBundle:Event')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Event entity.'); + } + + $em->remove($entity); + $em->flush(); + } + + return $this->redirect($this->generateUrl('event')); + } + + /** + * Creates a form to delete a Event entity by id. + * + * @param mixed $id The entity id + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm($id) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('event_delete', array('id' => $id))) + ->setMethod('DELETE') + ->add('submit', 'submit', array('label' => 'Delete')) + ->getForm() + ; + } +} diff --git a/Form/EventType.php b/Form/EventType.php new file mode 100644 index 000000000..5434681a7 --- /dev/null +++ b/Form/EventType.php @@ -0,0 +1,43 @@ +add('label') + ->add('date') + ->add('center') + ->add('type') + ->add('circle') + ; + } + + /** + * @param OptionsResolverInterface $resolver + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'Chill\EventBundle\Entity\Event' + )); + } + + /** + * @return string + */ + public function getName() + { + return 'chill_eventbundle_event'; + } +} diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index f6262b049..83a6a4093 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,3 +1,7 @@ +chill_event_event: + resource: "@ChillEventBundle/Resources/config/routing/event.yml" + prefix: /event + chill_event_fr_admin_event_status: resource: "@ChillEventBundle/Resources/config/routing/status.yml" prefix: /{_locale}/admin/event/status diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml new file mode 100644 index 000000000..cd3573f4e --- /dev/null +++ b/Resources/config/routing/event.yml @@ -0,0 +1,30 @@ +event: + path: / + defaults: { _controller: "ChillEventBundle:Event:index" } + +event_show: + path: /{id}/show + defaults: { _controller: "ChillEventBundle:Event:show" } + +event_new: + path: /new + defaults: { _controller: "ChillEventBundle:Event:new" } + +event_create: + path: /create + defaults: { _controller: "ChillEventBundle:Event:create" } + methods: POST + +event_edit: + path: /{id}/edit + defaults: { _controller: "ChillEventBundle:Event:edit" } + +event_update: + path: /{id}/update + defaults: { _controller: "ChillEventBundle:Event:update" } + methods: [POST, PUT] + +event_delete: + path: /{id}/delete + defaults: { _controller: "ChillEventBundle:Event:delete" } + methods: [POST, DELETE] diff --git a/Resources/views/Event/edit.html.twig b/Resources/views/Event/edit.html.twig new file mode 100644 index 000000000..733f7332c --- /dev/null +++ b/Resources/views/Event/edit.html.twig @@ -0,0 +1,16 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Event edit

+ + {{ form(edit_form) }} + + +{% endblock %} diff --git a/Resources/views/Event/index.html.twig b/Resources/views/Event/index.html.twig new file mode 100644 index 000000000..9ba265dda --- /dev/null +++ b/Resources/views/Event/index.html.twig @@ -0,0 +1,43 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Event list

+ + + + + + + + + + + + {% for entity in entities %} + + + + + + + {% endfor %} + +
IdLabelDateActions
{{ entity.id }}{{ entity.label }}{% if entity.date %}{{ entity.date|date('Y-m-d H:i:s') }}{% endif %} + +
+ + + {% endblock %} diff --git a/Resources/views/Event/new.html.twig b/Resources/views/Event/new.html.twig new file mode 100644 index 000000000..25e6d2661 --- /dev/null +++ b/Resources/views/Event/new.html.twig @@ -0,0 +1,15 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Event creation

+ + {{ form(form) }} + + +{% endblock %} diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig new file mode 100644 index 000000000..a2e9f85cb --- /dev/null +++ b/Resources/views/Event/show.html.twig @@ -0,0 +1,36 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Event

+ + + + + + + + + + + + + + + + +
Id{{ entity.id }}
Label{{ entity.label }}
Date{{ entity.date|date('Y-m-d H:i:s') }}
+ + +{% endblock %} diff --git a/Tests/Controller/EventControllerTest.php b/Tests/Controller/EventControllerTest.php new file mode 100644 index 000000000..6435a2712 --- /dev/null +++ b/Tests/Controller/EventControllerTest.php @@ -0,0 +1,55 @@ +request('GET', '/event/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /event/"); + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Create')->form(array( + 'chill_eventbundle_event[field_name]' => 'Test', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check data in the show view + $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")'); + + // Edit the entity + $crawler = $client->click($crawler->selectLink('Edit')->link()); + + $form = $crawler->selectButton('Update')->form(array( + 'chill_eventbundle_event[field_name]' => 'Foo', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check the element contains an attribute with value equals "Foo" + $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]'); + + // Delete the entity + $client->submit($crawler->selectButton('Delete')->form()); + $crawler = $client->followRedirect(); + + // Check the entity has been delete on the list + $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent()); + } + + */ +} From 26fa6a2c5634c037c8fb8752fcabf1ee1e14fe48 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 22 Mar 2016 18:26:34 +0100 Subject: [PATCH 013/179] Route for event is now {locale}/event/event --- Resources/config/routing.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 83a6a4093..0f58caa77 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,6 +1,6 @@ chill_event_event: resource: "@ChillEventBundle/Resources/config/routing/event.yml" - prefix: /event + prefix: /{_locale}/event/event chill_event_fr_admin_event_status: resource: "@ChillEventBundle/Resources/config/routing/status.yml" @@ -13,4 +13,3 @@ chill_event_admin_role: chill_event_admin_event_type: resource: "@ChillEventBundle/Resources/config/routing/eventtype.yml" prefix: /{_locale}/admin/event/event_type - From 041c43a93659b0fb0014d2acd682f585e89cbbc1 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 22 Mar 2016 18:59:59 +0100 Subject: [PATCH 014/179] Basic form to create an Event --- Form/EventType.php | 14 +++++++++++--- Resources/views/Event/new.html.twig | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Form/EventType.php b/Form/EventType.php index 5434681a7..bdfad1855 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -16,10 +16,18 @@ class EventType extends AbstractType { $builder ->add('label') - ->add('date') + ->add( + 'date', + 'date', + array( + 'required' => true, + 'widget' => 'single_text', + 'format' => 'dd-MM-yyyy' + ) + ) ->add('center') - ->add('type') - ->add('circle') + //->add('type') + //->add('circle') ; } diff --git a/Resources/views/Event/new.html.twig b/Resources/views/Event/new.html.twig index 25e6d2661..46b00a2b2 100644 --- a/Resources/views/Event/new.html.twig +++ b/Resources/views/Event/new.html.twig @@ -1,6 +1,6 @@ -{% extends '::base.html.twig' %} +{% extends 'ChillEventBundle::layout.html.twig' %} -{% block body -%} +{% block event_content -%}

Event creation

{{ form(form) }} From 888bcad81a794b4d459e5b865f9efbbd7bc35dcd Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 22 Mar 2016 20:34:34 +0100 Subject: [PATCH 015/179] Adding type to the creation event form --- DependencyInjection/ChillEventExtension.php | 1 + Form/EventType.php | 3 +- Form/Type/TranslatableEventType.php | 70 +++++++++++++++++++++ Resources/config/services/forms.yml | 7 +++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 Form/Type/TranslatableEventType.php create mode 100644 Resources/config/services/forms.yml diff --git a/DependencyInjection/ChillEventExtension.php b/DependencyInjection/ChillEventExtension.php index 5933488f1..29e273178 100644 --- a/DependencyInjection/ChillEventExtension.php +++ b/DependencyInjection/ChillEventExtension.php @@ -29,6 +29,7 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface $loader->load('repositories.yml'); $loader->load('search.yml'); $loader->load('authorization.yml'); + $loader->load('forms.yml'); } /* (non-PHPdoc) diff --git a/Form/EventType.php b/Form/EventType.php index bdfad1855..053c02007 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -5,6 +5,7 @@ namespace Chill\EventBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Chill\EventBundle\Form\Type\TranslatableEventType; class EventType extends AbstractType { @@ -26,7 +27,7 @@ class EventType extends AbstractType ) ) ->add('center') - //->add('type') + ->add('type', TranslatableEventType::class) //->add('circle') ; } diff --git a/Form/Type/TranslatableEventType.php b/Form/Type/TranslatableEventType.php new file mode 100644 index 000000000..cf2abc14a --- /dev/null +++ b/Form/Type/TranslatableEventType.php @@ -0,0 +1,70 @@ +, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\EventBundle\Form\Type; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Doctrine\ORM\EntityRepository; +use Chill\EventBundle\Entity\EventType; + +/** + * Description of TranslatableEventType + * + * @author Champs-Libres Coop + */ +class TranslatableEventType extends AbstractType +{ + /** + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + public function __construct(TranslatableStringHelper $helper) + { + $this->translatableStringHelper = $helper; + } + + public function getParent() + { + return EntityType::class; + } + + public function configureOptions(OptionsResolver $resolver) + { + $helper = $this->translatableStringHelper; + $resolver->setDefaults( + array( + 'class' => EventType::class, + 'query_builder' => function (EntityRepository $er) { + return $er->createQueryBuilder('et') + ->where('et.active = true'); + }, + 'choice_label' => function (EventType $t) use ($helper) { + return $helper->localize($t->getLabel()); + }, + ) + ); + } +} diff --git a/Resources/config/services/forms.yml b/Resources/config/services/forms.yml new file mode 100644 index 000000000..1dc75d5e4 --- /dev/null +++ b/Resources/config/services/forms.yml @@ -0,0 +1,7 @@ +services: + chill_event.form.event_type_type: + class: Chill\EventBundle\Form\Type\TranslatableEventType + arguments: + - "@chill.main.helper.translatable_string" + tags: + - { name: form.type } From 90cbb78621ba7d221738c7ad21dd1c1d61ba2ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 22 Mar 2016 21:18:32 +0100 Subject: [PATCH 016/179] add a "view page" for event ref #3 --- Controller/EventController.php | 10 +-- Entity/Event.php | 5 +- Resources/config/routing/event.yml | 2 +- Resources/translations/messages.fr.yml | 9 +++ Resources/views/Event/list.html.twig | 6 +- Resources/views/Event/show.html.twig | 89 +++++++++++++++++++------- Resources/views/layout.html.twig | 2 +- Security/Authorization/EventVoter.php | 7 +- 8 files changed, 94 insertions(+), 36 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index b084218df..0cccb2f83 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -91,21 +91,21 @@ class EventController extends Controller * Finds and displays a Event entity. * */ - public function showAction($id) + public function showAction($event_id) { $em = $this->getDoctrine()->getManager(); - $entity = $em->getRepository('ChillEventBundle:Event')->find($id); + $entity = $em->getRepository('ChillEventBundle:Event')->find($event_id); if (!$entity) { throw $this->createNotFoundException('Unable to find Event entity.'); } - $deleteForm = $this->createDeleteForm($id); + $this->denyAccessUnlessGranted('CHILL_EVENT_SEE_DETAILS', $entity, + "You are not allowed to see details on this event"); return $this->render('ChillEventBundle:Event:show.html.twig', array( - 'entity' => $entity, - 'delete_form' => $deleteForm->createView(), + 'event' => $entity )); } diff --git a/Entity/Event.php b/Entity/Event.php index 763f27f56..ac10db4cb 100644 --- a/Entity/Event.php +++ b/Entity/Event.php @@ -2,10 +2,13 @@ namespace Chill\EventBundle\Entity; +use Chill\MainBundle\Entity\HasScopeInterface; +use Chill\MainBundle\Entity\HasCenterInterface; + /** * Event */ -class Event +class Event implements HasScopeInterface, HasCenterInterface { /** * @var integer diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index cd3573f4e..84d775aab 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -3,7 +3,7 @@ event: defaults: { _controller: "ChillEventBundle:Event:index" } event_show: - path: /{id}/show + path: /{event_id}/show defaults: { _controller: "ChillEventBundle:Event:show" } event_new: diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index d579fd3a2..90a759f7c 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -3,8 +3,17 @@ Name: Nom Date: Date Event type : Type d'événement See: Voir +Event: Événement +'Event : %label%': Événement "%label%" +Participation: Participation +Status: Statut +Last update: Dernière mise à jour +'%count% participations to this event': '{0} Aucun participant à l''événement | {1} Un participant à l''événement | ]1,Inf] %count% participants à l''événement' +#CRUD +Details of an event: Détails d'un événement +Edit all the participations: Modifier toutes les participations #search Event search: Recherche d'événements diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig index 9e158b285..f7338fd98 100644 --- a/Resources/views/Event/list.html.twig +++ b/Resources/views/Event/list.html.twig @@ -22,11 +22,11 @@
  • - {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} - + {# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #} + {{ 'See'|trans }} - {% endif %} + {# {% endif %} #} {% if is_granted('CHILL_EVENT_UPDATE', event) %} {{ 'Edit'|trans }} diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index a2e9f85cb..1a500381a 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -1,36 +1,81 @@ -{% extends '::base.html.twig' %} +{% extends 'ChillEventBundle::layout.html.twig' %} -{% block body -%} -

    Event

    +{% block title 'Event : %label%'|trans({ '%label%' : event.label } ) %} + +{% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} + +{% block event_content -%} +

    {{ 'Details of an event'|trans }}

    - - + + - - + + - - + + + + + +
    Id{{ entity.id }}{{ 'Name'|trans }}{{ event.label }}
    Label{{ entity.label }}{{ 'Date'|trans }}{{ event.date|localizeddate('long', 'none') }}
    Date{{ entity.date|date('Y-m-d H:i:s') }}{{ 'Event type'|trans }}{{ event.type.label|localize_translatable_string }}
    {{ 'Circle'|trans }}{{ event.circle.name|localize_translatable_string }}
    + +
    + +

    {{ 'Participation'|trans }}

    + {% set count = event.participations|length %} +

    {% transchoice count %}%count% participations to this event{% endtranschoice %}

    + + {% if count > 0 %} + + + + + + + + + + + + {% for participation in event.participations %} + + + + + + + + {% endfor %} + +
    {{ 'Person'|trans }}{{ 'Role'|trans }}{{ 'Status'|trans }}{{ 'Last update'|trans }} 
    {{ person_macro.render(participation.person) }}{{ participation.role.label|localize_translatable_string }}{{ participation.status.label|localize_translatable_string }}{{ participation.lastUpdate|localizeddate("long", "none") }} + +
    + + + {% endif %} - + {% endblock %} diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index 091092cf6..a788962e3 100644 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -25,7 +25,7 @@ {% endblock %} {% block layout_wvm_content %} - {% block event_content %}} + {% block event_content %}

    {{ 'Event' |trans }}

    {% endblock %} {% endblock %} diff --git a/Security/Authorization/EventVoter.php b/Security/Authorization/EventVoter.php index 23fcccf28..dc7a63971 100644 --- a/Security/Authorization/EventVoter.php +++ b/Security/Authorization/EventVoter.php @@ -8,6 +8,7 @@ use Chill\MainBundle\Security\Authorization\AbstractChillVoter; use Chill\MainBundle\Security\ProvideRoleInterface; use Chill\EventBundle\Entity\Event; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Chill\MainBundle\Entity\User; /** * Description of EventVoter @@ -42,12 +43,12 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleInterface } protected function isGranted($attribute, $event, $user = null) - { + { if (!$user instanceof User) { return false; - } + } - return $this->helper->userHasAccess($user, $event, $attribute); + return $this->authorizationHelper->userHasAccess($user, $event, $attribute); } public function getRoles() From 4fe31185df451304a1e52df50e52f1786eacab01 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 23 Mar 2016 18:19:48 +0100 Subject: [PATCH 017/179] Good Center - Circle suggested --- Controller/EventController.php | 6 +-- Entity/Event.php | 17 +++--- Form/EventType.php | 82 ++++++++++++++++++++++++++++- Resources/config/services/forms.yml | 11 +++- 4 files changed, 103 insertions(+), 13 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index b084218df..8d08f281f 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -4,10 +4,10 @@ namespace Chill\EventBundle\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; - use Chill\EventBundle\Entity\Event; use Chill\EventBundle\Form\EventType; + /** * Event controller. * @@ -62,9 +62,9 @@ class EventController extends Controller */ private function createCreateForm(Event $entity) { - $form = $this->createForm(new EventType(), $entity, array( + $form = $this->createForm(EventType::class, $entity, array( 'action' => $this->generateUrl('event_create'), - 'method' => 'POST', + 'method' => 'POST' )); $form->add('submit', 'submit', array('label' => 'Create')); diff --git a/Entity/Event.php b/Entity/Event.php index 763f27f56..d9512fda0 100644 --- a/Entity/Event.php +++ b/Entity/Event.php @@ -2,10 +2,13 @@ namespace Chill\EventBundle\Entity; +use Chill\MainBundle\Entity\HasCenterInterface; +use Chill\MainBundle\Entity\HasScopeInterface; + /** * Event */ -class Event +class Event implements HasCenterInterface, HasScopeInterface { /** * @var integer @@ -120,7 +123,7 @@ class Event } /** - * + * * @return EventType */ public function getType() @@ -129,7 +132,7 @@ class Event } /** - * + * * @param \Chill\EventBundle\Entity\EventType $type * @return \Chill\EventBundle\Entity\Event */ @@ -140,7 +143,7 @@ class Event } /** - * + * * @return \Chill\MainBundle\Entity\Center */ public function getCenter() @@ -149,7 +152,7 @@ class Event } /** - * + * * @return \Chill\MainBundle\Entity\Scope */ public function getCircle() @@ -158,7 +161,7 @@ class Event } /** - * + * * @param \Chill\MainBundle\Entity\Scope $circle * @return \Chill\EventBundle\Entity\Event */ @@ -169,7 +172,7 @@ class Event } /** - * + * * @deprecated * @return \Chill\MainBundle\Entity\Scope */ diff --git a/Form/EventType.php b/Form/EventType.php index 053c02007..5ad2f6414 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -6,15 +6,66 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; use Chill\EventBundle\Form\Type\TranslatableEventType; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Doctrine\Common\Persistence\ObjectManager; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Chill\MainBundle\Entity\User; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Chill\MainBundle\Entity\Center; +use Chill\MainBundle\Entity\Scope; + +use Symfony\Component\Security\Core\Role\Role; class EventType extends AbstractType { + + /** @var the user running this form */ + protected $user; + + /** @var AuthorizationHelper */ + protected $authorizationHelper; + + /** @var TranslatableStringHelper */ + protected $translatableStringHelper; + + public function __construct( + TokenStorageInterface $tokenStorage, + AuthorizationHelper $authorizationHelper, + TranslatableStringHelper $translatableStringHelper + ) { + if (!$tokenStorage->getToken()->getUser() instanceof User) { + throw new \RuntimeException("you should have a valid user"); + } + $this->user = $tokenStorage->getToken()->getUser(); + $this->authorizationHelper = $authorizationHelper; + $this->translatableStringHelper = $translatableStringHelper; + } + /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { + $userReachableCenters = $this->authorizationHelper + ->getReachableCenters($this->user, new Role('CHILL_EVENT_CREATE')); + + $userReachableCirclesByCircleId = array(); + $userReachableCentersByCircleId = array(); + + foreach ($userReachableCenters as $center) { + foreach ($this->authorizationHelper + ->getReachableCircles($this->user, new Role('CHILL_EVENT_CREATE'), $center) as $circle) { + if (array_key_exists($circle->getId(), $userReachableCirclesByCircleId)) { + array_push($userReachableCentersByCircleId[$circle->getId()], $center); + } else { + $userReachableCirclesByCircleId[$circle->getId()] = $circle; + $userReachableCentersByCircleId[$circle->getId()] = array($center); + } + } + } + $builder ->add('label') ->add( @@ -26,9 +77,36 @@ class EventType extends AbstractType 'format' => 'dd-MM-yyyy' ) ) - ->add('center') + ->add('center', EntityType::class, array( + 'class' => Center::class, + 'choices' => $userReachableCenters, + 'choice_attr' => function (Center $center) { + return array( + 'data-link-category' => $center->getId() + ); + }, + )) + ->add('circle', EntityType::class, array( + 'class' => Scope::class, + 'choices' => array_values($userReachableCirclesByCircleId), + 'choice_label' => function ($circle) { + $helper = $this->translatableStringHelper; + return $helper->localize($circle->getName()); + }, + 'choice_attr' => function ($circle) use ($userReachableCentersByCircleId) { + $centersId = ""; + foreach ($userReachableCentersByCircleId[$circle->getId()] as $center) { + print $center; + $centersId = $centersId.($center->getId()).','; + } + $centersId = trim($centersId, ','); + return array( + 'data-link-categories' => $centersId, + + ); + }, + )) ->add('type', TranslatableEventType::class) - //->add('circle') ; } diff --git a/Resources/config/services/forms.yml b/Resources/config/services/forms.yml index 1dc75d5e4..2f1cb1d00 100644 --- a/Resources/config/services/forms.yml +++ b/Resources/config/services/forms.yml @@ -1,7 +1,16 @@ services: - chill_event.form.event_type_type: + chill.event.form.type.translatable_event_type: class: Chill\EventBundle\Form\Type\TranslatableEventType arguments: - "@chill.main.helper.translatable_string" tags: - { name: form.type } + + chill.event.form.event_type_test: + class: Chill\EventBundle\Form\EventType + arguments: + - "@security.token_storage" + - "@chill.main.security.authorization.helper" + - "@chill.main.helper.translatable_string" + tags: + - { name: form.type } From 5c29e85e4e66fd415bc1dc28cb457f180d88f414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 23 Mar 2016 21:57:25 +0100 Subject: [PATCH 018/179] prevent test/fixtures to be registered --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 9f103fd7c..a06b406d1 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,8 @@ app/config/parameters.ini app/config/parameters.yml Tests/Fixtures/App/config/parameters.yml +# fixtures +Resources/test/* + #composer composer.lock From e2decee8cb48a4980d1613cd7f80cc06b7b6fb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 23 Mar 2016 21:57:42 +0100 Subject: [PATCH 019/179] add a form to make a ling with 'add a participant' page --- Controller/EventController.php | 49 +++++++++++++++++++++- Resources/config/routing.yml | 4 ++ Resources/config/routing/participation.yml | 3 ++ Resources/translations/messages.fr.yml | 1 + Resources/views/Event/show.html.twig | 8 +++- 5 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 Resources/config/routing/participation.yml diff --git a/Controller/EventController.php b/Controller/EventController.php index 0cccb2f83..6fd94d173 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -4,9 +4,13 @@ namespace Chill\EventBundle\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; - +use Chill\PersonBundle\Form\Type\PickPersonType; use Chill\EventBundle\Entity\Event; use Chill\EventBundle\Form\EventType; +use Symfony\Component\Security\Core\Role\Role; +use Symfony\Component\Form\Extension\Core\Type\FormType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; /** * Event controller. @@ -103,11 +107,52 @@ class EventController extends Controller $this->denyAccessUnlessGranted('CHILL_EVENT_SEE_DETAILS', $entity, "You are not allowed to see details on this event"); + + $addParticipationByPersonForm = $this->createAddParticipationByPersonForm($entity); return $this->render('ChillEventBundle:Event:show.html.twig', array( - 'event' => $entity + 'event' => $entity, + 'form_add_participation_by_person' => $addParticipationByPersonForm->createView() )); } + + /** + * create a form to add a participation with a person + * + * @return \Symfony\Component\Form\FormInterface + */ + protected function createAddParticipationByPersonForm(Event $event) + { + /* @var $builder \Symfony\Component\Form\FormBuilderInterface */ + $builder = $this + ->get('form.factory') + ->createNamedBuilder( + null, + FormType::class, + null, + array( + 'method' => 'GET', + 'action' => $this->generateUrl('chill_event_participation_new'), + 'csrf_protection' => false + )) + ; + + $builder->add('person_id', PickPersonType::class, array( + 'role' => new Role('CHILL_EVENT_CREATE'), + 'centers' => $event->getCenter() + )); + + $builder->add('center_id', HiddenType::class, array( + 'data' => $event->getCenter()->getId() + )); + + $builder->add('submit', SubmitType::class, + array( + 'label' => 'Add a participation' + )); + + return $builder->getForm(); + } /** * Displays a form to edit an existing Event entity. diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 0f58caa77..c8be2882e 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -13,3 +13,7 @@ chill_event_admin_role: chill_event_admin_event_type: resource: "@ChillEventBundle/Resources/config/routing/eventtype.yml" prefix: /{_locale}/admin/event/event_type + +chill_event_participation: + resource: "@ChillEventBundle/Resources/config/routing/participation.yml" + prefix: /{_locale}/event/participation diff --git a/Resources/config/routing/participation.yml b/Resources/config/routing/participation.yml new file mode 100644 index 000000000..d89dd3b9c --- /dev/null +++ b/Resources/config/routing/participation.yml @@ -0,0 +1,3 @@ +chill_event_participation_new: + path: /new + defaults: { _controller: ChillEventBundle:Participation:new } diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 90a759f7c..7c558341a 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -14,6 +14,7 @@ Last update: Dernière mise à jour Details of an event: Détails d'un événement Edit all the participations: Modifier toutes les participations +Add a participation: Ajouter un participant #search Event search: Recherche d'événements diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 1a500381a..d5e02aa96 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -36,7 +36,7 @@
-

{{ 'Participation'|trans }}

+

{{ 'Participations'|trans }}

{% set count = event.participations|length %}

{% transchoice count %}%count% participations to this event{% endtranschoice %}

@@ -74,6 +74,12 @@
  • {{ 'Edit all the participations'|trans }}
  • +
  • + {{ form_widget(form_add_participation_by_person.person_id, { 'attr' : { 'style' : 'width: 20em; display:inline-block; ' } } ) }} + {{ form_widget(form_add_participation_by_person.submit, { 'attr' : { 'class' : 'sc-button btn-create' } } ) }} + {{ form_rest(form_add_participation_by_person) }} +
    +
{% endif %} From 627b9fb08f99e80a6240220d299ed3ba881e1791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 24 Mar 2016 01:44:32 +0100 Subject: [PATCH 020/179] add the possibility to add a participation of a person to an event ref #5 --- Controller/EventController.php | 4 +- Controller/ParticipationController.php | 151 ++++++++++++++++++ DataFixtures/ORM/LoadRolesACL.php | 14 +- Entity/Participation.php | 52 +++++- Form/ParticipationType.php | 117 ++++++++++++++ Resources/config/routing/participation.yml | 4 + Resources/config/services/authorization.yml | 8 + Resources/config/services/forms.yml | 7 + Resources/config/validation.yml | 10 ++ Resources/translations/messages.fr.yml | 6 +- Resources/views/Event/show.html.twig | 2 + Resources/views/Participation/new.html.twig | 37 +++++ Security/Authorization/ParticipationVoter.php | 82 ++++++++++ 13 files changed, 489 insertions(+), 5 deletions(-) create mode 100644 Controller/ParticipationController.php create mode 100644 Form/ParticipationType.php create mode 100644 Resources/config/validation.yml create mode 100644 Resources/views/Participation/new.html.twig create mode 100644 Security/Authorization/ParticipationVoter.php diff --git a/Controller/EventController.php b/Controller/EventController.php index b77517160..ddc6e4ebc 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -143,8 +143,8 @@ class EventController extends Controller 'centers' => $event->getCenter() )); - $builder->add('center_id', HiddenType::class, array( - 'data' => $event->getCenter()->getId() + $builder->add('event_id', HiddenType::class, array( + 'data' => $event->getId() )); $builder->add('submit', SubmitType::class, diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php new file mode 100644 index 000000000..8b9685462 --- /dev/null +++ b/Controller/ParticipationController.php @@ -0,0 +1,151 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\EventBundle\Controller; + +use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\HttpFoundation\Request; +use Chill\EventBundle\Entity\Participation; +use Chill\EventBundle\Form\ParticipationType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Chill\EventBundle\Security\Authorization\ParticipationVoter; + +/** + * + * + * @author Julien Fastré + */ +class ParticipationController extends Controller +{ + public function newAction(Request $request) + { + $participation = $this->handleRequest($request, new Participation()); + + $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, + $participation, 'The user is not allowed to create this participation'); + + $form = $this->createCreateForm($participation); + + return $this->render('ChillEventBundle:Participation:new.html.twig', array( + 'form' => $form->createView(), + 'participation' => $participation + )); + } + + public function createAction(Request $request) + { + $participation = $this->handleRequest($request, new Participation()); + + $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, + $participation, 'The user is not allowed to create this participation'); + + $form = $this->createCreateForm($participation); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + + $em->persist($participation); + $em->flush(); + + $this->addFlash('success', $this->get('translator')->trans( + 'The participation was created' + )); + + return $this->redirectToRoute('event_show', array( + 'event_id' => $participation->getEvent()->getId() + )); + } + + return $this->render('ChillEventBundle:Participation:new.html.twig', array( + 'form' => $form->createView(), + 'participation' => $participation + )); + } + + /** + * + * @param Request $request + * @param Participation $participation + * @return Participation + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the event/person is not found + * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException if the user does not have access to event/person + */ + protected function handleRequest(Request $request, Participation $participation) + { + $em = $this->getDoctrine()->getManager(); + + $event_id = $request->query->getInt('event_id', null); + + if ($event_id !== NULL) { + $event = $em->getRepository('ChillEventBundle:Event') + ->find($event_id); + + if ($event === NULL) { + throw $this->createNotFoundException('The event with id '.$event_id.' is not found'); + } + + $this->denyAccessUnlessGranted('CHILL_EVENT_SEE', $event, + 'The user is not allowed to see the event'); + + $participation->setEvent($event); + } + + $person_id = $request->query->getInt('person_id', null); + + if ($person_id !== NULL) { + $person = $em->getRepository('ChillPersonBundle:Person') + ->find($person_id); + + if ($person === NULL) { + throw $this->createNotFoundException('The person with id '.$person_id.' is not found'); + } + + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person, + 'The user is not allowed to see the person'); + + $participation->setPerson($person); + } + + return $participation; + } + + /** + * + * @param Participation $participation + * @return \Symfony\Component\Form\FormInterface + */ + public function createCreateForm(Participation $participation) + { + $form = $this->createForm(ParticipationType::class, $participation, array( + 'event_type' => $participation->getEvent()->getType(), + 'action' => $this->generateUrl('chill_event_participation_create', array( + 'event_id' => $participation->getEvent()->getId(), + 'person_id' => $participation->getPerson()->getId() + )) + )); + + $form->add('submit', SubmitType::class, array( + 'label' => 'Create' + )); + + return $form; + } + +} diff --git a/DataFixtures/ORM/LoadRolesACL.php b/DataFixtures/ORM/LoadRolesACL.php index c0236d25c..08c0a8feb 100644 --- a/DataFixtures/ORM/LoadRolesACL.php +++ b/DataFixtures/ORM/LoadRolesACL.php @@ -56,19 +56,31 @@ class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface break; } - printf("Adding CHILL_EVENT_UPDATE & CHILL_EVENT_CREATE to %s " + printf("Adding CHILL_EVENT_UPDATE & CHILL_EVENT_CREATE " + . "CHILL_EVENT_PARTICIPATION_UPDATE & CHILL_EVENT_PARTICIPATION_CREATE " + . "to %s " . "permission group, scope '%s' \n", $permissionsGroup->getName(), $scope->getName()['en']); $roleScopeUpdate = (new RoleScope()) ->setRole('CHILL_EVENT_UPDATE') ->setScope($scope); + $roleScopeUpdate2 = (new RoleScope()) + ->setRole('CHILL_EVENT_PARTICIPATION_UPDATE') + ->setScope($scope); $permissionsGroup->addRoleScope($roleScopeUpdate); + $permissionsGroup->addRoleScope($roleScopeUpdate2); $roleScopeCreate = (new RoleScope()) ->setRole('CHILL_EVENT_CREATE') ->setScope($scope); + $roleScopeCreate2 = (new RoleScope()) + ->setRole('CHILL_EVENT_PARTICIPATION_CREATE') + ->setScope($scope); $permissionsGroup->addRoleScope($roleScopeCreate); + $permissionsGroup->addRoleScope($roleScopeCreate2); $manager->persist($roleScopeUpdate); + $manager->persist($roleScopeUpdate2); $manager->persist($roleScopeCreate); + $manager->persist($roleScopeCreate2); } } diff --git a/Entity/Participation.php b/Entity/Participation.php index cc8b8544e..ef33c6b99 100644 --- a/Entity/Participation.php +++ b/Entity/Participation.php @@ -2,10 +2,14 @@ namespace Chill\EventBundle\Entity; +use Chill\MainBundle\Entity\HasScopeInterface; +use Chill\MainBundle\Entity\HasCenterInterface; +use Symfony\Component\Validator\Context\ExecutionContextInterface; + /** * Participation */ -class Participation +class Participation implements HasCenterInterface, HasScopeInterface { /** * @var integer @@ -183,4 +187,50 @@ class Participation { return $this->status; } + + public function getCenter() + { + if ($this->getEvent() === NULL) { + throw new \RuntimeException('The event is not linked with this instance. ' + . 'You should initialize the event with a valid center before.'); + } + + return $this->getEvent()->getCenter(); + } + + public function getScope() + { + if ($this->getEvent() === NULL) { + throw new \RuntimeException('The event is not linked with this instance. ' + . 'You should initialize the event with a valid center before.'); + } + + return $this->getEvent()->getCircle(); + } + + /** + * Check that : + * + * - the role can be associated with this event type + * - the status can be associated with this event type + * + * @param ExecutionContextInterface $context + */ + public function isConsistent(ExecutionContextInterface $context) + { + if ($this->getRole()->getType()->getId() !== + $this->getEvent()->getType()->getId()) { + $context->buildViolation('The role is not allowed with this event type') + ->atPath('role') + ->addViolation(); + } + + if ($this->getStatus()->getType()->getId() !== + $this->getEvent()->getType()->getId()) { + $context->buildViolation('The status is not allowed with this event type') + ->atPath('status') + ->addViolation(); + } + } + } diff --git a/Form/ParticipationType.php b/Form/ParticipationType.php new file mode 100644 index 000000000..4891a4811 --- /dev/null +++ b/Form/ParticipationType.php @@ -0,0 +1,117 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\EventBundle\Form; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Chill\EventBundle\Entity\EventType; +use Chill\EventBundle\Entity\Status; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Doctrine\ORM\EntityRepository; +use Chill\EventBundle\Entity\Role; +use Chill\MainBundle\Templating\TranslatableStringHelper; + +/** + * A type to create a participation + * + * If the `event` option is defined, the role will be restricted + * + * @author Julien Fastré + */ +class ParticipationType extends AbstractType +{ + /** + * + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + public function __construct(TranslatableStringHelper $translatableStringHelper) + { + $this->translatableStringHelper = $translatableStringHelper; + } + + public function buildForm(FormBuilderInterface $builder, array $options) + { + // local copy of variable for Closure + $translatableStringHelper = $this->translatableStringHelper; + + // add role + $builder->add('role', EntityType::class, array( + 'class' => Role::class, + 'query_builder' => function (EntityRepository $er) use ($options) { + $qb = $er->createQueryBuilder('r'); + + if ($options['event_type'] instanceof EventType) { + $qb->where($qb->expr()->eq('r.type', ':event_type')) + ->setParameter('event_type', $options['event_type']); + } + + $qb->andWhere($qb->expr()->eq('r.active', ':active')) + ->setParameter('active', true); + + return $qb; + }, + 'choice_attr' => function(Role $r) { + return array( + 'data-event-type' => $r->getType()->getId() + ); + }, + 'choice_label' => function(Role $r) use ($translatableStringHelper) { + return $translatableStringHelper->localize($r->getLabel()); + } + )); + + // add a status + $builder->add('status', EntityType::class, array( + 'class' => Status::class, + 'choice_attr' => function(Status $s) { + return array( + 'data-event-type' => $s->getType()->getId() + ); + }, + 'query_builder' => function (EntityRepository $er) use ($options) { + $qb = $er->createQueryBuilder('s'); + + if ($options['event_type'] instanceof EventType) { + $qb->where($qb->expr()->eq('s.type', ':event_type')) + ->setParameter('event_type', $options['event_type']); + } + + $qb->andWhere($qb->expr()->eq('s.active', ':active')) + ->setParameter('active', true); + + return $qb; + }, + 'choice_label' => function(Status $s) use ($translatableStringHelper) { + return $translatableStringHelper->localize($s->getLabel()); + } + )); + + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefined('event_type') + ->setAllowedTypes('event_type', array('null', EventType::class)) + ->setDefault('event_type', 'null'); + } +} diff --git a/Resources/config/routing/participation.yml b/Resources/config/routing/participation.yml index d89dd3b9c..f79e584a6 100644 --- a/Resources/config/routing/participation.yml +++ b/Resources/config/routing/participation.yml @@ -1,3 +1,7 @@ chill_event_participation_new: path: /new defaults: { _controller: ChillEventBundle:Participation:new } + +chill_event_participation_create: + path: /create + defaults: { _controller: ChillEventBundle:Participation:create } diff --git a/Resources/config/services/authorization.yml b/Resources/config/services/authorization.yml index 9adb5b087..d44f1e9d9 100644 --- a/Resources/config/services/authorization.yml +++ b/Resources/config/services/authorization.yml @@ -6,3 +6,11 @@ services: tags: - { name: chill.role } - { name: security.voter } + + chill_event.event_participation: + class: Chill\EventBundle\Security\Authorization\ParticipationVoter + arguments: + - "@chill.main.security.authorization.helper" + tags: + - { name: chill.role } + - { name: security.voter } diff --git a/Resources/config/services/forms.yml b/Resources/config/services/forms.yml index 2f1cb1d00..2f622a326 100644 --- a/Resources/config/services/forms.yml +++ b/Resources/config/services/forms.yml @@ -14,3 +14,10 @@ services: - "@chill.main.helper.translatable_string" tags: - { name: form.type } + + chill.event.form.participation_type: + class: Chill\EventBundle\Form\ParticipationType + arguments: + - "@chill.main.helper.translatable_string" + tags: + - { name: form.type } diff --git a/Resources/config/validation.yml b/Resources/config/validation.yml new file mode 100644 index 000000000..90ebf28e0 --- /dev/null +++ b/Resources/config/validation.yml @@ -0,0 +1,10 @@ +Chill\EventBundle\Event\Participation: + properties: + event: + - NotNull: ~ + status: + - NotNull: ~ + person: + - NotNull: ~ + constraints: + - Callback: [isConsistent] diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 7c558341a..e5d2a5e98 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -12,9 +12,13 @@ Last update: Dernière mise à jour #CRUD Details of an event: Détails d'un événement - Edit all the participations: Modifier toutes les participations Add a participation: Ajouter un participant +Participation creation: Ajouter une participation +Associated person: Personne associée +Associated event: Événement associé +Back to the event: Retour à l'événement +The participation was created: La participation a été créée #search Event search: Recherche d'événements diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index d5e02aa96..720075281 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -75,9 +75,11 @@
  • {{ 'Edit all the participations'|trans }}
  • + {{ form_start(form_add_participation_by_person) }} {{ form_widget(form_add_participation_by_person.person_id, { 'attr' : { 'style' : 'width: 20em; display:inline-block; ' } } ) }} {{ form_widget(form_add_participation_by_person.submit, { 'attr' : { 'class' : 'sc-button btn-create' } } ) }} {{ form_rest(form_add_participation_by_person) }} + {{ form_end(form_add_participation_by_person) }}
diff --git a/Resources/views/Participation/new.html.twig b/Resources/views/Participation/new.html.twig new file mode 100644 index 000000000..bd99347fe --- /dev/null +++ b/Resources/views/Participation/new.html.twig @@ -0,0 +1,37 @@ +{% extends 'ChillEventBundle::layout.html.twig' %} + +{% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} + +{% block event_content -%} +

{{ 'Participation creation'|trans }}

+ + + + + + + + + + + + +
{{ 'Associated person'|trans }}{{ person_macro.render(participation.person) }}
{{ 'Associated event'|trans }} {{ participation.event.label }}
+ + {{ form_start(form) }} + {{ form_row(form.role) }} + {{ form_row(form.status) }} + + + + {{ form_end(form) }} +{% endblock %} diff --git a/Security/Authorization/ParticipationVoter.php b/Security/Authorization/ParticipationVoter.php new file mode 100644 index 000000000..e8ba27548 --- /dev/null +++ b/Security/Authorization/ParticipationVoter.php @@ -0,0 +1,82 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\EventBundle\Security\Authorization; + +use Chill\MainBundle\Security\ProvideRoleInterface; +use Chill\MainBundle\Security\Authorization\AbstractChillVoter; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Chill\EventBundle\Entity\Participation; +use Chill\MainBundle\Entity\User; + +/** + * + * + * @author Julien Fastré + */ +class ParticipationVoter extends AbstractChillVoter implements ProvideRoleInterface +{ + /** + * + * @var AuthorizationHelper + */ + protected $authorizationHelper; + + const CREATE = 'CHILL_EVENT_PARTICIPATION_CREATE'; + const UPDATE = 'CHILL_EVENT_PARTICIPATION_UPDATE'; + + public function __construct(AuthorizationHelper $helper) + { + $this->authorizationHelper = $helper; + } + + protected function getSupportedAttributes() + { + return array( + self::CREATE, self::UPDATE + ); + } + + protected function getSupportedClasses() + { + return array( + Participation::class + ); + } + + protected function isGranted($attribute, $participation, $user = null) + { + if (!$user instanceof User) { + return false; + } + + return $this->authorizationHelper->userHasAccess($user, $participation, $attribute); + } + + public function getRoles() + { + return $this->getSupportedAttributes(); + } + + public function getRolesWithoutScope() + { + return null; + } + +} From 9eed387285431446a902475978bf7b0d24a43c67 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Thu, 24 Mar 2016 10:45:03 +0100 Subject: [PATCH 021/179] Adding the js function categoryLinkParentChildSelect for center and scope --- Form/EventType.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Form/EventType.php b/Form/EventType.php index 5ad2f6414..623004306 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -80,8 +80,10 @@ class EventType extends AbstractType ->add('center', EntityType::class, array( 'class' => Center::class, 'choices' => $userReachableCenters, + 'attr' => array('class' => 'select2 chill-category-link-parent'), 'choice_attr' => function (Center $center) { return array( + 'class' => ' chill-category-link-parent', 'data-link-category' => $center->getId() ); }, From b1b258d76b0bb95c340abe4d4576cbed50d0b43a Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Thu, 24 Mar 2016 10:52:21 +0100 Subject: [PATCH 022/179] Removing print --- Form/EventType.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Form/EventType.php b/Form/EventType.php index 623004306..29b32a086 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -98,7 +98,6 @@ class EventType extends AbstractType 'choice_attr' => function ($circle) use ($userReachableCentersByCircleId) { $centersId = ""; foreach ($userReachableCentersByCircleId[$circle->getId()] as $center) { - print $center; $centersId = $centersId.($center->getId()).','; } $centersId = trim($centersId, ','); From ccb4d6cfb54d778078ca04d88cbacb11e7adaa3e Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Thu, 24 Mar 2016 11:29:17 +0100 Subject: [PATCH 023/179] Correction of routing : id -> event_id --- Controller/EventController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index ddc6e4ebc..bb73708a2 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -49,7 +49,7 @@ class EventController extends Controller $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('event_show', array('id' => $entity->getId()))); + return $this->redirect($this->generateUrl('event_show', array('event_id' => $entity->getId()))); } return $this->render('ChillEventBundle:Event:new.html.twig', array( From 993882e92504b09e7caf2cad2e1e5e56c3588366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 24 Mar 2016 14:18:03 +0100 Subject: [PATCH 024/179] feature: update an existing participation The update allow to modify the status and role of a participation. ref #8 --- Controller/ParticipationController.php | 90 ++++++++++++++++++++ Resources/config/routing/participation.yml | 9 ++ Resources/translations/messages.fr.yml | 1 + Resources/views/Event/show.html.twig | 7 +- Resources/views/Participation/edit.html.twig | 41 +++++++++ Resources/views/Participation/new.html.twig | 2 + 6 files changed, 148 insertions(+), 2 deletions(-) create mode 100644 Resources/views/Participation/edit.html.twig diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index 8b9685462..8cf065706 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -148,4 +148,94 @@ class ParticipationController extends Controller return $form; } + /** + * show an edit form for the participation with the given id. + * + * @param int $participation_id + * @return \Symfony\Component\HttpFoundation\Response + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the participation is not found + * @throws \Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException if the user is not allowed to edit the participation + */ + public function editAction($participation_id) + { + /* @var $participation Participation */ + $participation = $this->getDoctrine()->getManager() + ->getRepository('ChillEventBundle:Participation') + ->find($participation_id); + + if ($participation === NULL) { + throw $this->createNotFoundException('The participation is not found'); + } + + $this->denyAccessUnlessGranted(ParticipationVoter::UPDATE, $participation, + 'You are not allowed to edit this participation'); + + $form = $this->createEditForm($participation); + + return $this->render('ChillEventBundle:Participation:edit.html.twig', array( + 'form' => $form->createView(), + 'participation' => $participation + )); + } + + public function updateAction($participation_id, Request $request) + { + /* @var $participation Participation */ + $participation = $this->getDoctrine()->getManager() + ->getRepository('ChillEventBundle:Participation') + ->find($participation_id); + + if ($participation === NULL) { + throw $this->createNotFoundException('The participation is not found'); + } + + $this->denyAccessUnlessGranted(ParticipationVoter::UPDATE, $participation, + 'You are not allowed to edit this participation'); + + $form = $this->createEditForm($participation); + + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + + $em->flush(); + + $this->addFlash('success', $this->get('translator')->trans( + 'The participation was updated' + )); + + return $this->redirectToRoute('event_show', array( + 'event_id' => $participation->getEvent()->getId() + )); + + } + + return $this->render('ChillEventBundle:Participation:edit.html.twig', array( + 'form' => $form->createView(), + 'participation' => $participation + )); + } + + /** + * + * @param Participation $participation + * @return \Symfony\Component\Form\FormInterface + */ + public function createEditForm(Participation $participation) + { + $form = $this->createForm(ParticipationType::class, $participation, array( + 'event_type' => $participation->getEvent()->getType(), + 'action' => $this->generateUrl('chill_event_participation_update', array( + 'participation_id' => $participation->getId() + )) + )); + + $form->add('submit', SubmitType::class, array( + 'label' => 'Edit' + )); + + return $form; + } + } diff --git a/Resources/config/routing/participation.yml b/Resources/config/routing/participation.yml index f79e584a6..54d18fb71 100644 --- a/Resources/config/routing/participation.yml +++ b/Resources/config/routing/participation.yml @@ -5,3 +5,12 @@ chill_event_participation_new: chill_event_participation_create: path: /create defaults: { _controller: ChillEventBundle:Participation:create } + +chill_event_participation_edit: + path: /{participation_id}/edit + defaults: { _controller: ChillEventBundle:Participation:edit } + +chill_event_participation_update: + path: /{participation_id}/update + defaults: { _controller: ChillEventBundle:Participation:update } + methods: [POST] diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index e5d2a5e98..91e7e1ea8 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -19,6 +19,7 @@ Associated person: Personne associée Associated event: Événement associé Back to the event: Retour à l'événement The participation was created: La participation a été créée +The participation was updated: La participation a été mise à jour #search Event search: Recherche d'événements diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 720075281..e28fec753 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -57,14 +57,17 @@ {{ person_macro.render(participation.person) }} {{ participation.role.label|localize_translatable_string }} {{ participation.status.label|localize_translatable_string }} - {{ participation.lastUpdate|localizeddate("long", "none") }} + {{ participation.lastUpdate|time_diff }} diff --git a/Resources/views/Participation/edit.html.twig b/Resources/views/Participation/edit.html.twig new file mode 100644 index 000000000..438fba6b3 --- /dev/null +++ b/Resources/views/Participation/edit.html.twig @@ -0,0 +1,41 @@ +{% extends 'ChillEventBundle::layout.html.twig' %} + +{% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} + +{% block event_content -%} +

{{ 'Participation Edit'|trans }}

+ + + + + + + + + + + + + + + + +
{{ 'Associated person'|trans }}{{ person_macro.render(participation.person) }}
{{ 'Associated event'|trans }} {{ participation.event.label }}
{{ 'Date'|trans }} {{ participation.event.date|localizeddate('long', 'none') }}
+ + {{ form_start(form) }} + {{ form_row(form.role) }} + {{ form_row(form.status) }} + + + + {{ form_end(form) }} +{% endblock %} diff --git a/Resources/views/Participation/new.html.twig b/Resources/views/Participation/new.html.twig index bd99347fe..cbf6c72bd 100644 --- a/Resources/views/Participation/new.html.twig +++ b/Resources/views/Participation/new.html.twig @@ -2,6 +2,8 @@ {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} +{% block title 'Participation creation'|trans %} + {% block event_content -%}

{{ 'Participation creation'|trans }}

From 3ac192d34cde31672eb6d89fbebc3913e50ba4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 24 Mar 2016 14:30:08 +0100 Subject: [PATCH 025/179] remove empty default controller --- Controller/DefaultController.php | 13 ------------- Resources/views/Default/index.html.twig | 1 - Tests/Controller/DefaultControllerTest.php | 17 ----------------- 3 files changed, 31 deletions(-) delete mode 100644 Controller/DefaultController.php delete mode 100644 Resources/views/Default/index.html.twig delete mode 100644 Tests/Controller/DefaultControllerTest.php diff --git a/Controller/DefaultController.php b/Controller/DefaultController.php deleted file mode 100644 index 6d455c21a..000000000 --- a/Controller/DefaultController.php +++ /dev/null @@ -1,13 +0,0 @@ -render('ChillEventBundle:Default:index.html.twig', array('name' => $name)); - } -} diff --git a/Resources/views/Default/index.html.twig b/Resources/views/Default/index.html.twig deleted file mode 100644 index 4ce626e9b..000000000 --- a/Resources/views/Default/index.html.twig +++ /dev/null @@ -1 +0,0 @@ -Hello {{ name }}! diff --git a/Tests/Controller/DefaultControllerTest.php b/Tests/Controller/DefaultControllerTest.php deleted file mode 100644 index 5c2a813f4..000000000 --- a/Tests/Controller/DefaultControllerTest.php +++ /dev/null @@ -1,17 +0,0 @@ -request('GET', '/hello/Fabien'); - - $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0); - } -} From 69465c387d5d37365d2f93d8fc68cd724c10ab02 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Thu, 24 Mar 2016 14:33:18 +0100 Subject: [PATCH 026/179] Adding validation for the event --- Resources/config/validation.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Resources/config/validation.yml b/Resources/config/validation.yml index 90ebf28e0..4163cd0bf 100644 --- a/Resources/config/validation.yml +++ b/Resources/config/validation.yml @@ -1,3 +1,17 @@ +Chill\EventBundle\Entity\Event: + properties: + label: + - Length: + min: 3 + max: 75 + minMessage: The event name must have at least {{ limit }} characters. + maxMessage: The event name must have maximum {{ limit }} characters. + type: + - NotNull: ~ + circle: + - NotNull: ~ + center: + - NotNull: ~ Chill\EventBundle\Event\Participation: properties: event: From a91ce5fe4f7f7a0e11d13ea80a90f457f437c548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 24 Mar 2016 15:02:08 +0100 Subject: [PATCH 027/179] fix bug in validation close #21 --- Resources/config/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/validation.yml b/Resources/config/validation.yml index 90ebf28e0..e214de89a 100644 --- a/Resources/config/validation.yml +++ b/Resources/config/validation.yml @@ -1,4 +1,4 @@ -Chill\EventBundle\Event\Participation: +Chill\EventBundle\Entity\Participation: properties: event: - NotNull: ~ From 372cae7008428561b94c1bc7ef99d99944fd1ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 24 Mar 2016 15:18:50 +0100 Subject: [PATCH 028/179] show always the form "add a participant" even if no participation yet --- Resources/views/Event/show.html.twig | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index e28fec753..8c47ab42c 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -75,18 +75,22 @@ -
    -
  • {{ 'Edit all the participations'|trans }}
  • -
  • - {{ form_start(form_add_participation_by_person) }} - {{ form_widget(form_add_participation_by_person.person_id, { 'attr' : { 'style' : 'width: 20em; display:inline-block; ' } } ) }} - {{ form_widget(form_add_participation_by_person.submit, { 'attr' : { 'class' : 'sc-button btn-create' } } ) }} - {{ form_rest(form_add_participation_by_person) }} - {{ form_end(form_add_participation_by_person) }} -
    -
  • -
+ {% endif %} + +
    + {% if count > 0 %} +
  • {{ 'Edit all the participations'|trans }}
  • + {% endif %} +
  • + {{ form_start(form_add_participation_by_person) }} + {{ form_widget(form_add_participation_by_person.person_id, { 'attr' : { 'style' : 'width: 20em; display:inline-block; ' } } ) }} + {{ form_widget(form_add_participation_by_person.submit, { 'attr' : { 'class' : 'sc-button btn-create' } } ) }} + {{ form_rest(form_add_participation_by_person) }} + {{ form_end(form_add_participation_by_person) }} +
    +
  • +
{% endblock %} From cd13140e6c372aa387fbc99b7b54a15215c48d2e Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Thu, 24 Mar 2016 15:18:59 +0100 Subject: [PATCH 029/179] Adding add an event into the section menu --- Resources/config/routing/event.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index 84d775aab..c6e7ebe79 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -9,6 +9,13 @@ event_show: event_new: path: /new defaults: { _controller: "ChillEventBundle:Event:new" } + options: + menus: + section: + order: 11 + label: Add an event + icons: [plus, calendar-o] + event_create: path: /create From 8db8c8925cc10e27e76f0399d844494c9ebd27d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 24 Mar 2016 15:19:23 +0100 Subject: [PATCH 030/179] add a link into section menu Currently, the main link in section menu redirect to a search which display the last events ref #10 --- Controller/EventController.php | 8 ++++++++ Entity/Participation.php | 1 + Resources/config/routing/event.yml | 10 ++++++++++ Resources/translations/messages.fr.yml | 7 ++++++- Resources/views/Event/list.html.twig | 10 +++++++++- 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index bb73708a2..ec3f5a3d5 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -34,6 +34,14 @@ class EventController extends Controller 'entities' => $entities, )); } + + public function mostRecentIndexAction() + { + return $this->redirectToRoute('chill_main_search', array( + 'q' => '@event' + )); + } + /** * Creates a new Event entity. * diff --git a/Entity/Participation.php b/Entity/Participation.php index ef33c6b99..3aa52313c 100644 --- a/Entity/Participation.php +++ b/Entity/Participation.php @@ -231,6 +231,7 @@ class Participation implements HasCenterInterface, HasScopeInterface ->atPath('status') ->addViolation(); } + var_dump('ok'); } } diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index 84d775aab..87781f06f 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -1,6 +1,16 @@ event: path: / defaults: { _controller: "ChillEventBundle:Event:index" } + +chill_event_list_most_recent: + path: most_recent + defaults: { _controller: "ChillEventBundle:Event:mostRecentIndex" } + options: + menus: + section: + order: 90 + label: Events + icons: [calendar] event_show: path: /{event_id}/show diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 91e7e1ea8..a456de1ee 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -4,14 +4,18 @@ Date: Date Event type : Type d'événement See: Voir Event: Événement +Events: Événements 'Event : %label%': Événement "%label%" Participation: Participation Status: Statut Last update: Dernière mise à jour '%count% participations to this event': '{0} Aucun participant à l''événement | {1} Un participant à l''événement | ]1,Inf] %count% participants à l''événement' -#CRUD +#CRUD event Details of an event: Détails d'un événement +New event: Nouvel événement + +#crud participation Edit all the participations: Modifier toutes les participations Add a participation: Ajouter un participant Participation creation: Ajouter une participation @@ -20,6 +24,7 @@ Associated event: Événement associé Back to the event: Retour à l'événement The participation was created: La participation a été créée The participation was updated: La participation a été mise à jour +Participation Edit: Modifier une participation #search Event search: Recherche d'événements diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig index f7338fd98..38196122a 100644 --- a/Resources/views/Event/list.html.twig +++ b/Resources/views/Event/list.html.twig @@ -40,4 +40,12 @@ -{% endif %} \ No newline at end of file +{% endif %} + + \ No newline at end of file From fdb2c094a65275a7a46ea9bdd0278b90cf6d33ea Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Thu, 24 Mar 2016 17:39:01 +0100 Subject: [PATCH 031/179] Removing IndexAction from Event controller --- Controller/EventController.php | 15 --------------- Resources/config/routing/event.yml | 4 ---- 2 files changed, 19 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index ec3f5a3d5..126a6b86a 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -19,21 +19,6 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType; */ class EventController extends Controller { - - /** - * Lists all Event entities. - * - */ - public function indexAction() - { - $em = $this->getDoctrine()->getManager(); - - $entities = $em->getRepository('ChillEventBundle:Event')->findAll(); - - return $this->render('ChillEventBundle:Event:index.html.twig', array( - 'entities' => $entities, - )); - } public function mostRecentIndexAction() { diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index c868cd9b7..ecbcf144f 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -1,7 +1,3 @@ -event: - path: / - defaults: { _controller: "ChillEventBundle:Event:index" } - chill_event_list_most_recent: path: most_recent defaults: { _controller: "ChillEventBundle:Event:mostRecentIndex" } From cf7f8a929b01cf2f14bc485e2a3904d7b9c30f94 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Thu, 24 Mar 2016 18:03:45 +0100 Subject: [PATCH 032/179] Allow the modification of event + adding the prefix chill_even to all the route --- Controller/EventController.php | 35 ++++++++++---------- Controller/ParticipationController.php | 4 +-- Resources/config/routing/event.yml | 19 +++++------ Resources/views/Event/edit.html.twig | 6 ++-- Resources/views/Event/index.html.twig | 8 ++--- Resources/views/Event/list.html.twig | 8 ++--- Resources/views/Event/new.html.twig | 2 +- Resources/views/Event/show.html.twig | 2 +- Resources/views/Participation/edit.html.twig | 2 +- Resources/views/Participation/new.html.twig | 2 +- 10 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index 126a6b86a..56c2b2d7f 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -42,7 +42,7 @@ class EventController extends Controller $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('event_show', array('event_id' => $entity->getId()))); + return $this->redirect($this->generateUrl('chill_event__event_show', array('event_id' => $entity->getId()))); } return $this->render('ChillEventBundle:Event:new.html.twig', array( @@ -61,7 +61,7 @@ class EventController extends Controller private function createCreateForm(Event $entity) { $form = $this->createForm(EventType::class, $entity, array( - 'action' => $this->generateUrl('event_create'), + 'action' => $this->generateUrl('chill_event__event_create'), 'method' => 'POST' )); @@ -152,18 +152,18 @@ class EventController extends Controller * Displays a form to edit an existing Event entity. * */ - public function editAction($id) + public function editAction($event_id) { $em = $this->getDoctrine()->getManager(); - $entity = $em->getRepository('ChillEventBundle:Event')->find($id); + $entity = $em->getRepository('ChillEventBundle:Event')->find($event_id); if (!$entity) { throw $this->createNotFoundException('Unable to find Event entity.'); } $editForm = $this->createEditForm($entity); - $deleteForm = $this->createDeleteForm($id); + $deleteForm = $this->createDeleteForm($event_id); return $this->render('ChillEventBundle:Event:edit.html.twig', array( 'entity' => $entity, @@ -181,11 +181,12 @@ class EventController extends Controller */ private function createEditForm(Event $entity) { - $form = $this->createForm(new EventType(), $entity, array( - 'action' => $this->generateUrl('event_update', array('id' => $entity->getId())), + $form = $this->createForm(EventType::class, $entity, array( + 'action' => $this->generateUrl('chill_event__event_update', array('event_id' => $entity->getId())), 'method' => 'PUT', )); + $form->add('submit', 'submit', array('label' => 'Update')); return $form; @@ -194,24 +195,24 @@ class EventController extends Controller * Edits an existing Event entity. * */ - public function updateAction(Request $request, $id) + public function updateAction(Request $request, $event_id) { $em = $this->getDoctrine()->getManager(); - $entity = $em->getRepository('ChillEventBundle:Event')->find($id); + $entity = $em->getRepository('ChillEventBundle:Event')->find($event_id); if (!$entity) { throw $this->createNotFoundException('Unable to find Event entity.'); } - $deleteForm = $this->createDeleteForm($id); + $deleteForm = $this->createDeleteForm($event_id); $editForm = $this->createEditForm($entity); $editForm->handleRequest($request); if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('event_edit', array('id' => $id))); + return $this->redirect($this->generateUrl('chill_event__event_edit', array('event_id' => $event_id))); } return $this->render('ChillEventBundle:Event:edit.html.twig', array( @@ -224,14 +225,14 @@ class EventController extends Controller * Deletes a Event entity. * */ - public function deleteAction(Request $request, $id) + public function deleteAction(Request $request, $event_id) { - $form = $this->createDeleteForm($id); + $form = $this->createDeleteForm($event_id); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); - $entity = $em->getRepository('ChillEventBundle:Event')->find($id); + $entity = $em->getRepository('ChillEventBundle:Event')->find($event_id); if (!$entity) { throw $this->createNotFoundException('Unable to find Event entity.'); @@ -247,14 +248,14 @@ class EventController extends Controller /** * Creates a form to delete a Event entity by id. * - * @param mixed $id The entity id + * @param mixed $event_id The event id * * @return \Symfony\Component\Form\Form The form */ - private function createDeleteForm($id) + private function createDeleteForm($event_id) { return $this->createFormBuilder() - ->setAction($this->generateUrl('event_delete', array('id' => $id))) + ->setAction($this->generateUrl('chill_event__event_delete', array('event_id' => $event_id))) ->setMethod('DELETE') ->add('submit', 'submit', array('label' => 'Delete')) ->getForm() diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index 8cf065706..9024ea253 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -68,7 +68,7 @@ class ParticipationController extends Controller 'The participation was created' )); - return $this->redirectToRoute('event_show', array( + return $this->redirectToRoute('chill_event__event_show', array( 'event_id' => $participation->getEvent()->getId() )); } @@ -205,7 +205,7 @@ class ParticipationController extends Controller 'The participation was updated' )); - return $this->redirectToRoute('event_show', array( + return $this->redirectToRoute('chill_event__event_show', array( 'event_id' => $participation->getEvent()->getId() )); diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index ecbcf144f..25b39a5c6 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -8,11 +8,11 @@ chill_event_list_most_recent: label: Events icons: [calendar] -event_show: +chill_event__event_show: path: /{event_id}/show defaults: { _controller: "ChillEventBundle:Event:show" } -event_new: +chill_event__event_new: path: /new defaults: { _controller: "ChillEventBundle:Event:new" } options: @@ -22,22 +22,21 @@ event_new: label: Add an event icons: [plus, calendar-o] - -event_create: +chill_event__event_create: path: /create defaults: { _controller: "ChillEventBundle:Event:create" } methods: POST -event_edit: - path: /{id}/edit +chill_event__event_edit: + path: /{event_id}/edit defaults: { _controller: "ChillEventBundle:Event:edit" } -event_update: - path: /{id}/update +chill_event__event_update: + path: /{event_id}/update defaults: { _controller: "ChillEventBundle:Event:update" } methods: [POST, PUT] -event_delete: - path: /{id}/delete +chill_event__event_delete: + path: /{event_id}/delete defaults: { _controller: "ChillEventBundle:Event:delete" } methods: [POST, DELETE] diff --git a/Resources/views/Event/edit.html.twig b/Resources/views/Event/edit.html.twig index 733f7332c..1d365f28a 100644 --- a/Resources/views/Event/edit.html.twig +++ b/Resources/views/Event/edit.html.twig @@ -1,13 +1,13 @@ -{% extends '::base.html.twig' %} +{% extends 'ChillEventBundle::layout.html.twig' %} -{% block body -%} +{% block event_content -%}

Event edit

{{ form(edit_form) }}
  • - + Back to the list
  • diff --git a/Resources/views/Event/index.html.twig b/Resources/views/Event/index.html.twig index 9ba265dda..b5ac1e62a 100644 --- a/Resources/views/Event/index.html.twig +++ b/Resources/views/Event/index.html.twig @@ -15,16 +15,16 @@ {% for entity in entities %} - {{ entity.id }} + {{ entity.id }} {{ entity.label }} {% if entity.date %}{{ entity.date|date('Y-m-d H:i:s') }}{% endif %} @@ -35,7 +35,7 @@
    • - + Create a new entry
    • diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig index 38196122a..c8e8ecbdd 100644 --- a/Resources/views/Event/list.html.twig +++ b/Resources/views/Event/list.html.twig @@ -23,12 +23,12 @@ diff --git a/Resources/views/Event/new.html.twig b/Resources/views/Event/new.html.twig index 46b00a2b2..fcd90a28b 100644 --- a/Resources/views/Event/new.html.twig +++ b/Resources/views/Event/new.html.twig @@ -7,7 +7,7 @@
      • - + Back to the list
      • diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 8c47ab42c..12cf2672d 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -30,7 +30,7 @@
        • - + {{ 'Edit'|trans }}
        • diff --git a/Resources/views/Participation/edit.html.twig b/Resources/views/Participation/edit.html.twig index 438fba6b3..67f37802a 100644 --- a/Resources/views/Participation/edit.html.twig +++ b/Resources/views/Participation/edit.html.twig @@ -28,7 +28,7 @@
          • - + {{ 'Back to the event'|trans }}
          • diff --git a/Resources/views/Participation/new.html.twig b/Resources/views/Participation/new.html.twig index cbf6c72bd..36b77a8b6 100644 --- a/Resources/views/Participation/new.html.twig +++ b/Resources/views/Participation/new.html.twig @@ -26,7 +26,7 @@
            • - + {{ 'Back to the event'|trans }}
            • From c9ce3aca96e1246219510584ec25971e5c54eccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 24 Mar 2016 23:00:45 +0100 Subject: [PATCH 033/179] some improvement to the Update / create event pages - i18n of all the form - add a title to each page - chill layout of each page - add flash message on successfully creation and update action For the update page, (see #23), the user is not allowed to update the center close #23 close #2 --- Controller/EventController.php | 7 ++++++ Resources/translations/messages.fr.yml | 7 ++++++ Resources/views/Event/edit.html.twig | 34 ++++++++++++++++++-------- Resources/views/Event/new.html.twig | 31 ++++++++++++++++------- Resources/views/Event/show.html.twig | 2 +- 5 files changed, 61 insertions(+), 20 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index 56c2b2d7f..702433e08 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -41,6 +41,9 @@ class EventController extends Controller $em = $this->getDoctrine()->getManager(); $em->persist($entity); $em->flush(); + + $this->addFlash('success', $this->get('translator') + ->trans('The event was created')); return $this->redirect($this->generateUrl('chill_event__event_show', array('event_id' => $entity->getId()))); } @@ -186,6 +189,7 @@ class EventController extends Controller 'method' => 'PUT', )); + $form->remove('center'); $form->add('submit', 'submit', array('label' => 'Update')); @@ -211,6 +215,9 @@ class EventController extends Controller if ($editForm->isValid()) { $em->flush(); + + $this->addFlash('success', $this->get('translator') + ->trans('The event was updated')); return $this->redirect($this->generateUrl('chill_event__event_edit', array('event_id' => $event_id))); } diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index a456de1ee..67e992d7e 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -1,5 +1,6 @@ #events Name: Nom +Label: Nom Date: Date Event type : Type d'événement See: Voir @@ -14,6 +15,12 @@ Last update: Dernière mise à jour #CRUD event Details of an event: Détails d'un événement New event: Nouvel événement +Back to the most recent events: Retour aux derniers événements +Event creation: Création d'un événement +Add an event: Ajouter un événement +Event edit: Modifier un événement +The event was updated: L'événement a été modifié +The event was created: L'événement a été créé #crud participation Edit all the participations: Modifier toutes les participations diff --git a/Resources/views/Event/edit.html.twig b/Resources/views/Event/edit.html.twig index 1d365f28a..ca326aa80 100644 --- a/Resources/views/Event/edit.html.twig +++ b/Resources/views/Event/edit.html.twig @@ -1,16 +1,30 @@ {% extends 'ChillEventBundle::layout.html.twig' %} +{% block title 'Event edit'|trans %} + {% block event_content -%} -

              Event edit

              +

              {{ 'Event edit'|trans }}

              - {{ form(edit_form) }} + {{ form_start(edit_form) }} + {{ form_errors(edit_form) }} + {{ form_row(edit_form.circle) }} + {% if edit_form.center is defined %} + {{ form_row(edit_form.center) }} + {% endif %} + {{ form_row(edit_form.label) }} + {{ form_row(edit_form.date) }} + {{ form_row(edit_form.type, { 'label': 'Event type' }) }} - + + + {{ form_end(edit_form) }} {% endblock %} diff --git a/Resources/views/Event/new.html.twig b/Resources/views/Event/new.html.twig index fcd90a28b..2986a83ac 100644 --- a/Resources/views/Event/new.html.twig +++ b/Resources/views/Event/new.html.twig @@ -1,15 +1,28 @@ {% extends 'ChillEventBundle::layout.html.twig' %} +{% block title 'Event creation'|trans %} + {% block event_content -%} -

              Event creation

              +

              {{ 'Event creation'|trans }}

              - {{ form(form) }} + {{ form_start(form) }} + {{ form_errors(form) }} + {{ form_row(form.circle) }} + {{ form_row(form.center) }} + {{ form_row(form.label) }} + {{ form_row(form.date) }} + {{ form_row(form.type, { 'label': 'Event type' }) }} - + + + {{ form_end(form) }} {% endblock %} diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 12cf2672d..541e08ea1 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -30,7 +30,7 @@
              • - + {{ 'Edit'|trans }}
              • From 20c49d5bd06d3b24b99c0972f9d8e4c35c1a2075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 24 Mar 2016 23:06:35 +0100 Subject: [PATCH 034/179] remove event menu ref #24 --- Resources/views/layout.html.twig | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index a788962e3..3b1a4d092 100644 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -18,12 +18,6 @@ {% extends "ChillMainBundle::layoutWithVerticalMenu.html.twig" %} -{% block vertical_menu_content %} - {{ chill_menu('event', { - 'layout': 'ChillMainBundle::Menu/verticalMenu.html.twig', - }) }} -{% endblock %} - {% block layout_wvm_content %} {% block event_content %}

                {{ 'Event' |trans }}

                From d8de53ca3c700fd70eb50002a3dd666204d74d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 24 Mar 2016 23:27:39 +0100 Subject: [PATCH 035/179] rename 'label' to 'name'. Warning : this commit require to rename some table column, but the original Version file has been update. If you do not care to loose your date, you may run : ``` php app/console doctrine:migrations:execute --down 20160318111334 php app/console doctrine:migrations:execute --up 20160318111334 php app/console doctrine:cache:metadata #(if you have a cache for doctrine meta date) ``` close #20 --- DataFixtures/ORM/LoadEventTypes.php | 18 +++++++++--------- DataFixtures/ORM/LoadParticipation.php | 2 +- Entity/Event.php | 10 +++++----- Entity/EventType.php | 10 +++++----- Entity/Role.php | 10 +++++----- Entity/Status.php | 12 ++++++------ Form/EventType.php | 2 +- Form/EventTypeType.php | 2 +- Form/ParticipationType.php | 4 ++-- Form/RoleType.php | 2 +- Form/StatusType.php | 2 +- Form/Type/TranslatableEventType.php | 2 +- Resources/config/doctrine/Event.orm.yml | 2 +- Resources/config/doctrine/EventType.orm.yml | 2 +- Resources/config/doctrine/Role.orm.yml | 2 +- Resources/config/doctrine/Status.orm.yml | 2 +- Resources/migrations/Version20160318111334.php | 8 ++++---- Resources/views/Event/edit.html.twig | 2 +- Resources/views/Event/index.html.twig | 4 ++-- Resources/views/Event/list.html.twig | 4 ++-- Resources/views/Event/new.html.twig | 2 +- Resources/views/Event/show.html.twig | 12 ++++++------ Resources/views/EventType/index.html.twig | 2 +- Resources/views/EventType/show.html.twig | 4 ++-- Resources/views/Participation/edit.html.twig | 2 +- Resources/views/Participation/new.html.twig | 2 +- Resources/views/Role/index.html.twig | 4 ++-- Resources/views/Role/show.html.twig | 4 ++-- Resources/views/Status/index.html.twig | 4 ++-- Resources/views/Status/show.html.twig | 4 ++-- 30 files changed, 71 insertions(+), 71 deletions(-) diff --git a/DataFixtures/ORM/LoadEventTypes.php b/DataFixtures/ORM/LoadEventTypes.php index 38e171d97..40e9b76b0 100644 --- a/DataFixtures/ORM/LoadEventTypes.php +++ b/DataFixtures/ORM/LoadEventTypes.php @@ -29,7 +29,7 @@ class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface { $type = (new EventType()) ->setActive(true) - ->setLabel(array('fr' => 'Échange de savoirs', 'en' => 'Exchange of knowledge')) + ->setName(array('fr' => 'Échange de savoirs', 'en' => 'Exchange of knowledge')) ; $manager->persist($type); $this->addReference('event_type_knowledge', $type); @@ -37,26 +37,26 @@ class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface $role = (new Role()) ->setActive(true) - ->setLabel(array('fr' => 'Participant', 'nl' => 'Deelneemer', 'en' => 'Participant')) + ->setName(array('fr' => 'Participant', 'nl' => 'Deelneemer', 'en' => 'Participant')) ->setType($type) ; $manager->persist($role); $role = (new Role()) ->setActive(true) - ->setLabel(array('fr' => 'Animateur')) + ->setName(array('fr' => 'Animateur')) ->setType($type); $manager->persist($role); $status = (new Status()) ->setActive(true) - ->setLabel(array('fr' => 'Inscrit')) + ->setName(array('fr' => 'Inscrit')) ->setType($type); $manager->persist($status); $status = (new Status()) ->setActive(true) - ->setLabel(array('fr' => 'Présent')) + ->setName(array('fr' => 'Présent')) ->setType($type) ; $manager->persist($status); @@ -64,7 +64,7 @@ class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface $type = (new EventType()) ->setActive(true) - ->setLabel(array('fr' => 'Formation', 'en' => 'Course', 'nl' => 'Opleiding')) + ->setName(array('fr' => 'Formation', 'en' => 'Course', 'nl' => 'Opleiding')) ; $manager->persist($type); $this->addReference('event_type_course', $type); @@ -72,21 +72,21 @@ class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface $role = (new Role()) ->setActive(true) - ->setLabel(array('fr' => 'Participant', 'nl' => 'Deelneemer', 'en' => 'Participant')) + ->setName(array('fr' => 'Participant', 'nl' => 'Deelneemer', 'en' => 'Participant')) ->setType($type) ; $manager->persist($role); $status = (new Status()) ->setActive(true) - ->setLabel(array('fr' => 'Inscrit')) + ->setName(array('fr' => 'Inscrit')) ->setType($type) ; $manager->persist($status); $status = (new Status()) ->setActive(true) - ->setLabel(array('fr' => 'En liste d\'attente')) + ->setName(array('fr' => 'En liste d\'attente')) ->setType($type) ; $manager->persist($status); diff --git a/DataFixtures/ORM/LoadParticipation.php b/DataFixtures/ORM/LoadParticipation.php index 98f19a82e..5f18d06b2 100644 --- a/DataFixtures/ORM/LoadParticipation.php +++ b/DataFixtures/ORM/LoadParticipation.php @@ -80,7 +80,7 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa for($i=0; $i<$expectedNumber; $i++) { $event = (new Event()) ->setDate($this->faker->dateTimeBetween('-2 years', '+6 months')) - ->setLabel($this->faker->words(rand(2,4), true)) + ->setName($this->faker->words(rand(2,4), true)) ->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)])) ->setCenter($center) ->setCircle( diff --git a/Entity/Event.php b/Entity/Event.php index d9512fda0..0246be6fd 100644 --- a/Entity/Event.php +++ b/Entity/Event.php @@ -18,7 +18,7 @@ class Event implements HasCenterInterface, HasScopeInterface /** * @var string */ - private $label; + private $name; /** * @var \DateTime @@ -74,9 +74,9 @@ class Event implements HasCenterInterface, HasScopeInterface * * @return Event */ - public function setLabel($label) + public function setName($label) { - $this->label = $label; + $this->name = $label; return $this; } @@ -86,9 +86,9 @@ class Event implements HasCenterInterface, HasScopeInterface * * @return string */ - public function getLabel() + public function getName() { - return $this->label; + return $this->name; } /** diff --git a/Entity/EventType.php b/Entity/EventType.php index e7646c03a..8f0d2bba4 100644 --- a/Entity/EventType.php +++ b/Entity/EventType.php @@ -15,7 +15,7 @@ class EventType /** * @var array */ - private $label; + private $name; /** * @var boolean @@ -58,9 +58,9 @@ class EventType * * @return EventType */ - public function setLabel($label) + public function setName($label) { - $this->label = $label; + $this->name = $label; return $this; } @@ -70,9 +70,9 @@ class EventType * * @return array */ - public function getLabel() + public function getName() { - return $this->label; + return $this->name; } /** diff --git a/Entity/Role.php b/Entity/Role.php index fe98414ab..c50665b11 100644 --- a/Entity/Role.php +++ b/Entity/Role.php @@ -15,7 +15,7 @@ class Role /** * @var array */ - private $label; + private $name; /** * @var boolean @@ -45,9 +45,9 @@ class Role * * @return Role */ - public function setLabel($label) + public function setName($label) { - $this->label = $label; + $this->name = $label; return $this; } @@ -57,9 +57,9 @@ class Role * * @return array */ - public function getLabel() + public function getName() { - return $this->label; + return $this->name; } /** diff --git a/Entity/Status.php b/Entity/Status.php index d39a325c3..6a4ee29ad 100644 --- a/Entity/Status.php +++ b/Entity/Status.php @@ -15,7 +15,7 @@ class Status /** * @var array */ - private $label; + private $name; /** * @var boolean @@ -41,13 +41,13 @@ class Status /** * Set label * - * @param array $label + * @param array $name * * @return Status */ - public function setLabel($label) + public function setName($name) { - $this->label = $label; + $this->name = $name; return $this; } @@ -57,9 +57,9 @@ class Status * * @return array */ - public function getLabel() + public function getName() { - return $this->label; + return $this->name; } diff --git a/Form/EventType.php b/Form/EventType.php index 29b32a086..a3417a81e 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -67,7 +67,7 @@ class EventType extends AbstractType } $builder - ->add('label') + ->add('name') ->add( 'date', 'date', diff --git a/Form/EventTypeType.php b/Form/EventTypeType.php index 02ec828e8..9616f9f59 100644 --- a/Form/EventTypeType.php +++ b/Form/EventTypeType.php @@ -15,7 +15,7 @@ class EventTypeType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('label') + ->add('name') ->add('active') ; } diff --git a/Form/ParticipationType.php b/Form/ParticipationType.php index 4891a4811..5b754dcf9 100644 --- a/Form/ParticipationType.php +++ b/Form/ParticipationType.php @@ -76,7 +76,7 @@ class ParticipationType extends AbstractType ); }, 'choice_label' => function(Role $r) use ($translatableStringHelper) { - return $translatableStringHelper->localize($r->getLabel()); + return $translatableStringHelper->localize($r->getName()); } )); @@ -102,7 +102,7 @@ class ParticipationType extends AbstractType return $qb; }, 'choice_label' => function(Status $s) use ($translatableStringHelper) { - return $translatableStringHelper->localize($s->getLabel()); + return $translatableStringHelper->localize($s->getName()); } )); diff --git a/Form/RoleType.php b/Form/RoleType.php index 293aec1d1..4f8fb3c53 100644 --- a/Form/RoleType.php +++ b/Form/RoleType.php @@ -15,7 +15,7 @@ class RoleType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('label') + ->add('name') ->add('active') ->add('type') ; diff --git a/Form/StatusType.php b/Form/StatusType.php index 24bdcd604..1bef97168 100644 --- a/Form/StatusType.php +++ b/Form/StatusType.php @@ -15,7 +15,7 @@ class StatusType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('label') + ->add('name') ->add('active') ->add('type') ; diff --git a/Form/Type/TranslatableEventType.php b/Form/Type/TranslatableEventType.php index cf2abc14a..6b7a80d03 100644 --- a/Form/Type/TranslatableEventType.php +++ b/Form/Type/TranslatableEventType.php @@ -62,7 +62,7 @@ class TranslatableEventType extends AbstractType ->where('et.active = true'); }, 'choice_label' => function (EventType $t) use ($helper) { - return $helper->localize($t->getLabel()); + return $helper->localize($t->getName()); }, ) ); diff --git a/Resources/config/doctrine/Event.orm.yml b/Resources/config/doctrine/Event.orm.yml index ae69e2f06..eb02041e4 100644 --- a/Resources/config/doctrine/Event.orm.yml +++ b/Resources/config/doctrine/Event.orm.yml @@ -8,7 +8,7 @@ Chill\EventBundle\Entity\Event: generator: strategy: AUTO fields: - label: + name: type: string length: '150' date: diff --git a/Resources/config/doctrine/EventType.orm.yml b/Resources/config/doctrine/EventType.orm.yml index 17bc5cadb..dcfab3ba6 100644 --- a/Resources/config/doctrine/EventType.orm.yml +++ b/Resources/config/doctrine/EventType.orm.yml @@ -8,7 +8,7 @@ Chill\EventBundle\Entity\EventType: generator: strategy: AUTO fields: - label: + name: type: json_array active: type: boolean diff --git a/Resources/config/doctrine/Role.orm.yml b/Resources/config/doctrine/Role.orm.yml index 8d1723c37..b6a1ae677 100644 --- a/Resources/config/doctrine/Role.orm.yml +++ b/Resources/config/doctrine/Role.orm.yml @@ -8,7 +8,7 @@ Chill\EventBundle\Entity\Role: generator: strategy: AUTO fields: - label: + name: type: json_array active: type: boolean diff --git a/Resources/config/doctrine/Status.orm.yml b/Resources/config/doctrine/Status.orm.yml index 2849b7522..f1567f8f0 100644 --- a/Resources/config/doctrine/Status.orm.yml +++ b/Resources/config/doctrine/Status.orm.yml @@ -8,7 +8,7 @@ Chill\EventBundle\Entity\Status: generator: strategy: AUTO fields: - label: + name: type: json_array active: type: boolean diff --git a/Resources/migrations/Version20160318111334.php b/Resources/migrations/Version20160318111334.php index fe23df743..df23eaab1 100644 --- a/Resources/migrations/Version20160318111334.php +++ b/Resources/migrations/Version20160318111334.php @@ -24,24 +24,24 @@ class Version20160318111334 extends AbstractMigration $this->addSql('CREATE SEQUENCE chill_event_event_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('CREATE SEQUENCE chill_event_participation_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('CREATE TABLE chill_event_event_type (' - . 'id INT NOT NULL, label JSON NOT NULL, ' + . 'id INT NOT NULL, name JSON NOT NULL, ' . 'active BOOLEAN NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE TABLE chill_event_role (' . 'id INT NOT NULL, ' . 'type_id INT DEFAULT NULL, ' - . 'label JSON NOT NULL, ' + . 'name JSON NOT NULL, ' . 'active BOOLEAN NOT NULL, ' . 'PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_AA714E54C54C8C93 ON chill_event_role (type_id)'); $this->addSql('CREATE TABLE chill_event_status (id INT NOT NULL, ' . 'type_id INT DEFAULT NULL, ' - . 'label JSON NOT NULL, ' + . 'name JSON NOT NULL, ' . 'active BOOLEAN NOT NULL, ' . 'PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_A6CC85D0C54C8C93 ON chill_event_status (type_id)'); $this->addSql('CREATE TABLE chill_event_event (' . 'id INT NOT NULL, ' - . 'label VARCHAR(150) NOT NULL, ' + . 'name VARCHAR(150) NOT NULL, ' . 'date DATE NOT NULL, ' . 'center_id INT DEFAULT NULL, ' . 'type_id INT DEFAULT NULL, ' diff --git a/Resources/views/Event/edit.html.twig b/Resources/views/Event/edit.html.twig index ca326aa80..03519eff9 100644 --- a/Resources/views/Event/edit.html.twig +++ b/Resources/views/Event/edit.html.twig @@ -11,7 +11,7 @@ {% if edit_form.center is defined %} {{ form_row(edit_form.center) }} {% endif %} - {{ form_row(edit_form.label) }} + {{ form_row(edit_form.name) }} {{ form_row(edit_form.date) }} {{ form_row(edit_form.type, { 'label': 'Event type' }) }} diff --git a/Resources/views/Event/index.html.twig b/Resources/views/Event/index.html.twig index b5ac1e62a..442d5ca67 100644 --- a/Resources/views/Event/index.html.twig +++ b/Resources/views/Event/index.html.twig @@ -7,7 +7,7 @@ Id - Label + Name Date Actions @@ -16,7 +16,7 @@ {% for entity in entities %} {{ entity.id }} - {{ entity.label }} + {{ entity.name }} {% if entity.date %}{{ entity.date|date('Y-m-d H:i:s') }}{% endif %}
                  diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig index c8e8ecbdd..4f3687049 100644 --- a/Resources/views/Event/list.html.twig +++ b/Resources/views/Event/list.html.twig @@ -16,9 +16,9 @@ {% for event in events %} - {{ event.label }} + {{ event.name }} {{ event.date|localizeddate('long', 'none') }} - {{ event.type.label|localize_translatable_string }} + {{ event.type.name|localize_translatable_string }}
                  • diff --git a/Resources/views/Event/new.html.twig b/Resources/views/Event/new.html.twig index 2986a83ac..17c8de06b 100644 --- a/Resources/views/Event/new.html.twig +++ b/Resources/views/Event/new.html.twig @@ -9,7 +9,7 @@ {{ form_errors(form) }} {{ form_row(form.circle) }} {{ form_row(form.center) }} - {{ form_row(form.label) }} + {{ form_row(form.name) }} {{ form_row(form.date) }} {{ form_row(form.type, { 'label': 'Event type' }) }} diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 541e08ea1..19393459e 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -1,6 +1,6 @@ {% extends 'ChillEventBundle::layout.html.twig' %} -{% block title 'Event : %label%'|trans({ '%label%' : event.label } ) %} +{% block title 'Event : %label%'|trans({ '%label%' : event.name } ) %} {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} @@ -11,7 +11,7 @@ {{ 'Name'|trans }} - {{ event.label }} + {{ event.name }} {{ 'Date'|trans }} @@ -19,7 +19,7 @@ {{ 'Event type'|trans }} - {{ event.type.label|localize_translatable_string }} + {{ event.type.name|localize_translatable_string }} {{ 'Circle'|trans }} @@ -55,9 +55,9 @@ {% for participation in event.participations %} {{ person_macro.render(participation.person) }} - {{ participation.role.label|localize_translatable_string }} - {{ participation.status.label|localize_translatable_string }} - {{ participation.lastUpdate|time_diff }} + {{ participation.role.name|localize_translatable_string }} + {{ participation.status.name|localize_translatable_string }} + {{ participation.lastUpdate|time_diff }}
                      {% if is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %} diff --git a/Resources/views/EventType/index.html.twig b/Resources/views/EventType/index.html.twig index 72c47e279..b40ce7b0f 100644 --- a/Resources/views/EventType/index.html.twig +++ b/Resources/views/EventType/index.html.twig @@ -16,7 +16,7 @@ {% for entity in entities %} {{ entity.id }} - {{ entity.label }} + {{ entity.name }} {{ entity.active }}
                        diff --git a/Resources/views/EventType/show.html.twig b/Resources/views/EventType/show.html.twig index 818e30fa9..3e748ca85 100644 --- a/Resources/views/EventType/show.html.twig +++ b/Resources/views/EventType/show.html.twig @@ -10,8 +10,8 @@ {{ entity.id }} - Label - {{ entity.label }} + Name + {{ entity.name }} Active diff --git a/Resources/views/Participation/edit.html.twig b/Resources/views/Participation/edit.html.twig index 67f37802a..7ad24aed1 100644 --- a/Resources/views/Participation/edit.html.twig +++ b/Resources/views/Participation/edit.html.twig @@ -13,7 +13,7 @@ {{ 'Associated event'|trans }} - {{ participation.event.label }} + {{ participation.event.name }} {{ 'Date'|trans }} diff --git a/Resources/views/Participation/new.html.twig b/Resources/views/Participation/new.html.twig index 36b77a8b6..9544d62a7 100644 --- a/Resources/views/Participation/new.html.twig +++ b/Resources/views/Participation/new.html.twig @@ -15,7 +15,7 @@ {{ 'Associated event'|trans }} - {{ participation.event.label }} + {{ participation.event.name }} diff --git a/Resources/views/Role/index.html.twig b/Resources/views/Role/index.html.twig index dcfda2a25..b6dd692bc 100644 --- a/Resources/views/Role/index.html.twig +++ b/Resources/views/Role/index.html.twig @@ -7,7 +7,7 @@ Id - Label + Name Active Actions @@ -16,7 +16,7 @@ {% for entity in entities %} {{ entity.id }} - {{ entity.label }} + {{ entity.name }} {{ entity.active }}
                          diff --git a/Resources/views/Role/show.html.twig b/Resources/views/Role/show.html.twig index a212c2f6d..99207becc 100644 --- a/Resources/views/Role/show.html.twig +++ b/Resources/views/Role/show.html.twig @@ -10,8 +10,8 @@ {{ entity.id }} - Label - {{ entity.label }} + Name + {{ entity.name }} Active diff --git a/Resources/views/Status/index.html.twig b/Resources/views/Status/index.html.twig index e5ec9e480..67d138ce9 100644 --- a/Resources/views/Status/index.html.twig +++ b/Resources/views/Status/index.html.twig @@ -7,7 +7,7 @@ Id - Label + Name Active Actions @@ -16,7 +16,7 @@ {% for entity in entities %} {{ entity.id }} - {{ entity.label }} + {{ entity.name }} {{ entity.active }}
                            diff --git a/Resources/views/Status/show.html.twig b/Resources/views/Status/show.html.twig index 7b0dd4049..2b56d32eb 100644 --- a/Resources/views/Status/show.html.twig +++ b/Resources/views/Status/show.html.twig @@ -10,8 +10,8 @@ {{ entity.id }} - Label - {{ entity.label }} + Name + {{ entity.name }} Active From 90edc185314a2b5771e4737991280d112e06318a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 24 Mar 2016 23:59:24 +0100 Subject: [PATCH 036/179] fix missing label=> name in validation ref #20 --- Resources/config/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/validation.yml b/Resources/config/validation.yml index b8b62d678..d6a12b418 100644 --- a/Resources/config/validation.yml +++ b/Resources/config/validation.yml @@ -12,7 +12,7 @@ Chill\EventBundle\Entity\Participation: Chill\EventBundle\Entity\Event: properties: - label: + name: - Length: min: 3 max: 75 From a6d4cb5f5e85430c327c3358170b6a9988cbcafd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 25 Mar 2016 00:07:34 +0100 Subject: [PATCH 037/179] remove var_dump --- Entity/Participation.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Entity/Participation.php b/Entity/Participation.php index 3aa52313c..ef33c6b99 100644 --- a/Entity/Participation.php +++ b/Entity/Participation.php @@ -231,7 +231,6 @@ class Participation implements HasCenterInterface, HasScopeInterface ->atPath('status') ->addViolation(); } - var_dump('ok'); } } From 5949fd8cfb09166d8cec504e6796217b56c6ea33 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 25 Mar 2016 08:53:29 +0100 Subject: [PATCH 038/179] adding css class for buttons --- Resources/views/Event/list.html.twig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig index 4f3687049..0c98cb027 100644 --- a/Resources/views/Event/list.html.twig +++ b/Resources/views/Event/list.html.twig @@ -23,12 +23,12 @@
                            • {# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #} - + {{ 'See'|trans }} {# {% endif %} #} {% if is_granted('CHILL_EVENT_UPDATE', event) %} - + {{ 'Edit'|trans }} {% endif %} @@ -44,7 +44,8 @@
                              • - + + {{ 'New event'|trans }}
                              • From 827d1d3f2c35c45610b12a952712ecb9ff9f45e1 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 25 Mar 2016 08:57:41 +0100 Subject: [PATCH 039/179] adding css class for buttons - page event edit --- Resources/views/Event/edit.html.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/views/Event/edit.html.twig b/Resources/views/Event/edit.html.twig index 03519eff9..a5752fb73 100644 --- a/Resources/views/Event/edit.html.twig +++ b/Resources/views/Event/edit.html.twig @@ -18,6 +18,7 @@
                                • + {{ 'Back to the most recent events'|trans }}
                                • From 4aa6c4b53f15480e7b4a1db6174d4f89f8a9b2dc Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 25 Mar 2016 09:02:48 +0100 Subject: [PATCH 040/179] adding css class for buttons - page event new & show --- Resources/views/Event/new.html.twig | 1 + Resources/views/Event/show.html.twig | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Resources/views/Event/new.html.twig b/Resources/views/Event/new.html.twig index 17c8de06b..1c29a495d 100644 --- a/Resources/views/Event/new.html.twig +++ b/Resources/views/Event/new.html.twig @@ -16,6 +16,7 @@
                                  • + {{ 'Back to the most recent events'|trans }}
                                  • diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 19393459e..74fa07559 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -30,7 +30,7 @@
                                    • - + {{ 'Edit'|trans }}
                                    • @@ -63,7 +63,7 @@ {% if is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %}
                                    • + class="sc-button bt-edit"> {{ 'Edit'|trans }}
                                    • @@ -80,12 +80,12 @@
                                        {% if count > 0 %} -
                                      • {{ 'Edit all the participations'|trans }}
                                      • +
                                      • {{ 'Edit all the participations'|trans }}
                                      • {% endif %}
                                      • {{ form_start(form_add_participation_by_person) }} {{ form_widget(form_add_participation_by_person.person_id, { 'attr' : { 'style' : 'width: 20em; display:inline-block; ' } } ) }} - {{ form_widget(form_add_participation_by_person.submit, { 'attr' : { 'class' : 'sc-button btn-create' } } ) }} + {{ form_widget(form_add_participation_by_person.submit, { 'attr' : { 'class' : 'sc-button bt-create' } } ) }} {{ form_rest(form_add_participation_by_person) }} {{ form_end(form_add_participation_by_person) }}
                                        From 005fd222905b11fcd76ca9a1a285daad692eb18c Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 25 Mar 2016 09:07:32 +0100 Subject: [PATCH 041/179] adding css class for buttons - page participation new & edit --- Resources/views/Participation/edit.html.twig | 5 +++-- Resources/views/Participation/new.html.twig | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Resources/views/Participation/edit.html.twig b/Resources/views/Participation/edit.html.twig index 7ad24aed1..a778eeef7 100644 --- a/Resources/views/Participation/edit.html.twig +++ b/Resources/views/Participation/edit.html.twig @@ -28,12 +28,13 @@
                                        • - + + {{ 'Back to the event'|trans }}
                                        • - {{ form_widget(form.submit, { 'attr' : { 'class' : 'sc-button btn-create' } } ) }} + {{ form_widget(form.submit, { 'attr' : { 'class' : 'sc-button bt-edit' } } ) }}
                                        diff --git a/Resources/views/Participation/new.html.twig b/Resources/views/Participation/new.html.twig index 9544d62a7..9b7a55a7f 100644 --- a/Resources/views/Participation/new.html.twig +++ b/Resources/views/Participation/new.html.twig @@ -27,11 +27,12 @@
                                        • + {{ 'Back to the event'|trans }}
                                        • - {{ form_widget(form.submit, { 'attr' : { 'class' : 'sc-button btn-create' } } ) }} + {{ form_widget(form.submit, { 'attr' : { 'class' : 'sc-button bt-create' } } ) }}
                                        From 9cdbd8303a9f4fc42d13a421fac109f18a45043d Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 25 Mar 2016 10:10:15 +0100 Subject: [PATCH 042/179] Removing code for Deleting an event --- Controller/EventController.php | 44 ------------------------------ Resources/config/routing/event.yml | 5 ---- 2 files changed, 49 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index 702433e08..cb2301e6d 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -166,12 +166,10 @@ class EventController extends Controller } $editForm = $this->createEditForm($entity); - $deleteForm = $this->createDeleteForm($event_id); return $this->render('ChillEventBundle:Event:edit.html.twig', array( 'entity' => $entity, 'edit_form' => $editForm->createView(), - 'delete_form' => $deleteForm->createView(), )); } @@ -209,7 +207,6 @@ class EventController extends Controller throw $this->createNotFoundException('Unable to find Event entity.'); } - $deleteForm = $this->createDeleteForm($event_id); $editForm = $this->createEditForm($entity); $editForm->handleRequest($request); @@ -225,47 +222,6 @@ class EventController extends Controller return $this->render('ChillEventBundle:Event:edit.html.twig', array( 'entity' => $entity, 'edit_form' => $editForm->createView(), - 'delete_form' => $deleteForm->createView(), )); } - /** - * Deletes a Event entity. - * - */ - public function deleteAction(Request $request, $event_id) - { - $form = $this->createDeleteForm($event_id); - $form->handleRequest($request); - - if ($form->isValid()) { - $em = $this->getDoctrine()->getManager(); - $entity = $em->getRepository('ChillEventBundle:Event')->find($event_id); - - if (!$entity) { - throw $this->createNotFoundException('Unable to find Event entity.'); - } - - $em->remove($entity); - $em->flush(); - } - - return $this->redirect($this->generateUrl('event')); - } - - /** - * Creates a form to delete a Event entity by id. - * - * @param mixed $event_id The event id - * - * @return \Symfony\Component\Form\Form The form - */ - private function createDeleteForm($event_id) - { - return $this->createFormBuilder() - ->setAction($this->generateUrl('chill_event__event_delete', array('event_id' => $event_id))) - ->setMethod('DELETE') - ->add('submit', 'submit', array('label' => 'Delete')) - ->getForm() - ; - } } diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index 25b39a5c6..256850e5c 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -35,8 +35,3 @@ chill_event__event_update: path: /{event_id}/update defaults: { _controller: "ChillEventBundle:Event:update" } methods: [POST, PUT] - -chill_event__event_delete: - path: /{event_id}/delete - defaults: { _controller: "ChillEventBundle:Event:delete" } - methods: [POST, DELETE] From 93a5568aeec0263c8c1ff027f42a683726740296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 7 Apr 2016 23:29:22 +0200 Subject: [PATCH 043/179] splitting function in order to prepare single/multiple adding association ref #6 --- Controller/ParticipationController.php | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index 9024ea253..a04f05ed0 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -21,6 +21,7 @@ namespace Chill\EventBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Chill\EventBundle\Entity\Participation; use Chill\EventBundle\Form\ParticipationType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; @@ -33,7 +34,33 @@ use Chill\EventBundle\Security\Authorization\ParticipationVoter; */ class ParticipationController extends Controller { + /** + * Show a form to add a participation + * + * This function parse the person_id / persons_ids query argument + * and decide if it should process a single or multiple participation + * + * @param Request $request + */ public function newAction(Request $request) + { + $single = $request->query->getInt('person_id', null); + $multiple = $request->query->get('persons_ids', null); + + if ($single !== NULL AND $multiple !== NULL) { + // we are not allowed to have both person_id and persons_ids + return (new Response()) + ->setStatusCode(Response::HTTP_BAD_REQUEST) + ->setContent("You are not allow to provide both 'person_id' and " + . "'persons_ids' simulaneously"); + } + + if ($single !== NULL) { + return $this->newSingleAction($request); + } + } + + protected function newSingleAction(Request $request) { $participation = $this->handleRequest($request, new Participation()); From bcfa2c2131d210deb14420954e1f3f0512f595bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 9 Apr 2016 23:44:40 +0200 Subject: [PATCH 044/179] bootstrapping tests --- .gitignore | 2 +- Resources/test/Fixtures/App/AppKernel.php | 46 ++++++++++++++++ Resources/test/Fixtures/App/config/config.yml | 43 +++++++++++++++ .../test/Fixtures/App/config/config_test.yml | 52 +++++++++++++++++++ .../App/config/parameters.gitlab-ci.yml | 11 ++++ .../test/Fixtures/App/config/parameters.yml | 11 ++++ .../Fixtures/App/config/parameters.yml.dist | 11 ++++ .../test/Fixtures/App/config/routing.yml | 4 ++ Resources/test/Fixtures/App/console | 27 ++++++++++ Resources/test/bootstrap.php | 8 +++ .../Participation/new-multiple.html.twig | 40 ++++++++++++++ phpunit.xml.dist | 23 ++++++++ 12 files changed, 277 insertions(+), 1 deletion(-) create mode 100644 Resources/test/Fixtures/App/AppKernel.php create mode 100644 Resources/test/Fixtures/App/config/config.yml create mode 100644 Resources/test/Fixtures/App/config/config_test.yml create mode 100644 Resources/test/Fixtures/App/config/parameters.gitlab-ci.yml create mode 100644 Resources/test/Fixtures/App/config/parameters.yml create mode 100644 Resources/test/Fixtures/App/config/parameters.yml.dist create mode 100644 Resources/test/Fixtures/App/config/routing.yml create mode 100644 Resources/test/Fixtures/App/console create mode 100644 Resources/test/bootstrap.php create mode 100644 Resources/views/Participation/new-multiple.html.twig create mode 100644 phpunit.xml.dist diff --git a/.gitignore b/.gitignore index a06b406d1..093d23fa5 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,7 @@ app/config/parameters.yml Tests/Fixtures/App/config/parameters.yml # fixtures -Resources/test/* +Resources/test/Fixtures/App/DoctrineMigrations/ #composer composer.lock diff --git a/Resources/test/Fixtures/App/AppKernel.php b/Resources/test/Fixtures/App/AppKernel.php new file mode 100644 index 000000000..366c1e6a0 --- /dev/null +++ b/Resources/test/Fixtures/App/AppKernel.php @@ -0,0 +1,46 @@ +load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); + } + + /** + * @return string + */ + public function getCacheDir() + { + return sys_get_temp_dir().'/ChillEventBundle/cache'; + } + + /** + * @return string + */ + public function getLogDir() + { + return sys_get_temp_dir().'/ChillEventBundle/logs'; + } +} diff --git a/Resources/test/Fixtures/App/config/config.yml b/Resources/test/Fixtures/App/config/config.yml new file mode 100644 index 000000000..cf6bb3108 --- /dev/null +++ b/Resources/test/Fixtures/App/config/config.yml @@ -0,0 +1,43 @@ +imports: + - { resource: parameters.yml } + +framework: + secret: Not very secret + router: { resource: "%kernel.root_dir%/config/routing.yml" } + form: true + csrf_protection: true + session: ~ + default_locale: fr + translator: { fallback: fr } + profiler: { only_exceptions: false } + templating: + engines: ['twig'] + +# Doctrine Configuration +doctrine: + dbal: + driver: pdo_pgsql + host: "%database_host%" + port: "%database_port%" + dbname: "%database_name%" + user: "%database_user%" + password: "%database_password%" + charset: UTF8 + mapping_types: + jsonb: json_array + + orm: + auto_generate_proxy_classes: "%kernel.debug%" + auto_mapping: true + +# Assetic Configuration +assetic: + debug: "%kernel.debug%" + use_controller: false + bundles: [ ] + #java: /usr/bin/java + filters: + cssrewrite: ~ + +chill_main: + available_languages: [fr, en] diff --git a/Resources/test/Fixtures/App/config/config_test.yml b/Resources/test/Fixtures/App/config/config_test.yml new file mode 100644 index 000000000..b4f6d786a --- /dev/null +++ b/Resources/test/Fixtures/App/config/config_test.yml @@ -0,0 +1,52 @@ +imports: + - { resource: config.yml } + +framework: + test: ~ + session: + storage_id: session.storage.filesystem + +security: + role_hierarchy: + CHILL_MASTER_ROLE: [CHILL_INHERITED_ROLE_1] + providers: + chain_provider: + chain : + providers: [in_memory, users] + in_memory: + memory: + users: + admin: { password: "password", roles: 'ROLE_ADMIN' } + users: + entity: + class: Chill\MainBundle\Entity\User + property: username + + encoders: + Chill\MainBundle\Entity\User: + algorithm: bcrypt + Symfony\Component\Security\Core\User\User: + algorithm: plaintext + + firewalls: + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + + + + default: + anonymous: ~ + http_basic: ~ + form_login: + csrf_parameter: _csrf_token + csrf_token_id: authenticate + csrf_provider: form.csrf_provider + + logout: ~ + + + access_control: + - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: ^/[a-z]*/admin, roles: ROLE_ADMIN } + - { path: ^/, roles: ROLE_USER } \ No newline at end of file diff --git a/Resources/test/Fixtures/App/config/parameters.gitlab-ci.yml b/Resources/test/Fixtures/App/config/parameters.gitlab-ci.yml new file mode 100644 index 000000000..c4e63ef76 --- /dev/null +++ b/Resources/test/Fixtures/App/config/parameters.gitlab-ci.yml @@ -0,0 +1,11 @@ +parameters: + database_host: chill__database + database_port: 5432 + database_name: postgres + database_user: postgres + database_password: postgres + locale: fr + secret: ThisTokenIsNotSoSecretChangeIt + debug_toolbar: true + debug_redirects: false + use_assetic_controller: true \ No newline at end of file diff --git a/Resources/test/Fixtures/App/config/parameters.yml b/Resources/test/Fixtures/App/config/parameters.yml new file mode 100644 index 000000000..d92cc2318 --- /dev/null +++ b/Resources/test/Fixtures/App/config/parameters.yml @@ -0,0 +1,11 @@ +parameters: + database_host: 127.0.0.1 + database_port: 5435 + database_name: postgres + database_user: postgres + database_password: postgres + locale: fr + secret: ThisTokenIsNotSoSecretChangeIt + debug_toolbar: true + debug_redirects: false + use_assetic_controller: true \ No newline at end of file diff --git a/Resources/test/Fixtures/App/config/parameters.yml.dist b/Resources/test/Fixtures/App/config/parameters.yml.dist new file mode 100644 index 000000000..38fab7fd2 --- /dev/null +++ b/Resources/test/Fixtures/App/config/parameters.yml.dist @@ -0,0 +1,11 @@ +parameters: + database_host: 127.0.0.1 + database_port: 5435 + database_name: chill + database_user: chill + database_password: chill + locale: fr + secret: ThisTokenIsNotSoSecretChangeIt + debug_toolbar: true + debug_redirects: false + use_assetic_controller: true \ No newline at end of file diff --git a/Resources/test/Fixtures/App/config/routing.yml b/Resources/test/Fixtures/App/config/routing.yml new file mode 100644 index 000000000..802d3a1c8 --- /dev/null +++ b/Resources/test/Fixtures/App/config/routing.yml @@ -0,0 +1,4 @@ +#load routes for chil bundles +chill_routes: + resource: . + type: chill_routes \ No newline at end of file diff --git a/Resources/test/Fixtures/App/console b/Resources/test/Fixtures/App/console new file mode 100644 index 000000000..4ee9cfb33 --- /dev/null +++ b/Resources/test/Fixtures/App/console @@ -0,0 +1,27 @@ +#!/usr/bin/env php +getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'test'); +$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod'; + +if ($debug) { + Debug::enable(); +} + +$kernel = new AppKernel($env, $debug); +$application = new Application($kernel); +$application->run($input); diff --git a/Resources/test/bootstrap.php b/Resources/test/bootstrap.php new file mode 100644 index 000000000..0279b4ee6 --- /dev/null +++ b/Resources/test/bootstrap.php @@ -0,0 +1,8 @@ +{{ 'Participation creation'|trans }} + + + + + + + + + + + + +
                                        {{ 'Associated person'|trans }}{{ person_macro.render(participation.person) }}
                                        {{ 'Associated event'|trans }} {{ participation.event.name }}
                                        + + {{ form_start(form) }} + {{ form_row(form.role) }} + {{ form_row(form.status) }} + + + + {{ form_end(form) }} +{% endblock %} diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 000000000..cb1f867cf --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,23 @@ + + + + + + ./Tests + + + + + ./ + + ./Resources + ./Tests + ./vendor + + + + + + + + From 9459d7a287e961d47159f5e17cfcb4b09b8e2400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 9 Apr 2016 23:45:07 +0200 Subject: [PATCH 045/179] Allow to add multiple participation The participationController accept a new parameter : `persons_ids`, which must receive a comma-separated list of person ids. A participation will be create for all those peoples. The `new` and `create` actions does not allow to receive both `person_id` and `persons_ids`. Tests are added. ref #6 --- Controller/ParticipationController.php | 224 +++++++++++-- Entity/Participation.php | 55 +++- .../Participation/new-multiple.html.twig | 47 ++- Resources/views/Participation/new.html.twig | 3 + Tests/Controller/EventControllerTest.php | 5 + Tests/Controller/EventTypeControllerTest.php | 4 + .../ParticipationControllerTest.php | 311 ++++++++++++++++++ Tests/Controller/RoleControllerTest.php | 4 + Tests/Controller/StatusControllerTest.php | 4 + 9 files changed, 626 insertions(+), 31 deletions(-) create mode 100644 Tests/Controller/ParticipationControllerTest.php diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index a04f05ed0..007a7825d 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -26,6 +26,7 @@ use Chill\EventBundle\Entity\Participation; use Chill\EventBundle\Form\ParticipationType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Chill\EventBundle\Security\Authorization\ParticipationVoter; +use Symfony\Component\Form\Extension\Core\Type\CollectionType; /** * @@ -44,23 +45,65 @@ class ParticipationController extends Controller */ public function newAction(Request $request) { - $single = $request->query->getInt('person_id', null); - $multiple = $request->query->get('persons_ids', null); - - if ($single !== NULL AND $multiple !== NULL) { - // we are not allowed to have both person_id and persons_ids + // test the request is correct + try { + $this->testRequest($request); + } catch (\RuntimeException $ex) { + $this->get('logger')->warning($ex->getMessage()); + return (new Response()) ->setStatusCode(Response::HTTP_BAD_REQUEST) - ->setContent("You are not allow to provide both 'person_id' and " + ->setContent($ex->getMessage()); + } + + // forward to other action + $single = $request->query->has('person_id'); + $multiple = $request->query->has('persons_ids'); + + if ($single === true) { + return $this->newSingle($request); + } + + if ($multiple === true) { + + return $this->newMultiple($request); + } + + // at this point, we miss the required fields. Throw an error + return (new Response()) + ->setStatusCode(Response::HTTP_BAD_REQUEST) + ->setContent("You must provide either 'person_id' or " + . "'persons_ids' argument in query"); + } + + protected function testRequest($request) + { + $single = $request->query->has('person_id'); + $multiple = $request->query->has('persons_ids'); + + if ($single === true AND $multiple === true) { + // we are not allowed to have both person_id and persons_ids + throw new \RuntimeException("You are not allow to provide both 'person_id' and " . "'persons_ids' simulaneously"); } - if ($single !== NULL) { - return $this->newSingleAction($request); + if ($multiple === true) { + $persons_ids = $request->query->get('persons_ids'); + + if (!preg_match('/^([0-9]{1,},){1,}[0-9]{1,}$/', $persons_ids)) { + throw new \RuntimeException("The persons_ids value should " + . "contains int separated by ','"); + } } + + // check for event_id - this could be removed later + if ($request->query->has('event_id') === FALSE) { + throw new \RuntimeException("You must provide an event_id"); + } + } - protected function newSingleAction(Request $request) + protected function newSingle(Request $request) { $participation = $this->handleRequest($request, new Participation()); @@ -75,7 +118,57 @@ class ParticipationController extends Controller )); } + protected function newMultiple(Request $request) + { + $participations = $this->handleRequest($request, new Participation()); + + foreach ($participations as $participation) { + $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, + $participation, 'The user is not allowed to create this participation'); + } + + $form = $this->createCreateFormMultiple($participations); + + return $this->render('ChillEventBundle:Participation:new-multiple.html.twig', array( + 'form' => $form->createView(), + 'participations' => $participations + )); + } + public function createAction(Request $request) + { + // test the request is correct + try { + $this->testRequest($request); + } catch (\RuntimeException $ex) { + $this->get('logger')->warning($ex->getMessage()); + + return (new Response()) + ->setStatusCode(Response::HTTP_BAD_REQUEST) + ->setContent($ex->getMessage()); + } + + // forward to other action + $single = $request->query->has('person_id'); + $multiple = $request->query->has('persons_ids'); + + if ($single === true) { + return $this->createSingle($request); + } + + if ($multiple === true) { + + return $this->createMultiple($request); + } + + // at this point, we miss the required fields. Throw an error + return (new Response()) + ->setStatusCode(Response::HTTP_BAD_REQUEST) + ->setContent("You must provide either 'person_id' or " + . "'persons_ids' argument in query"); + } + + public function createSingle(Request $request) { $participation = $this->handleRequest($request, new Participation()); @@ -106,7 +199,49 @@ class ParticipationController extends Controller )); } + public function createMultiple(Request $request) + { + $participations = $this->handleRequest($request, new Participation()); + + foreach($participations as $participation) { + $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, + $participation, 'The user is not allowed to create this participation'); + } + + $form = $this->createCreateFormMultiple($participations); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $data = $form->getData(); + + foreach($data['participations'] as $participation) { + $em->persist($participation); + } + + $em->flush(); + + $this->addFlash('success', $this->get('translator')->trans( + 'The participations were created' + )); + + return $this->redirectToRoute('chill_event__event_show', array( + 'event_id' => $participations[0]->getEvent()->getId() + )); + } + + return $this->render('ChillEventBundle:Participation:new.html.twig', array( + 'form' => $form->createView(), + 'participation' => $participation + )); + } + /** + * + * Handle the request to adapt $participation. + * + * If the request is multiple, the $participation object is cloned. + * Limitations: the $participation should not be persisted. * * @param Request $request * @param Participation $participation @@ -117,6 +252,10 @@ class ParticipationController extends Controller protected function handleRequest(Request $request, Participation $participation) { $em = $this->getDoctrine()->getManager(); + if ($em->contains($participation)) { + throw new \LogicException("The participation object should not be managed by " + . "the object manager using the method ".__METHOD__); + } $event_id = $request->query->getInt('event_id', null); @@ -134,23 +273,37 @@ class ParticipationController extends Controller $participation->setEvent($event); } - $person_id = $request->query->getInt('person_id', null); + // this script should be able to handle multiple, so we translate + // single person_id in an array + $persons_ids = $request->query->has('person_id') ? + array($request->query->getInt('person_id', null)): + explode(',', $request->query->get('persons_ids')) + ; + $participations = array(); - if ($person_id !== NULL) { - $person = $em->getRepository('ChillPersonBundle:Person') - ->find($person_id); + foreach($persons_ids as $person_id) { - if ($person === NULL) { - throw $this->createNotFoundException('The person with id '.$person_id.' is not found'); + // clone if we have to reuse the $participation + $participation = count($persons_ids) > 1 ? clone $participation : $participation; + + if ($person_id !== NULL) { + $person = $em->getRepository('ChillPersonBundle:Person') + ->find($person_id); + + if ($person === NULL) { + throw $this->createNotFoundException('The person with id '.$person_id.' is not found'); + } + + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person, + 'The user is not allowed to see the person'); + + $participation->setPerson($person); } - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person, - 'The user is not allowed to see the person'); - - $participation->setPerson($person); + $participations[] = $participation; } - return $participation; + return count($participations) > 1 ? $participations : $participations[0]; } /** @@ -175,6 +328,37 @@ class ParticipationController extends Controller return $form; } + /** + * + * @param array $participations + * @return type + */ + public function createCreateFormMultiple(array $participations) + { + $form = $this->createForm(\Symfony\Component\Form\Extension\Core\Type\FormType::class, + array('participations' => $participations), array( + 'action' => $this->generateUrl('chill_event_participation_create', array( + 'event_id' => $participations[0]->getEvent()->getId(), + 'persons_ids' => implode(',', array_map( + function(Participation $p) { return $p->getPerson()->getId(); }, + $participations)) + ) + ))); + $form->add('participations', CollectionType::class, array( + 'entry_type' => ParticipationType::class, + 'entry_options' => array( + 'event_type' => $participations[0]->getEvent()->getType() + ), + ) + ); + + $form->add('submit', SubmitType::class, array( + 'label' => 'Create' + )); + + return $form; + } + /** * show an edit form for the participation with the given id. * diff --git a/Entity/Participation.php b/Entity/Participation.php index ef33c6b99..07967edca 100644 --- a/Entity/Participation.php +++ b/Entity/Participation.php @@ -9,7 +9,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * Participation */ -class Participation implements HasCenterInterface, HasScopeInterface +class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAccess { /** * @var integer @@ -218,6 +218,11 @@ class Participation implements HasCenterInterface, HasScopeInterface */ public function isConsistent(ExecutionContextInterface $context) { + + if ($this->getEvent() === NULL || $this->getRole() === NULL || $this->getStatus() === NULL) { + return; + } + if ($this->getRole()->getType()->getId() !== $this->getEvent()->getType()->getId()) { $context->buildViolation('The role is not allowed with this event type') @@ -233,4 +238,52 @@ class Participation implements HasCenterInterface, HasScopeInterface } } + public function offsetExists($offset) + { + return in_array($offset, array( + 'person', 'role', 'status', 'event' + )); + } + + public function offsetGet($offset) + { + switch ($offset) { + case 'person': + return $this->getPerson(); + break; + case 'role': + return $this->getRole(); + break; + case 'status': + return $this->getStatus(); + break; + case 'event': + return $this->getEvent(); + break; + } + } + + public function offsetSet($offset, $value) + { + switch($offset) { + case 'person': + return $this->setPerson($value); + break; + case 'role': + return $this->setRole($value); + break; + case 'status': + return $this->setStatus($value); + break; + case 'event': + return $this->setEvent($value); + break; + } + } + + public function offsetUnset($offset) + { + $this->offsetSet($offset, null); + } + } diff --git a/Resources/views/Participation/new-multiple.html.twig b/Resources/views/Participation/new-multiple.html.twig index 9b7a55a7f..634ffa78f 100644 --- a/Resources/views/Participation/new-multiple.html.twig +++ b/Resources/views/Participation/new-multiple.html.twig @@ -3,30 +3,57 @@ {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} {% block title 'Participation creation'|trans %} + + {% form_theme form _self %} + + {% block _collection_row %} + + + {{ form_widget(form) }} + + + {# {{ form_row(participationField.status) }} #} + + + {% endblock %} {% block event_content -%}

                                        {{ 'Participation creation'|trans }}

                                        - - - - - +
                                        {{ 'Associated person'|trans }}{{ person_macro.render(participation.person) }}
                                        {{ 'Associated event'|trans }} {{ participation.event.name }}{{ participations[0].event.name }}
                                        - - {{ form_start(form) }} - {{ form_row(form.role) }} - {{ form_row(form.status) }} + + + {{ form_start(form) }} + + + + + + + + + + {% for participationField in form.participations %} + + + + + + {% endfor %} + +
                                        {{ 'Person'|trans }}{{ 'Role'|trans }}{{ 'Status'|trans }}
                                        {{ person_macro.render(participationField.vars.value.person) }}{{ form_widget(participationField.role) }}{{ form_widget(participationField.status) }}
                                        +
                                        • - + {{ 'Back to the event'|trans }} diff --git a/Resources/views/Participation/new.html.twig b/Resources/views/Participation/new.html.twig index 9b7a55a7f..f74aef392 100644 --- a/Resources/views/Participation/new.html.twig +++ b/Resources/views/Participation/new.html.twig @@ -21,6 +21,9 @@ {{ form_start(form) }} + + {{ form_errors(form) }} + {{ form_row(form.role) }} {{ form_row(form.status) }} diff --git a/Tests/Controller/EventControllerTest.php b/Tests/Controller/EventControllerTest.php index 6435a2712..d955d4a56 100644 --- a/Tests/Controller/EventControllerTest.php +++ b/Tests/Controller/EventControllerTest.php @@ -6,6 +6,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class EventControllerTest extends WebTestCase { + + public function testSkipped() + { + $this->markTestSkipped(); + } /* public function testCompleteScenario() { diff --git a/Tests/Controller/EventTypeControllerTest.php b/Tests/Controller/EventTypeControllerTest.php index 2075dfdbe..57af95de5 100644 --- a/Tests/Controller/EventTypeControllerTest.php +++ b/Tests/Controller/EventTypeControllerTest.php @@ -6,6 +6,10 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class EventTypeControllerTest extends WebTestCase { + public function testSkipped() + { + $this->markTestSkipped(); + } /* public function testCompleteScenario() { diff --git a/Tests/Controller/ParticipationControllerTest.php b/Tests/Controller/ParticipationControllerTest.php new file mode 100644 index 000000000..b9a6d8dde --- /dev/null +++ b/Tests/Controller/ParticipationControllerTest.php @@ -0,0 +1,311 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\EventBundle\Tests\Controller; + +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; + +/** + * Test the creation of participation controller + * + * + * @author Julien Fastré + */ +class ParticipationControllerTest extends WebTestCase +{ + /** + * + * @var \Symfony\Component\BrowserKit\Client + */ + protected $client; + + /** + * + * @var \Doctrine\ORM\EntityManagerInterface + */ + protected $em; + + /** + * Keep a cache for each person id given by the function getRandomPerson. + * + * This is reset by setUp() + * + * @var int[] + */ + private $personsIdsCache = array(); + + public function setUp() + { + self::bootKernel(); + + $this->client = static::createClient(array(), array( + 'PHP_AUTH_USER' => 'center a_social', + 'PHP_AUTH_PW' => 'password', + 'HTTP_ACCEPT_LANGUAGE' => 'fr_FR' + )); + + $container = self::$kernel->getContainer(); + + $this->em = $container->get('doctrine.orm.entity_manager') + ; + + $this->personsIdsCache = array(); + } + + /** + * + * + * @return \Chill\EventBundle\Entity\Event + */ + protected function getRandomEvent($centerName = 'Center A', $circleName = 'social') + { + $center = $this->em->getRepository('ChillMainBundle:Center') + ->findByName($centerName); + + $circles = $this->em->getRepository('ChillMainBundle:Scope') + ->findAll(); + array_filter($circles, function($circle) use ($circleName) { + return in_array($circleName, $circle->getName()); + }); + $circle = $circles[0]; + + $events = $this->em->getRepository('ChillEventBundle:Event') + ->findBy(array('center' => $center, 'circle' => $circle)); + + return $events[array_rand($events)]; + } + + /** + * This function does not give the same person twice + * for each test + * + * @param string $centerName + * @return \Chill\PersonBundle\Entity\Person + */ + protected function getRandomPerson($centerName = 'Center A') + { + $center = $this->em->getRepository('ChillMainBundle:Center') + ->findByName($centerName); + + $persons = $this->em->getRepository('ChillPersonBundle:Person') + ->findBy(array('center' => $center)); + + $person = $persons[array_rand($persons)]; + + if (in_array($person->getId(), $this->personsIdsCache)) { + return $this->getRandomPerson($centerName); // we try another time + } else { + $this->personsIdsCache[] = $person->getId(); + return $person; + } + + } + + public function testNewActionWrongParameters() + { + $event = $this->getRandomEvent(); + $person = $this->getRandomPerson(); + + // missing person_id or persons_ids + $this->client->request('GET', '/fr/event/participation/new', + array( + 'event_id' => $event->getId() + )); + $this->assertEquals(400, $this->client->getResponse()->getStatusCode(), + "Test that /fr/event/participation/new fail if " + . "both person_id and persons_ids are missing"); + + // having both person_id and persons_ids + $this->client->request('GET', '/fr/event/participation/new', + array( + 'event_id' => $event->getId(), + 'persons_ids' => implode(',', array( + $this->getRandomPerson()->getId(), + $this->getRandomPerson()->getId() + )), + 'person_id' => $person->getId() + )); + $this->assertEquals(400, $this->client->getResponse()->getStatusCode(), + "test that /fr/event/participation/new fail if both person_id and " + . "persons_ids are set"); + + // missing event_id + $this->client->request('GET', '/fr/event/participation/new', + array( + 'person_id' => $person->getId() + )); + $this->assertEquals(400, $this->client->getResponse()->getStatusCode(), + "Test that /fr/event/participation/new fails if event_id is missing"); + + // persons_ids with wrong content + $this->client->request('GET', '/fr/event/participation/new', + array( + 'persons_ids' => 'a,b,531', + 'event_id' => $event->getId() + )); + $this->assertEquals(400, $this->client->getResponse()->getStatusCode(), + "Test that /fr/event/participation/new fails if persons_ids has wrong content"); + } + + /** + * This method test participation creation with wrong parameters. + * + * Those request should fail before any processing. + */ + public function testCreateActionWrongParameters() + { + $event = $this->getRandomEvent(); + $person = $this->getRandomPerson(); + + // missing person_id or persons_ids + $this->client->request('GET', '/fr/event/participation/create', + array( + 'event_id' => $event->getId() + )); + $this->assertEquals(400, $this->client->getResponse()->getStatusCode(), + "Test that /fr/event/participation/create fail if " + . "both person_id and persons_ids are missing"); + + // having both person_id and persons_ids + $this->client->request('GET', '/fr/event/participation/create', + array( + 'event_id' => $event->getId(), + 'persons_ids' => implode(',', array( + $this->getRandomPerson()->getId(), + $this->getRandomPerson()->getId() + )), + 'person_id' => $person->getId() + )); + $this->assertEquals(400, $this->client->getResponse()->getStatusCode(), + "test that /fr/event/participation/create fail if both person_id and " + . "persons_ids are set"); + + // missing event_id + $this->client->request('GET', '/fr/event/participation/create', + array( + 'person_id' => $person->getId() + )); + $this->assertEquals(400, $this->client->getResponse()->getStatusCode(), + "Test that /fr/event/participation/create fails if event_id is missing"); + + // persons_ids with wrong content + $this->client->request('GET', '/fr/event/participation/create', + array( + 'persons_ids' => 'a,b,531', + 'event_id' => $event->getId() + )); + $this->assertEquals(400, $this->client->getResponse()->getStatusCode(), + "Test that /fr/event/participation/create fails if persons_ids has wrong content"); + } + + public function testNewSingleAction() + { + $event = $this->getRandomEvent(); + // record the number of participation for the event + $nbParticipations = $event->getParticipations()->count(); + $person = $this->getRandomPerson(); + + $crawler = $this->client->request('GET', '/fr/event/participation/new', + array( + 'person_id' => $person->getId(), + 'event_id' => $event->getId() + )); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), + "test that /fr/event/participation/new is successful"); + + $button = $crawler->selectButton('Créer'); + + $this->assertNotNull($button, "test the form with button 'Créer' exists"); + + $this->client->submit($button->form(), array( + 'participation[role]' => $event->getType()->getRoles()->first()->getId(), + 'participation[status]' => $event->getType()->getStatuses()->first()->getId() + )); + + $this->assertTrue($this->client->getResponse()->isRedirect()); + $crawler = $this->client->followRedirect(); + + $span = $crawler->filter('table td span.entity-person a:contains("' + .$person->getFirstName().'"):contains("'.$person->getLastname().'")'); + + $this->assertGreaterThan(0, count($span)); + + // as the container has reloaded, reload the event + $event = $this->em->getRepository('ChillEventBundle:Event')->find($event->getId()); + $this->em->refresh($event); + + $this->assertEquals($nbParticipations + 1, $event->getParticipations()->count()); + } + + public function testNewMultipleAction() + { + $event = $this->getRandomEvent(); + // record the number of participation for the event + $nbParticipations = $event->getParticipations()->count(); + $person1 = $this->getRandomPerson(); + $person2 = $this->getRandomPerson(); + + $crawler = $this->client->request('GET', '/fr/event/participation/new', + array( + 'persons_ids' => implode(',', array($person1->getId(), $person2->getId())), + 'event_id' => $event->getId() + )); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), + "test that /fr/event/participation/new is successful"); + + $button = $crawler->selectButton('Créer'); + + $this->assertNotNull($button, "test the form with button 'Créer' exists"); + + $this->client->submit($button->form(), array( + 'form' => array( + 'participations' => array( + 0 => array( + 'role' => $event->getType()->getRoles()->first()->getId(), + 'status' => $event->getType()->getStatuses()->first()->getId() + ), + 1 => array( + 'role' => $event->getType()->getRoles()->first()->getId(), + 'status' => $event->getType()->getStatuses()->first()->getId() + ), + ) + ) + )); + + $this->assertTrue($this->client->getResponse()->isRedirect()); + $crawler = $this->client->followRedirect(); + + $span1 = $crawler->filter('table td span.entity-person a:contains("' + .$person1->getFirstName().'"):contains("'.$person1->getLastname().'")'); + $this->assertGreaterThan(0, count($span1)); + $span2 = $crawler->filter('table td span.entity-person a:contains("' + .$person2->getFirstName().'"):contains("'.$person2->getLastname().'")'); + $this->assertGreaterThan(0, count($span2)); + + // as the container has reloaded, reload the event + $event = $this->em->getRepository('ChillEventBundle:Event')->find($event->getId()); + $this->em->refresh($event); + + $this->assertEquals($nbParticipations + 2, $event->getParticipations()->count()); + } + + +} diff --git a/Tests/Controller/RoleControllerTest.php b/Tests/Controller/RoleControllerTest.php index 39d21ff7b..f2286f208 100644 --- a/Tests/Controller/RoleControllerTest.php +++ b/Tests/Controller/RoleControllerTest.php @@ -6,6 +6,10 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class RoleControllerTest extends WebTestCase { + public function testSkipped() + { + $this->markTestSkipped(); + } /* public function testCompleteScenario() { diff --git a/Tests/Controller/StatusControllerTest.php b/Tests/Controller/StatusControllerTest.php index fc2c94259..99e297575 100644 --- a/Tests/Controller/StatusControllerTest.php +++ b/Tests/Controller/StatusControllerTest.php @@ -6,6 +6,10 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class StatusControllerTest extends WebTestCase { + public function testSkipped() + { + $this->markTestSkipped(); + } /* public function testCompleteScenario() { From fe8994d775943e8a97f8a6ff416da92dd55e1b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 10 Apr 2016 01:38:42 +0200 Subject: [PATCH 046/179] Add event on page footer --- Resources/views/Event/show.html.twig | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 74fa07559..a94d7e1ba 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -82,15 +82,18 @@ {% if count > 0 %}
                                        • {{ 'Edit all the participations'|trans }}
                                        • {% endif %} -
                                        • - {{ form_start(form_add_participation_by_person) }} - {{ form_widget(form_add_participation_by_person.person_id, { 'attr' : { 'style' : 'width: 20em; display:inline-block; ' } } ) }} - {{ form_widget(form_add_participation_by_person.submit, { 'attr' : { 'class' : 'sc-button bt-create' } } ) }} - {{ form_rest(form_add_participation_by_person) }} - {{ form_end(form_add_participation_by_person) }} -
                                          -
                                        + +
                                        + {{ form_start(form_add_participation_by_person) }} + {{ form_widget(form_add_participation_by_person.person_id, { 'attr' : { 'style' : 'width: 25em; display:inline-block; ' } } ) }} + {{ form_widget(form_add_participation_by_person.submit, { 'attr' : { 'class' : 'sc-button bt-create' } } ) }} + {{ form_rest(form_add_participation_by_person) }} + {{ form_end(form_add_participation_by_person) }} +
                                        +
                                        + {{ chill_delegated_block('block_footer_show', { 'event': event }) }} +
                                        {% endblock %} From c1b9069138a53a7cb0949cb6c00b0178bb7b85ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 11 Apr 2016 23:59:14 +0200 Subject: [PATCH 047/179] fix the possibility to add multiple participation ref #6 --- Controller/ParticipationController.php | 99 ++++++++++++-- Resources/translations/messages.fr.yml | 2 + .../_ignored_participations.html.twig | 10 ++ .../Participation/new-multiple.html.twig | 5 +- Resources/views/Participation/new.html.twig | 5 + .../ParticipationControllerTest.php | 122 +++++++++++++++++- 6 files changed, 225 insertions(+), 18 deletions(-) create mode 100644 Resources/views/Participation/_ignored_participations.html.twig diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index 007a7825d..e2eaa3fa2 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -39,7 +39,8 @@ class ParticipationController extends Controller * Show a form to add a participation * * This function parse the person_id / persons_ids query argument - * and decide if it should process a single or multiple participation + * and decide if it should process a single or multiple participation. Depending + * on this, the appropriate layout and form. * * @param Request $request */ @@ -76,7 +77,18 @@ class ParticipationController extends Controller . "'persons_ids' argument in query"); } - protected function testRequest($request) + /** + * + * Test that the query parameters are valid : + * + * - an `event_id` is existing ; + * - `person_id` and `persons_ids` are **not** both present ; + * - `persons_id` is correct (contains only numbers and a ','. + * + * @param Request $request + * @throws \RuntimeException if an error is detected + */ + protected function testRequest(Request $request) { $single = $request->query->has('person_id'); $multiple = $request->query->has('persons_ids'); @@ -103,6 +115,12 @@ class ParticipationController extends Controller } + /** + * Show a form with single participation. + * + * @param Request $request + * @return Response + */ protected function newSingle(Request $request) { $participation = $this->handleRequest($request, new Participation()); @@ -114,25 +132,84 @@ class ParticipationController extends Controller return $this->render('ChillEventBundle:Participation:new.html.twig', array( 'form' => $form->createView(), - 'participation' => $participation + 'participation' => $participation, + 'ignored_participations' => array() // this is required, see self::newMultiple )); } + /** + * Show a form with multiple participation. + * + * If a person is already participating on the event (if a participation with + * the same person is associated with the event), the participation is ignored. + * + * If all but one participation is ignored, the page show the same response + * than the newSingle function. + * + * If all participations must be ignored, an error is shown and the method redirects + * to the event 'show' view with an appropriate flash message. + * + * @param Request $request + * @return Response + */ protected function newMultiple(Request $request) { $participations = $this->handleRequest($request, new Participation()); - foreach ($participations as $participation) { + foreach ($participations as $i => $participation) { + // check for authorization $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, $participation, 'The user is not allowed to create this participation'); + + // check that the user is not already in the event (computing only once) + /* @var $peopleParticipating \Doctrine\Common\Collections\ArrayCollection */ + $peopleParticipating = isset($peopleParticipating) ? $peopleParticipating : + $participation->getEvent()->getParticipations()->map( + function(Participation $p) { return $p->getPerson()->getId(); } + ); + + if ($peopleParticipating->contains($participation->getPerson()->getId())) { + $ignoredParticipations[] = $participation + ->getEvent()->getParticipations()->filter( + function (Participation $p) use ($participation) { + return $p->getPerson()->getId() === $participation->getPerson()->getId(); + } + )->first(); + } else { + $newParticipations[] = $participation; + } } - $form = $this->createCreateFormMultiple($participations); + // this is where the function redirect depending on valid participation - return $this->render('ChillEventBundle:Participation:new-multiple.html.twig', array( - 'form' => $form->createView(), - 'participations' => $participations - )); + if (!isset($newParticipations)) { + // if we do not have nay participants, redirect to event view + $this->addFlash('error', 'Any of the requested people may be added ' + . 'on the event: they are maybe already participating.'); + + return $this->redirectToRoute('chill_event_participation_new', array( + 'event_id' => $request->query->getInt('event_id', 0) + )); + } elseif (count($newParticipations) > 1) { + // if we have multiple participations, show a form with multiple participations + $form = $this->createCreateFormMultiple($newParticipations); + + return $this->render('ChillEventBundle:Participation:new-multiple.html.twig', array( + 'form' => $form->createView(), + 'participations' => $newParticipations, + 'ignored_participations' => isset($ignoredParticipations) ? $ignoredParticipations : array() + )); + } else { + // if we have only one participation, show the same form than for single participation + $form = $this->createCreateForm($participation); + + return $this->render('ChillEventBundle:Participation:new.html.twig', array( + 'form' => $form->createView(), + 'participation' => $participation, + 'ignored_participations' => isset($ignoredParticipations) ? $ignoredParticipations : array() + )); + + } } public function createAction(Request $request) @@ -338,7 +415,7 @@ class ParticipationController extends Controller $form = $this->createForm(\Symfony\Component\Form\Extension\Core\Type\FormType::class, array('participations' => $participations), array( 'action' => $this->generateUrl('chill_event_participation_create', array( - 'event_id' => $participations[0]->getEvent()->getId(), + 'event_id' => current($participations)->getEvent()->getId(), 'persons_ids' => implode(',', array_map( function(Participation $p) { return $p->getPerson()->getId(); }, $participations)) @@ -347,7 +424,7 @@ class ParticipationController extends Controller $form->add('participations', CollectionType::class, array( 'entry_type' => ParticipationType::class, 'entry_options' => array( - 'event_type' => $participations[0]->getEvent()->getType() + 'event_type' => current($participations)->getEvent()->getType() ), ) ); diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 67e992d7e..3d1d9c4ca 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -32,6 +32,8 @@ Back to the event: Retour à l'événement The participation was created: La participation a été créée The participation was updated: La participation a été mise à jour Participation Edit: Modifier une participation +'Any of the requested people may be added on the event: they are maybe already participating.': 'Aucune des personnes suggérées ne peut être ajoutée à l''événement: elles sont peut-être déjà inscrites comme participantes.' +'The following people have been ignored because they are already participating on the event': '{1} La personne suivante a été ignorée parce qu''elle participe déjà à l''événement | ]1,Inf] Les personnes suivantes ont été ignorées parce qu''elles participent déjà à l''événement' #search Event search: Recherche d'événements diff --git a/Resources/views/Participation/_ignored_participations.html.twig b/Resources/views/Participation/_ignored_participations.html.twig new file mode 100644 index 000000000..0d54dd624 --- /dev/null +++ b/Resources/views/Participation/_ignored_participations.html.twig @@ -0,0 +1,10 @@ +{% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} + +{% if ignored_participations|length > 0 %} +

                                        {% transchoice ignored_participations|length %}The following people have been ignored because they are already participating on the event{% endtranschoice %} :

                                        +
                                          + {% for p in ignored_participations %} +
                                        • {{ person_macro.render(p.person) }}
                                        • + {% endfor %} +
                                        +{% endif %} \ No newline at end of file diff --git a/Resources/views/Participation/new-multiple.html.twig b/Resources/views/Participation/new-multiple.html.twig index 634ffa78f..8cdfed800 100644 --- a/Resources/views/Participation/new-multiple.html.twig +++ b/Resources/views/Participation/new-multiple.html.twig @@ -28,8 +28,8 @@ - - + + {% include 'ChillEventBundle:Participation:_ignored_participations.html.twig' with ignored_participations %} {{ form_start(form) }} @@ -64,4 +64,5 @@ {{ form_end(form) }} + {% endblock %} diff --git a/Resources/views/Participation/new.html.twig b/Resources/views/Participation/new.html.twig index f74aef392..7ec10fa5f 100644 --- a/Resources/views/Participation/new.html.twig +++ b/Resources/views/Participation/new.html.twig @@ -19,6 +19,8 @@
                                        + + {% include 'ChillEventBundle:Participation:_ignored_participations.html.twig' with ignored_participations %} {{ form_start(form) }} @@ -26,6 +28,8 @@ {{ form_row(form.role) }} {{ form_row(form.status) }} + +
                                        • @@ -40,4 +44,5 @@
                                        {{ form_end(form) }} + {% endblock %} diff --git a/Tests/Controller/ParticipationControllerTest.php b/Tests/Controller/ParticipationControllerTest.php index b9a6d8dde..d912b206f 100644 --- a/Tests/Controller/ParticipationControllerTest.php +++ b/Tests/Controller/ParticipationControllerTest.php @@ -44,7 +44,9 @@ class ParticipationControllerTest extends WebTestCase /** * Keep a cache for each person id given by the function getRandomPerson. * - * This is reset by setUp() + * You may ask to ignore some people by adding their id to the array. + * + * This is reset by setUp(). * * @var int[] */ @@ -92,8 +94,31 @@ class ParticipationControllerTest extends WebTestCase } /** + * Return a random event only if he has more than one participation. + * + * @param string $centerName + * @param type $circleName + * @return \Chill\EventBundle\Entity\Event + */ + protected function getRandomEventWithMultipleParticipations( + $centerName = 'Center A', + $circleName = 'social') + { + $event = $this->getRandomEvent($centerName, $circleName); + + return $event->getParticipations()->count() > 1 ? + $event : + $this->getRandomEventWithMultipleParticipations($centerName, $circleName); + } + + /** + * Returns a person randomly. + * * This function does not give the same person twice - * for each test + * for each test. + * + * You may ask to ignore some people by adding their id to the property + * `$this->personsIdsCache` * * @param string $centerName * @return \Chill\PersonBundle\Entity\Person @@ -226,7 +251,7 @@ class ParticipationControllerTest extends WebTestCase 'person_id' => $person->getId(), 'event_id' => $event->getId() )); - + $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), "test that /fr/event/participation/new is successful"); @@ -257,8 +282,17 @@ class ParticipationControllerTest extends WebTestCase public function testNewMultipleAction() { $event = $this->getRandomEvent(); - // record the number of participation for the event + // record the number of participation for the event (used later in this test) $nbParticipations = $event->getParticipations()->count(); + // make ignore the people already in the event from the function getRandomPerson + $this->personsIdsCache = array_merge( + $this->personsIdsCache, + $event->getParticipations()->map( + function($p) { return $p->getPerson()->getId(); } + ) + ->toArray() + ); + // get some random people $person1 = $this->getRandomPerson(); $person2 = $this->getRandomPerson(); @@ -267,7 +301,7 @@ class ParticipationControllerTest extends WebTestCase 'persons_ids' => implode(',', array($person1->getId(), $person2->getId())), 'event_id' => $event->getId() )); - + $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), "test that /fr/event/participation/new is successful"); @@ -307,5 +341,83 @@ class ParticipationControllerTest extends WebTestCase $this->assertEquals($nbParticipations + 2, $event->getParticipations()->count()); } + public function testMultipleWithAllPeopleParticipating() + { + $event = $this->getRandomEventWithMultipleParticipations(); + + $persons_id = implode(',', $event->getParticipations()->map( + function($p) { return $p->getPerson()->getId(); } + )->toArray()); + + $crawler = $this->client->request('GET', '/fr/event/participation/new', + array( + 'persons_ids' => $persons_id, + 'event_id' => $event->getId() + )); + + $this->assertEquals(302, $this->client->getResponse()->getStatusCode(), + "test that /fr/event/participation/new is redirecting"); + } + + public function testMultipleWithSomePeopleParticipating() + { + $event = $this->getRandomEventWithMultipleParticipations(); + // record the number of participation for the event (used later in this test) + $nbParticipations = $event->getParticipations()->count(); + // get the persons_id participating on this event + $persons_id = $event->getParticipations()->map( + function($p) { return $p->getPerson()->getId(); } + )->toArray(); + // exclude the existing persons_ids from the new person + $this->personsIdsCache = array_merge($this->personsIdsCache, $persons_id); + + // get a random person + $newPerson = $this->getRandomPerson(); + + // build the `persons_ids` parameter + $persons_ids_string = implode(',', array_merge($persons_id, + array($newPerson->getId()))); + + $crawler = $this->client->request('GET', '/fr/event/participation/new', + array( + 'persons_ids' => $persons_ids_string, + 'event_id' => $event->getId() + )); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), + "test that /fr/event/participation/new is successful"); + + // count that the one UL contains the new person string + $firstPerson = $event->getParticipations()->first()->getPerson(); + $ul = $crawler->filter('ul:contains("'.$firstPerson->getLastName().'")' + . ':contains("'.$firstPerson->getFirstName().'")'); + + $this->assertEquals(1, $ul->count(), + "assert an ul containing the name of ignored people is present"); + $this->assertEquals($event->getParticipations()->count(), $ul->children()->count(), + "assert the li listing ignored people has the correct number"); + + // test a form is present on the page + $button = $crawler->selectButton('Créer'); + + $this->assertNotNull($button, "test the form with button 'Créer' exists"); + + // submit the form + $this->client->submit($button->form(), array( + 'participation[role]' => $event->getType()->getRoles()->first()->getId(), + 'participation[status]' => $event->getType()->getStatuses()->first()->getId() + )); + + $this->assertTrue($this->client->getResponse()->isRedirect()); + + // reload the event and test there is a new participation + $event = $this->em->getRepository('ChillEventBundle:Event') + ->find($event->getId()); + $this->em->refresh($event); + + $this->assertEquals($nbParticipations + 1, $event->getParticipations()->count(), + "Test we have persisted a new participation associated to the test"); + } + } From 78c53fe7b0f6e43edc4df1ef105d7980159ce9b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Apr 2016 22:40:11 +0200 Subject: [PATCH 048/179] [feature] allow to edit multiple participations at once ref #7 --- Controller/ParticipationController.php | 120 ++++++++++++++++++ Resources/config/routing/participation.yml | 9 ++ Resources/translations/messages.fr.yml | 3 + Resources/views/Event/show.html.twig | 2 +- .../Participation/edit-multiple.html.twig | 60 +++++++++ .../ParticipationControllerTest.php | 29 ++++- 6 files changed, 220 insertions(+), 3 deletions(-) create mode 100644 Resources/views/Participation/edit-multiple.html.twig diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index e2eaa3fa2..ca2a5f953 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -526,4 +526,124 @@ class ParticipationController extends Controller return $form; } + /** + * show a form to edit multiple participation for the same event. + * + * @param int $event_id + */ + public function editMultipleAction($event_id) + { + $event = $this->getDoctrine()->getRepository('ChillEventBundle:Event') + ->find($event_id); + + if ($event === null) { + throw $this->createNotFoundException("The event with id $event_id is not found"); + } + + // check for ACL, on Event level and on Participation Level + $this->denyAccessUnlessGranted('CHILL_EVENT_SEE', $event, "You are not allowed " + . "to see this event"); + foreach ($event->getParticipations() as $participation) { + $this->denyAccessUnlessGranted(ParticipationVoter::UPDATE, $participation, + "You are not allowed to update participation with id ".$participation->getId()); + } + + + switch ($event->getParticipations()->count()) { + + case 0: + // if there aren't any participation, redirect to the 'show' view with an add flash + $this->addFlash('warning', $this->get('translator') + ->trans( "There are no participation to edit for this event")); + + return $this->redirectToRoute('chill_event__event_show', + array('event_id' => $event->getId())); + + case 1: + // redirect to the form for a single participation + return $this->redirectToRoute('chill_event_participation_edit', array( + 'participation_id' => $event->getParticipations()->first()->getId() + )); + } + + $form = $this->createEditFormMultiple($event->getParticipations(), $event); + + return $this->render('ChillEventBundle:Participation:edit-multiple.html.twig', array( + 'event' => $event, + 'participations' => $event->getParticipations(), + 'form' => $form->createView() + )); + } + + public function updateMultipleAction($event_id, Request $request) + { + /* @var $event \Chill\EventBundle\Entity\Event */ + $event = $this->getDoctrine()->getRepository('ChillEventBundle:Event') + ->find($event_id); + + if ($event === null) { + throw $this->createNotFoundException("The event with id $event_id is not found"); + } + + $this->denyAccessUnlessGranted('CHILL_EVENT_SEE', $event, "You are not allowed " + . "to see this event"); + foreach ($event->getParticipations() as $participation) { + $this->denyAccessUnlessGranted(ParticipationVoter::UPDATE, $participation, + "You are not allowed to update participation with id ".$participation->getId()); + } + + $form = $this->createEditFormMultiple($event->getParticipations(), $event); + + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $this->getDoctrine()->getManager()->flush(); + + $this->addFlash('success', $this->get('translator')->trans("The participations " + . "have been successfully updated.")); + + return $this->redirectToRoute('chill_event__event_show', + array('event_id' => $event->getId())); + } + + return $this->render('ChillEventBundle:Participation:edit-multiple.html.twig', array( + 'event' => $event, + 'participations' => $event->getParticipations(), + 'form' => $form->createView() + )); + } + + /** + * + * @param \Doctrine\Common\Collections\Collectionn $participations contains object of Participation type + * @param \Chill\EventBundle\Entity\Event $event + * @return \Symfony\Component\Form\FormInterface + */ + protected function createEditFormMultiple( + \Doctrine\Common\Collections\Collection $participations, + \Chill\EventBundle\Entity\Event $event + ) { + $form = $this->createForm(\Symfony\Component\Form\Extension\Core\Type\FormType::class, + array('participations' => $participations), array( + 'method' => 'POST', + 'action' => $this->generateUrl('chill_event_participation_update_multiple', array( + 'event_id' => $event->getId() + )) + )); + + $form->add('participations', CollectionType::class, array( + 'entry_type' => ParticipationType::class, + 'entry_options' => array( + 'event_type' => $event->getType() + ), + ) + ); + + $form->add('submit', SubmitType::class, array( + 'label' => 'Update' + )); + + return $form; + } + } diff --git a/Resources/config/routing/participation.yml b/Resources/config/routing/participation.yml index 54d18fb71..bbb727382 100644 --- a/Resources/config/routing/participation.yml +++ b/Resources/config/routing/participation.yml @@ -14,3 +14,12 @@ chill_event_participation_update: path: /{participation_id}/update defaults: { _controller: ChillEventBundle:Participation:update } methods: [POST] + +chill_event_participation_edit_multiple: + path: /{event_id}/edit_multiple + defaults: { _controller: ChillEventBundle:Participation:editMultiple } + +chill_event_participation_update_multiple: + path: /{event_id}/update_multiple + defaults: { _controller: ChillEventBundle:Participation:updateMultiple } + methods: [POST] diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 3d1d9c4ca..4af7a2b83 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -8,6 +8,7 @@ Event: Événement Events: Événements 'Event : %label%': Événement "%label%" Participation: Participation +Participations: Participations Status: Statut Last update: Dernière mise à jour '%count% participations to this event': '{0} Aucun participant à l''événement | {1} Un participant à l''événement | ]1,Inf] %count% participants à l''événement' @@ -34,6 +35,8 @@ The participation was updated: La participation a été mise à jour Participation Edit: Modifier une participation 'Any of the requested people may be added on the event: they are maybe already participating.': 'Aucune des personnes suggérées ne peut être ajoutée à l''événement: elles sont peut-être déjà inscrites comme participantes.' 'The following people have been ignored because they are already participating on the event': '{1} La personne suivante a été ignorée parce qu''elle participe déjà à l''événement | ]1,Inf] Les personnes suivantes ont été ignorées parce qu''elles participent déjà à l''événement' +There are no participation to edit for this event: Il n'y a pas de participation pour cet événement +The participations have been successfully updated.: Les participations ont été mises à jour. #search Event search: Recherche d'événements diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index a94d7e1ba..e2aa9caf3 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -80,7 +80,7 @@ diff --git a/Resources/views/Participation/edit-multiple.html.twig b/Resources/views/Participation/edit-multiple.html.twig new file mode 100644 index 000000000..747b53260 --- /dev/null +++ b/Resources/views/Participation/edit-multiple.html.twig @@ -0,0 +1,60 @@ +{% extends 'ChillEventBundle::layout.html.twig' %} + +{% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} + +{% block event_content -%} +

                                        {{ 'Participation Edit'|trans }}

                                        + + + + + + + + + + + + +
                                        {{ 'Associated event'|trans }} {{ event.name }}
                                        {{ 'Date'|trans }} {{ event.date|localizeddate('long', 'none') }}
                                        + +

                                        {{ 'Participations'|trans }}

                                        + + {{ form_start(form) }} + + + + + + + + + + + + + {% for participation in form.participations %} + + + + + + + {% endfor %} + +
                                        {{ 'Person'|trans }}{{ 'Role'|trans }}{{ 'Status'|trans }}{{ 'Last update'|trans }} 
                                        {{ person_macro.render(participation.vars.value.person) }}{{ form_widget(participation.role) }}{{ form_widget(participation.status) }}{{ participation.vars.value.lastUpdate|time_diff }}
                                        + + + + {{ form_end(form) }} +{% endblock %} diff --git a/Tests/Controller/ParticipationControllerTest.php b/Tests/Controller/ParticipationControllerTest.php index d912b206f..a51fae197 100644 --- a/Tests/Controller/ParticipationControllerTest.php +++ b/Tests/Controller/ParticipationControllerTest.php @@ -341,7 +341,7 @@ class ParticipationControllerTest extends WebTestCase $this->assertEquals($nbParticipations + 2, $event->getParticipations()->count()); } - public function testMultipleWithAllPeopleParticipating() + public function testNewMultipleWithAllPeopleParticipating() { $event = $this->getRandomEventWithMultipleParticipations(); @@ -359,7 +359,7 @@ class ParticipationControllerTest extends WebTestCase "test that /fr/event/participation/new is redirecting"); } - public function testMultipleWithSomePeopleParticipating() + public function testNewMultipleWithSomePeopleParticipating() { $event = $this->getRandomEventWithMultipleParticipations(); // record the number of participation for the event (used later in this test) @@ -419,5 +419,30 @@ class ParticipationControllerTest extends WebTestCase "Test we have persisted a new participation associated to the test"); } + public function testEditMultipleAction() + { + /* @var $event \Chill\EventBundle\Entity\Event */ + $event = $this->getRandomEventWithMultipleParticipations(); + + $crawler = $this->client->request('GET', '/fr/event/participation/'.$event->getId(). + '/edit_multiple'); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + + $button = $crawler->selectButton('Mettre à jour'); + $this->assertEquals(1, $button->count(), "test the form with button 'mettre à jour' exists "); + + + $this->client->submit($button->form(), array( + 'form[participations][0][role]' => $event->getType()->getRoles()->first()->getId(), + 'form[participations][0][status]' => $event->getType()->getStatuses()->first()->getId(), + 'form[participations][1][role]' => $event->getType()->getRoles()->last()->getId(), + 'form[participations][1][status]' => $event->getType()->getStatuses()->last()->getId(), + )); + + $this->assertTrue($this->client->getResponse() + ->isRedirect('/fr/event/event/'.$event->getId().'/show')); + } + } From cf4a0d9e75542f122d26453198a489a473c7d2dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 19 Apr 2016 15:30:44 +0200 Subject: [PATCH 049/179] factorize PickRoleType, PickStatusType and rename TranslatableEventType --- Form/EventType.php | 4 +- Form/ParticipationType.php | 55 +------ ...latableEventType.php => PickEventType.php} | 5 +- Form/Type/PickRoleType.php | 144 ++++++++++++++++++ Form/Type/PickStatusType.php | 134 ++++++++++++++++ Resources/config/services/forms.yml | 22 ++- Resources/config/services/repositories.yml | 16 +- Resources/config/services/search.yml | 2 +- 8 files changed, 326 insertions(+), 56 deletions(-) rename Form/Type/{TranslatableEventType.php => PickEventType.php} (91%) create mode 100644 Form/Type/PickRoleType.php create mode 100644 Form/Type/PickStatusType.php diff --git a/Form/EventType.php b/Form/EventType.php index a3417a81e..2d4895efa 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -5,7 +5,7 @@ namespace Chill\EventBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; -use Chill\EventBundle\Form\Type\TranslatableEventType; +use Chill\EventBundle\Form\Type\PickEventType; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Doctrine\Common\Persistence\ObjectManager; @@ -107,7 +107,7 @@ class EventType extends AbstractType ); }, )) - ->add('type', TranslatableEventType::class) + ->add('type', PickEventType::class) ; } diff --git a/Form/ParticipationType.php b/Form/ParticipationType.php index 5b754dcf9..d7186ac91 100644 --- a/Form/ParticipationType.php +++ b/Form/ParticipationType.php @@ -26,8 +26,9 @@ use Chill\EventBundle\Entity\EventType; use Chill\EventBundle\Entity\Status; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Doctrine\ORM\EntityRepository; -use Chill\EventBundle\Entity\Role; use Chill\MainBundle\Templating\TranslatableStringHelper; +use Chill\EventBundle\Form\Type\PickRoleType; +use Chill\EventBundle\Form\Type\PickStatusType; /** * A type to create a participation @@ -55,55 +56,13 @@ class ParticipationType extends AbstractType $translatableStringHelper = $this->translatableStringHelper; // add role - $builder->add('role', EntityType::class, array( - 'class' => Role::class, - 'query_builder' => function (EntityRepository $er) use ($options) { - $qb = $er->createQueryBuilder('r'); - - if ($options['event_type'] instanceof EventType) { - $qb->where($qb->expr()->eq('r.type', ':event_type')) - ->setParameter('event_type', $options['event_type']); - } - - $qb->andWhere($qb->expr()->eq('r.active', ':active')) - ->setParameter('active', true); - - return $qb; - }, - 'choice_attr' => function(Role $r) { - return array( - 'data-event-type' => $r->getType()->getId() - ); - }, - 'choice_label' => function(Role $r) use ($translatableStringHelper) { - return $translatableStringHelper->localize($r->getName()); - } - )); + $builder->add('role', PickRoleType::class, array( + 'event_type' => $options['event_type'] + )); // add a status - $builder->add('status', EntityType::class, array( - 'class' => Status::class, - 'choice_attr' => function(Status $s) { - return array( - 'data-event-type' => $s->getType()->getId() - ); - }, - 'query_builder' => function (EntityRepository $er) use ($options) { - $qb = $er->createQueryBuilder('s'); - - if ($options['event_type'] instanceof EventType) { - $qb->where($qb->expr()->eq('s.type', ':event_type')) - ->setParameter('event_type', $options['event_type']); - } - - $qb->andWhere($qb->expr()->eq('s.active', ':active')) - ->setParameter('active', true); - - return $qb; - }, - 'choice_label' => function(Status $s) use ($translatableStringHelper) { - return $translatableStringHelper->localize($s->getName()); - } + $builder->add('status', PickStatusType::class, array( + 'event_type' => $options['event_type'] )); } diff --git a/Form/Type/TranslatableEventType.php b/Form/Type/PickEventType.php similarity index 91% rename from Form/Type/TranslatableEventType.php rename to Form/Type/PickEventType.php index 6b7a80d03..0d41fb2e3 100644 --- a/Form/Type/TranslatableEventType.php +++ b/Form/Type/PickEventType.php @@ -34,7 +34,7 @@ use Chill\EventBundle\Entity\EventType; * * @author Champs-Libres Coop */ -class TranslatableEventType extends AbstractType +class PickEventType extends AbstractType { /** * @var TranslatableStringHelper @@ -64,6 +64,9 @@ class TranslatableEventType extends AbstractType 'choice_label' => function (EventType $t) use ($helper) { return $helper->localize($t->getName()); }, + 'choice_attrs' => function (EventType $t) { + return array('data-link-category' => $t->getId()); + } ) ); } diff --git a/Form/Type/PickRoleType.php b/Form/Type/PickRoleType.php new file mode 100644 index 000000000..4ea4b46a2 --- /dev/null +++ b/Form/Type/PickRoleType.php @@ -0,0 +1,144 @@ +, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\EventBundle\Form\Type; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Chill\EventBundle\Entity\Role; +use Chill\EventBundle\Entity\EventType; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Doctrine\ORM\EntityRepository; + +/** + * Allow to pick a choice amongst different choices + * + * @author Julien Fastré + * @author Champs Libres + */ +class PickRoleType extends AbstractType +{ + + /** + * + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + /** + * + * @var TranslatorInterface + */ + protected $translator; + + /** + * + * @var EntityRepository + */ + protected $roleRepository; + + public function __construct( + TranslatableStringHelper $translatableStringHelper, + TranslatorInterface $translator, + EntityRepository $roleRepository + ) { + $this->translatableStringHelper = $translatableStringHelper; + $this->translator = $translator; + $this->roleRepository = $roleRepository; + } + + public function buildForm(FormBuilderInterface $builder, array $options) + { + // create copy for use in Closure + $translatableStringHelper = $this->translatableStringHelper; + // create copy for easier management + $qb = $options['query_builder']; + + if ($options['event_type'] instanceof EventType) { + $options['query_builder']->where($qb->expr()->eq('r.type', ':event_type')) + ->setParameter('event_type', $options['event_type']); + } + + if ($options['active_only'] === true) { + $options['query_builder']->andWhere($qb->expr()->eq('r.active', ':active')) + ->setParameter('active', true); + } + +// if ($options['show_group_type'] === true) { +// $closure = $options['choice_label']; +// $options['choice_label'] = function(Role $r) +// use ($translatableStringHelper, $closure) { +// return $translatableStringHelper->localize($r->get) +// +// } +// } + + + } + + public function configureOptions(OptionsResolver $resolver) + { + // create copy for use in Closure + $translatableStringHelper = $this->translatableStringHelper; + $translator = $this->translator; + + $resolver + // add option "event_type" + ->setDefined('event_type') + ->setAllowedTypes('event_type', array('null', EventType::class)) + ->setDefault('event_type', null) + // add option allow unactive + ->setDefault('active_only', true) + ->setAllowedTypes('active_only', array('boolean')) + // add possibility to prepend by group_type + ->setDefault('show_group_type', false) + ->setAllowedTypes('show_group_type', array('boolean')) + ; + + $qb = $this->roleRepository->createQueryBuilder('r'); + + $resolver->setDefaults(array( + 'class' => Role::class, + 'query_builder' => $qb, + 'choice_attr' => function(Role $r) { + return array( + 'data-event-type' => $r->getType()->getId(), + 'data-link-category' => $r->getType()->getId() + ); + }, + 'choice_label' => function(Role $r) + use ($translatableStringHelper, $translator) { + return $translatableStringHelper->localize($r->getName()). + ($r->getActive() === true ? '' : + ' ('.$translator->trans('unactive').')'); + } + )); + } + + public function getParent() + { + return EntityType::class; + } +} diff --git a/Form/Type/PickStatusType.php b/Form/Type/PickStatusType.php new file mode 100644 index 000000000..c4bde94e2 --- /dev/null +++ b/Form/Type/PickStatusType.php @@ -0,0 +1,134 @@ +, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\EventBundle\Form\Type; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Chill\EventBundle\Entity\Status; +use Chill\EventBundle\Entity\EventType; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Doctrine\ORM\EntityRepository; + +/** + * Allow to pick amongst type + * + * parameters : + * + * - event_type : restricts to a certain event type. Default null (= all event types) + * - active_only: restricts to active type only. Default true + * + * @author Julien Fastré + * @author Champs Libres + */ +class PickStatusType extends AbstractType +{ + + /** + * + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + /** + * + * @var TranslatorInterface + */ + protected $translator; + + /** + * + * @var EntityRepository + */ + protected $statusRepository; + + public function __construct( + TranslatableStringHelper $translatableStringHelper, + TranslatorInterface $translator, + EntityRepository $statusRepository + ) { + $this->translatableStringHelper = $translatableStringHelper; + $this->translator = $translator; + $this->statusRepository = $statusRepository; + } + + public function buildForm(FormBuilderInterface $builder, array $options) + { + $qb = $options['query_builder']; + + if ($options['event_type'] instanceof EventType) { + $options['query_builder']->where($qb->expr()->eq('r.type', ':event_type')) + ->setParameter('event_type', $options['event_type']); + + } + + if ($options['active_only'] === true) { + $options['query_builder']->andWhere($qb->expr()->eq('r.active', ':active')) + ->setParameter('active', true); + } + + + } + + public function configureOptions(OptionsResolver $resolver) + { + // create copy for use in Closure + $translatableStringHelper = $this->translatableStringHelper; + $translator = $this->translator; + + $resolver + // add option "event_type" + ->setDefined('event_type') + ->setAllowedTypes('event_type', array('null', EventType::class)) + ->setDefault('event_type', null) + // add option allow unactive + ->setDefault('active_only', true) + ->setAllowedTypes('active_only', array('boolean')) + ; + + $qb = $this->statusRepository->createQueryBuilder('r'); + + $resolver->setDefaults(array( + 'class' => Status::class, + 'query_builder' => $qb, + 'choice_attr' => function(Status $s) { + return array( + 'data-event-type' => $s->getType()->getId() + ); + }, + 'choice_label' => function(Status $s) + use ($translatableStringHelper, $translator) { + return $translatableStringHelper->localize($s->getName()). + ($s->getActive() === true ? '' : + ' ('.$translator->trans('unactive').')'); + } + )); + } + + public function getParent() + { + return EntityType::class; + } +} diff --git a/Resources/config/services/forms.yml b/Resources/config/services/forms.yml index 2f622a326..b587bac49 100644 --- a/Resources/config/services/forms.yml +++ b/Resources/config/services/forms.yml @@ -1,6 +1,6 @@ services: - chill.event.form.type.translatable_event_type: - class: Chill\EventBundle\Form\Type\TranslatableEventType + chill.event.form.type.pick_event_type: + class: Chill\EventBundle\Form\Type\PickEventType arguments: - "@chill.main.helper.translatable_string" tags: @@ -21,3 +21,21 @@ services: - "@chill.main.helper.translatable_string" tags: - { name: form.type } + + chill.event.form.pick_role_type: + class: Chill\EventBundle\Form\Type\PickRoleType + arguments: + - "@chill.main.helper.translatable_string" + - "@translator" + - "@chill_event.repository.role" + tags: + - { name: form.type } + + chill.event.form.pick_status_type: + class: Chill\EventBundle\Form\Type\PickStatusType + arguments: + - "@chill.main.helper.translatable_string" + - "@translator" + - "@chill_event.repository.status" + tags: + - { name: form.type } diff --git a/Resources/config/services/repositories.yml b/Resources/config/services/repositories.yml index 44e653cc0..d27130bcd 100644 --- a/Resources/config/services/repositories.yml +++ b/Resources/config/services/repositories.yml @@ -1,6 +1,18 @@ services: - chill_group.repository.event: + chill_event.repository.event: class: Doctrine\ORM\EntityRepository factory: ['@doctrine.orm.entity_manager', getRepository] arguments: - - 'Chill\EventBundle\Entity\Event' \ No newline at end of file + - 'Chill\EventBundle\Entity\Event' + + chill_event.repository.role: + class: Doctrine\ORM\EntityRepository + factory: ['@doctrine.orm.entity_manager', getRepository] + arguments: + - 'Chill\EventBundle\Entity\Role' + + chill_event.repository.status: + class: Doctrine\ORM\EntityRepository + factory: ['@doctrine.orm.entity_manager', getRepository] + arguments: + - 'Chill\EventBundle\Entity\Status' \ No newline at end of file diff --git a/Resources/config/services/search.yml b/Resources/config/services/search.yml index 99b455bae..a1e0b2f17 100644 --- a/Resources/config/services/search.yml +++ b/Resources/config/services/search.yml @@ -3,7 +3,7 @@ services: class: Chill\EventBundle\Search\EventSearch arguments: - "@security.token_storage" - - "@chill_group.repository.event" + - "@chill_event.repository.event" - "@chill.main.security.authorization.helper" - "@templating" tags: From e77409095914c2449831fdb49dfaccefd9833f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 19 Apr 2016 18:36:29 +0200 Subject: [PATCH 050/179] allow group_by in PickRoleType and PickStatusType --- Form/Type/PickRoleType.php | 39 +++++++++++++++++++++--------------- Form/Type/PickStatusType.php | 21 ++++++++++++++++++- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/Form/Type/PickRoleType.php b/Form/Type/PickRoleType.php index 4ea4b46a2..545892b98 100644 --- a/Form/Type/PickRoleType.php +++ b/Form/Type/PickRoleType.php @@ -31,6 +31,8 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Symfony\Component\Translation\TranslatorInterface; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Doctrine\ORM\EntityRepository; +use Symfony\Component\Form\FormEvent; +use Symfony\Component\Form\FormEvents; /** * Allow to pick a choice amongst different choices @@ -71,31 +73,38 @@ class PickRoleType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - // create copy for use in Closure - $translatableStringHelper = $this->translatableStringHelper; // create copy for easier management $qb = $options['query_builder']; if ($options['event_type'] instanceof EventType) { $options['query_builder']->where($qb->expr()->eq('r.type', ':event_type')) ->setParameter('event_type', $options['event_type']); - } + } if ($options['active_only'] === true) { $options['query_builder']->andWhere($qb->expr()->eq('r.active', ':active')) ->setParameter('active', true); } -// if ($options['show_group_type'] === true) { -// $closure = $options['choice_label']; -// $options['choice_label'] = function(Role $r) -// use ($translatableStringHelper, $closure) { -// return $translatableStringHelper->localize($r->get) -// -// } -// } - - + if ($options['group_by'] === null) { + $builder->addEventListener( + FormEvents::PRE_SET_DATA, + function(FormEvent $event) use ($options) { + if ($options['event_type'] === null) { + $form = $event->getForm(); + $name = $form->getName(); + $config = $form->getConfig(); + $type = $config->getType()->getName(); + $options = $config->getOptions(); + + $form->getParent()->add($name, $type, array_replace($options, array( + 'group_by' => function(Role $r) + { return $this->translatableStringHelper->localize($r->getType()->getName()); } + ))); + } + } + ); + } } public function configureOptions(OptionsResolver $resolver) @@ -112,9 +121,6 @@ class PickRoleType extends AbstractType // add option allow unactive ->setDefault('active_only', true) ->setAllowedTypes('active_only', array('boolean')) - // add possibility to prepend by group_type - ->setDefault('show_group_type', false) - ->setAllowedTypes('show_group_type', array('boolean')) ; $qb = $this->roleRepository->createQueryBuilder('r'); @@ -122,6 +128,7 @@ class PickRoleType extends AbstractType $resolver->setDefaults(array( 'class' => Role::class, 'query_builder' => $qb, + 'group_by' => null, 'choice_attr' => function(Role $r) { return array( 'data-event-type' => $r->getType()->getId(), diff --git a/Form/Type/PickStatusType.php b/Form/Type/PickStatusType.php index c4bde94e2..0557a0648 100644 --- a/Form/Type/PickStatusType.php +++ b/Form/Type/PickStatusType.php @@ -31,6 +31,8 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Symfony\Component\Translation\TranslatorInterface; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Doctrine\ORM\EntityRepository; +use Symfony\Component\Form\FormEvent; +use Symfony\Component\Form\FormEvents; /** * Allow to pick amongst type @@ -88,7 +90,23 @@ class PickStatusType extends AbstractType $options['query_builder']->andWhere($qb->expr()->eq('r.active', ':active')) ->setParameter('active', true); } - + + if ($options['group_by'] === null && $options['event_type'] === null) { + $builder->addEventListener( + FormEvents::PRE_SET_DATA, + function(FormEvent $event) { + $form = $event->getForm(); + $name = $form->getName(); + $config = $form->getConfig(); + $type = $config->getType()->getName(); + $options = $config->getOptions(); + $form->getParent()->add($name, $type, array_replace($options, array( + 'group_by' => function(Status $s) + { return $this->translatableStringHelper->localize($s->getType()->getName()); } + ))); + } + ); + } } @@ -113,6 +131,7 @@ class PickStatusType extends AbstractType $resolver->setDefaults(array( 'class' => Status::class, 'query_builder' => $qb, + 'group_by' => null, 'choice_attr' => function(Status $s) { return array( 'data-event-type' => $s->getType()->getId() From e723aeeeb4787f77a93b6df670fd890e15fc194f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 17 May 2016 09:20:27 +0200 Subject: [PATCH 051/179] [minor] add translation --- Resources/translations/messages.fr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 4af7a2b83..07f5ec9ce 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -37,6 +37,7 @@ Participation Edit: Modifier une participation 'The following people have been ignored because they are already participating on the event': '{1} La personne suivante a été ignorée parce qu''elle participe déjà à l''événement | ]1,Inf] Les personnes suivantes ont été ignorées parce qu''elles participent déjà à l''événement' There are no participation to edit for this event: Il n'y a pas de participation pour cet événement The participations have been successfully updated.: Les participations ont été mises à jour. +The participations were created: Les participations ont été créées #search Event search: Recherche d'événements From 54ac8d052f3ca82280e0d699ef412bff295d3d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 17 May 2016 20:41:03 +0200 Subject: [PATCH 052/179] fix bug on redirection when all required participation already exists When we request multiple participations on an event, and all people already participate on the event, the controller redirected to a route which provoked a bad request error. Now, we redirect to the view route. --- Controller/ParticipationController.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index ca2a5f953..1b23db177 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -156,18 +156,19 @@ class ParticipationController extends Controller { $participations = $this->handleRequest($request, new Participation()); + foreach ($participations as $i => $participation) { // check for authorization $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, $participation, 'The user is not allowed to create this participation'); - // check that the user is not already in the event (computing only once) + // create a collection of person's id participating to the event /* @var $peopleParticipating \Doctrine\Common\Collections\ArrayCollection */ $peopleParticipating = isset($peopleParticipating) ? $peopleParticipating : $participation->getEvent()->getParticipations()->map( function(Participation $p) { return $p->getPerson()->getId(); } ); - + // check that the user is not already in the event if ($peopleParticipating->contains($participation->getPerson()->getId())) { $ignoredParticipations[] = $participation ->getEvent()->getParticipations()->filter( @@ -184,10 +185,11 @@ class ParticipationController extends Controller if (!isset($newParticipations)) { // if we do not have nay participants, redirect to event view - $this->addFlash('error', 'Any of the requested people may be added ' - . 'on the event: they are maybe already participating.'); + $this->addFlash('error', $this->get('translator')->trans( + 'None of the requested people may participate ' + . 'the event: they are maybe already participating.')); - return $this->redirectToRoute('chill_event_participation_new', array( + return $this->redirectToRoute('chill_event__event_show', array( 'event_id' => $request->query->getInt('event_id', 0) )); } elseif (count($newParticipations) > 1) { From 5bcff0cba4c529150cb0f9c03dbbc9bbea34bc86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 17 May 2016 21:04:14 +0200 Subject: [PATCH 053/179] allow to add single participation with persons_ids --- Controller/ParticipationController.php | 20 ++++++++++++-------- Resources/translations/messages.fr.yml | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index 1b23db177..4c597a818 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -102,7 +102,7 @@ class ParticipationController extends Controller if ($multiple === true) { $persons_ids = $request->query->get('persons_ids'); - if (!preg_match('/^([0-9]{1,},){1,}[0-9]{1,}$/', $persons_ids)) { + if (!preg_match('/^([0-9]{1,},{0,1}){1,}[0-9]{0,}$/', $persons_ids)) { throw new \RuntimeException("The persons_ids value should " . "contains int separated by ','"); } @@ -123,7 +123,7 @@ class ParticipationController extends Controller */ protected function newSingle(Request $request) { - $participation = $this->handleRequest($request, new Participation()); + $participation = $this->handleRequest($request, new Participation(), false); $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, $participation, 'The user is not allowed to create this participation'); @@ -154,7 +154,7 @@ class ParticipationController extends Controller */ protected function newMultiple(Request $request) { - $participations = $this->handleRequest($request, new Participation()); + $participations = $this->handleRequest($request, new Participation(), true); foreach ($participations as $i => $participation) { @@ -249,7 +249,7 @@ class ParticipationController extends Controller public function createSingle(Request $request) { - $participation = $this->handleRequest($request, new Participation()); + $participation = $this->handleRequest($request, new Participation(), false); $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, $participation, 'The user is not allowed to create this participation'); @@ -280,7 +280,7 @@ class ParticipationController extends Controller public function createMultiple(Request $request) { - $participations = $this->handleRequest($request, new Participation()); + $participations = $this->handleRequest($request, new Participation(), true); foreach($participations as $participation) { $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, @@ -324,11 +324,15 @@ class ParticipationController extends Controller * * @param Request $request * @param Participation $participation - * @return Participation + * @param boolean $multiple (default false) + * @return Participation|Participations[] return one single participation if $multiple == false * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the event/person is not found * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException if the user does not have access to event/person */ - protected function handleRequest(Request $request, Participation $participation) + protected function handleRequest( + Request $request, + Participation $participation, + $multiple = false) { $em = $this->getDoctrine()->getManager(); if ($em->contains($participation)) { @@ -382,7 +386,7 @@ class ParticipationController extends Controller $participations[] = $participation; } - return count($participations) > 1 ? $participations : $participations[0]; + return $multiple ? $participations : $participations[0]; } /** diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 07f5ec9ce..0a38cf10b 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -33,7 +33,7 @@ Back to the event: Retour à l'événement The participation was created: La participation a été créée The participation was updated: La participation a été mise à jour Participation Edit: Modifier une participation -'Any of the requested people may be added on the event: they are maybe already participating.': 'Aucune des personnes suggérées ne peut être ajoutée à l''événement: elles sont peut-être déjà inscrites comme participantes.' +'None of the requested people may participate the event: they are maybe already participating.': 'Aucune des personnes indiquées ne peut être ajoutée à l''événement: elles sont peut-être déjà inscrites comme participantes.' 'The following people have been ignored because they are already participating on the event': '{1} La personne suivante a été ignorée parce qu''elle participe déjà à l''événement | ]1,Inf] Les personnes suivantes ont été ignorées parce qu''elles participent déjà à l''événement' There are no participation to edit for this event: Il n'y a pas de participation pour cet événement The participations have been successfully updated.: Les participations ont été mises à jour. From ca2d4db6f93ea2af30e87e5480ac57a4b50ee78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 17 May 2016 21:33:10 +0200 Subject: [PATCH 054/179] add search within event name, date, date-from, date-to ref #10 --- Search/EventSearch.php | 46 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/Search/EventSearch.php b/Search/EventSearch.php index c2b4e4e80..882dd2a77 100644 --- a/Search/EventSearch.php +++ b/Search/EventSearch.php @@ -13,6 +13,17 @@ use Symfony\Component\Security\Core\Role\Role; /** * Search within Events. + * + * available terms : + * - name: to search within the name + * - date: search the event at a the given date + * - date-from: search the event after the given date + * - date-to : search the event before the given date + * + * Default terms search within the name, but the term "name" has precedence. This + * means that if the search string is `@event xyz name:"abc"`, the searched + * string will be "abc" and not xyz + * * * @author Julien Fastré * @author Champs Libres @@ -65,7 +76,7 @@ class EventSearch extends AbstractSearch public function isActiveByDefault() { - return false; + return true; } public function getOrder() @@ -136,6 +147,39 @@ class EventSearch extends AbstractSearch $qb->andWhere($orWhere); } + if (isset($terms['name']) OR isset($terms['_default'])) { + // the form with name:"xyz" has precedence + $name = isset($terms['name']) ? $terms['name'] : $terms['_default']; + + $where = $qb->expr()->like('UNACCENT(LOWER(e.name))', ':name'); + $qb->setParameter('name', '%'.$name.'%'); + $qb->andWhere($where); + } + + if (isset($terms['date'])) { + $date = $this->parseDate($terms['date']); + + $where = $qb->expr()->eq('e.date', ':date'); + $qb->setParameter('date', $date); + $qb->andWhere($where); + } + + if (isset($terms['date-from'])) { + $date = $this->parseDate($terms['date-from']); + + $where = $qb->expr()->gte('e.date', ':datefrom'); + $qb->setParameter('datefrom', $date); + $qb->andWhere($where); + } + + if (isset($terms['date-to'])) { + $date = $this->parseDate($terms['date-to']); + + $where = $qb->expr()->lte('e.date', ':dateto'); + $qb->setParameter('dateto', $date); + $qb->andWhere($where); + } + return $qb; From 329d688b5a2e043c0abf1cfd4d79c40bb711396c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 27 May 2016 15:44:28 +0200 Subject: [PATCH 055/179] adding a link to event types for link parent/categories --- Form/Type/PickStatusType.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Form/Type/PickStatusType.php b/Form/Type/PickStatusType.php index 0557a0648..b4f40b7be 100644 --- a/Form/Type/PickStatusType.php +++ b/Form/Type/PickStatusType.php @@ -134,7 +134,8 @@ class PickStatusType extends AbstractType 'group_by' => null, 'choice_attr' => function(Status $s) { return array( - 'data-event-type' => $s->getType()->getId() + 'data-event-type' => $s->getType()->getId(), + 'data-link-category' => $s->getType()->getId() ); }, 'choice_label' => function(Status $s) From 9be006a9466b8cfe7e112ac78d01afdcaa8ffe28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 27 May 2016 17:15:54 +0200 Subject: [PATCH 056/179] fix error in recompose pattern --- Search/EventSearch.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Search/EventSearch.php b/Search/EventSearch.php index 882dd2a77..62f4e1604 100644 --- a/Search/EventSearch.php +++ b/Search/EventSearch.php @@ -89,11 +89,16 @@ class EventSearch extends AbstractSearch return $this->templating->render('ChillEventBundle:Event:list.html.twig', array( 'events' => $this->search($terms, $start, $limit, $options), - 'pattern' => $this->recomposePattern($terms, array(), $terms['_domain']), + 'pattern' => $this->recomposePattern($terms, $this->getAvailableTerms(), $terms['_domain']), 'total' => $this->count($terms) )); } + protected function getAvailableTerms() + { + return array('date-from', 'date-to', 'name', 'date'); + } + protected function search(array $terms, $start, $limit, $options) { $qb = $this->er->createQueryBuilder('e'); From 69af3e8d43a53422b311984c1994bbbb19a2432e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 31 May 2016 17:30:35 +0200 Subject: [PATCH 057/179] add test to eventSearch ref #10 --- Resources/views/Event/list.html.twig | 2 +- Search/EventSearch.php | 5 +- Tests/Search/EventSearchTest.php | 276 +++++++++++++++++++++++++++ 3 files changed, 281 insertions(+), 2 deletions(-) create mode 100644 Tests/Search/EventSearchTest.php diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig index 0c98cb027..10d274e2d 100644 --- a/Resources/views/Event/list.html.twig +++ b/Resources/views/Event/list.html.twig @@ -4,7 +4,7 @@ {% if events|length > 0 %} - +
                                        diff --git a/Search/EventSearch.php b/Search/EventSearch.php index 62f4e1604..d04d0e3eb 100644 --- a/Search/EventSearch.php +++ b/Search/EventSearch.php @@ -152,7 +152,10 @@ class EventSearch extends AbstractSearch $qb->andWhere($orWhere); } - if (isset($terms['name']) OR isset($terms['_default'])) { + if ( + (isset($terms['name']) OR isset($terms['_default'])) + AND + (!empty($terms['name']) OR !empty($terms['_default']))) { // the form with name:"xyz" has precedence $name = isset($terms['name']) ? $terms['name'] : $terms['_default']; diff --git a/Tests/Search/EventSearchTest.php b/Tests/Search/EventSearchTest.php new file mode 100644 index 000000000..ab5e732c9 --- /dev/null +++ b/Tests/Search/EventSearchTest.php @@ -0,0 +1,276 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\EventBundle\Tests\Search; + +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Chill\EventBundle\Entity\Event; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Chill\EventBundle\Search\EventSearch; + + +/** + * Test the EventSearch class + * + * @author Julien Fastré + */ +class EventSearchTest extends WebTestCase +{ + /** + * The eventSearch service, which is used to search events + * + * @var \Chill\EventBundle\Search\EventSearch + */ + protected $eventSearch; + + /** + * + * @var \Doctrine\ORM\EntityManagerInterface + */ + protected $entityManager; + + /** + * The center A + * + * @var \Chill\MainBundle\Entity\Center + */ + protected $centerA; + + /** + * a random event type + * + * @var \Chill\EventBundle\Entity\EventType + */ + protected $eventType; + + /** + * Events created during this test + * + * @var Event[] + */ + protected $events = array(); + + /** + * + * @var \Prophecy\Prophet + */ + protected $prophet; + + /** + * + * @var \Symfony\Component\BrowserKit\Client + */ + protected $client; + + public function setUp() + { + self::bootKernel(); + /* @var $kernel \Symfony\Component\HttpKernel\KernelInterface */ + $kernel = self::$kernel; + + $this->client = static::createClient(array(), array( + 'PHP_AUTH_USER' => 'center a_social', + 'PHP_AUTH_PW' => 'password', + 'HTTP_ACCEPT_LANGUAGE' => 'fr_FR' + )); + + $this->prophet = new \Prophecy\Prophet; + + $this->entityManager = self::$kernel->getContainer() + ->get('doctrine.orm.entity_manager') + ; + + $this->centerA = $this->entityManager + ->getRepository('ChillMainBundle:Center') + ->findOneBy(array('name' => 'Center A')); + + $this->eventType = $this->entityManager + ->getRepository('ChillEventBundle:EventType') + ->findAll()[0]; + + $this->createEvents(); + } + + public function tearDown() + { + foreach ($this->events as $event) { + $this->entityManager->createQuery('DELETE FROM ChillEventBundle:Event e WHERE e.id = :event_id') + ->setParameter('event_id', $event->getId()) + ->execute(); + } + + $this->events = array(); + } + + protected function createEvents() + { + $event1 = (new Event()) + ->setCenter($this->centerA) + ->setDate(new \DateTime('2016-05-30')) + ->setName('Printemps européen') + ->setType($this->eventType) + ->setCircle($this->getCircle()) + ; + $this->entityManager->persist($event1); + $this->events[] = $event1; + + $event2 = (new Event()) + ->setCenter($this->centerA) + ->setDate(new \DateTime('2016-06-24')) + ->setName('Hiver de la droite') + ->setType($this->eventType) + ->setCircle($this->getCircle()) + ; + $this->entityManager->persist($event2); + $this->events[] = $event2; + + $this->entityManager->flush(); + } + + /** + * + * @param string $name the name of the circle + * @return \Chill\MainBundle\Entity\Scope + */ + protected function getCircle($name = 'social') + { + $circles = $this->entityManager->getRepository('ChillMainBundle:Scope') + ->findAll(); + + /* @var $circle \Chill\MainBundle\Entity\Scope */ + foreach($circles as $circle) { + if (in_array($name, $circle->getName())) { + return $circle; + } + } + } + + public function testDisplayAll() + { + $crawler = $this->client->request('GET', '/fr/search', array( + 'q' => '@events' + )); + + $this->assertGreaterThan(2, $crawler->filter('table.events tr')->count(), + 'assert than more than 2 tr are present'); + } + + public function testSearchByDefault() + { + $crawler = $this->client->request('GET', '/fr/search', array( + 'q' => '@events printemps' + )); + + $this->assertEquals( + 1, + $crawler->filter('table.events tr')->count() - 1 /* as the header is a th */, + 'assert than more than 2 tr are present'); + + $this->assertEquals( + 1, + $crawler->filter('tr:contains("Printemps")')->count(), + 'assert that the word "printemps" is present'); + } + + public function testSearchByName() + { + $crawler = $this->client->request('GET', '/fr/search', array( + 'q' => '@events name:printemps' + )); + + $this->assertEquals( + 1, + $crawler->filter('table.events tr')->count() - 1 /* as the header is a th */, + 'assert than more than 2 tr are present'); + + $this->assertEquals( + 1, + $crawler->filter('tr:contains("Printemps")')->count(), + 'assert that the word "printemps" is present'); + } + + public function testSearchByDate() + { + // search with date from + $crawler = $this->client->request('GET', '/fr/search', array( + 'q' => '@events date-from:2016-05-30' + )); + + $this->assertEquals( + 1, + $crawler->filter('tr:contains("Printemps")')->count(), + 'assert that the word "printemps" is present'); + $this->assertEquals( + 1, + $crawler->filter('tr:contains("Hiver")')->count(), + 'assert that the word "Hiver" is present'); + + // serach with date from **and** date-to + $crawler = $this->client->request('GET', '/fr/search', array( + 'q' => '@events date-from:2016-05-30 date-to:2016-06-20' + )); + + $this->assertEquals( + 1, + $crawler->filter('tr:contains("Printemps")')->count(), + 'assert that the word "printemps" is present'); + $this->assertEquals( + 0, + $crawler->filter('tr:contains("Hiver")')->count(), + 'assert that the word "Hiver" is not present'); + + // serach with date from **and** date-to + $crawler = $this->client->request('GET', '/fr/search', array( + 'q' => '@events date:2016-05-30' + )); + + $this->assertEquals( + 1, + $crawler->filter('tr:contains("Printemps")')->count(), + 'assert that the word "printemps" is present'); + $this->assertEquals( + 0, + $crawler->filter('tr:contains("Hiver")')->count(), + 'assert that the word "Hiver" is not present'); + } + + /** + * Test that a user connected with an user with the wrong center does not + * see the events + */ + public function testDisplayAllWrongUser() + { + $client = static::createClient(array(), array( + 'PHP_AUTH_USER' => 'center b_social', + 'PHP_AUTH_PW' => 'password', + 'HTTP_ACCEPT_LANGUAGE' => 'fr_FR' + )); + + $crawler = $client->request('GET', '/fr/search', array( + 'q' => '@events printemps' + )); + + $this->assertEquals(0, $crawler->filter('tr:contains("Printemps")')->count(), + 'assert that the word "printemps" is present'); + + } + + + +} From c8fcab4d1d8ba909391967f84229c8bfcfb854cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 10 Jun 2016 17:07:34 +0200 Subject: [PATCH 058/179] fix routes and translatable string in admin prototype ref #12 ref #13 ref #14 ref #15 --- Controller/EventTypeController.php | 16 ++++++++++------ Controller/RoleController.php | 19 +++++++++++-------- Controller/StatusController.php | 12 ++++++------ Form/EventTypeType.php | 3 ++- Form/RoleType.php | 23 +++++++++++++++++++++-- Form/StatusType.php | 6 ++++-- Resources/config/routing/eventtype.yml | 14 +++++++------- Resources/config/routing/status.yml | 14 +++++++------- Resources/config/services/forms.yml | 7 +++++++ Resources/views/EventType/edit.html.twig | 2 +- Resources/views/EventType/index.html.twig | 10 +++++----- Resources/views/EventType/new.html.twig | 2 +- Resources/views/EventType/show.html.twig | 6 +++--- Resources/views/Role/edit.html.twig | 2 +- Resources/views/Role/index.html.twig | 10 +++++----- Resources/views/Role/new.html.twig | 2 +- Resources/views/Role/show.html.twig | 6 +++--- Resources/views/Status/edit.html.twig | 2 +- Resources/views/Status/index.html.twig | 10 +++++----- Resources/views/Status/new.html.twig | 2 +- Resources/views/Status/show.html.twig | 6 +++--- 21 files changed, 105 insertions(+), 69 deletions(-) diff --git a/Controller/EventTypeController.php b/Controller/EventTypeController.php index cbe28999b..760594600 100644 --- a/Controller/EventTypeController.php +++ b/Controller/EventTypeController.php @@ -44,7 +44,8 @@ class EventTypeController extends Controller $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('{_locale}_admin_show', array('id' => $entity->getId()))); + return $this->redirect($this->generateUrl('chill_eventtype_admin_show', + array('id' => $entity->getId()))); } return $this->render('ChillEventBundle:EventType:new.html.twig', array( @@ -63,7 +64,7 @@ class EventTypeController extends Controller private function createCreateForm(EventType $entity) { $form = $this->createForm(new EventTypeType(), $entity, array( - 'action' => $this->generateUrl('{_locale}_admin_create'), + 'action' => $this->generateUrl('chill_eventtype_admin_create'), 'method' => 'POST', )); @@ -143,7 +144,8 @@ class EventTypeController extends Controller private function createEditForm(EventType $entity) { $form = $this->createForm(new EventTypeType(), $entity, array( - 'action' => $this->generateUrl('{_locale}_admin_update', array('id' => $entity->getId())), + 'action' => $this->generateUrl('chill_eventtype_admin_update', + array('id' => $entity->getId())), 'method' => 'PUT', )); @@ -172,7 +174,8 @@ class EventTypeController extends Controller if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('{_locale}_admin_edit', array('id' => $id))); + return $this->redirect($this->generateUrl('chill_eventtype_admin_edit', + array('id' => $id))); } return $this->render('ChillEventBundle:EventType:edit.html.twig', array( @@ -202,7 +205,7 @@ class EventTypeController extends Controller $em->flush(); } - return $this->redirect($this->generateUrl('{_locale}_admin')); + return $this->redirect($this->generateUrl('chill_eventtype_admin')); } /** @@ -215,7 +218,8 @@ class EventTypeController extends Controller private function createDeleteForm($id) { return $this->createFormBuilder() - ->setAction($this->generateUrl('{_locale}_admin_delete', array('id' => $id))) + ->setAction($this->generateUrl('chill_eventtype_admin_delete', + array('id' => $id))) ->setMethod('DELETE') ->add('submit', 'submit', array('label' => 'Delete')) ->getForm() diff --git a/Controller/RoleController.php b/Controller/RoleController.php index 3834e89a9..b1c560292 100644 --- a/Controller/RoleController.php +++ b/Controller/RoleController.php @@ -44,7 +44,8 @@ class RoleController extends Controller $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('{_locale}_admin_role_show', array('id' => $entity->getId()))); + return $this->redirect($this->generateUrl('chill_event_admin_role_show', + array('id' => $entity->getId()))); } return $this->render('ChillEventBundle:Role:new.html.twig', array( @@ -62,8 +63,8 @@ class RoleController extends Controller */ private function createCreateForm(Role $entity) { - $form = $this->createForm(new RoleType(), $entity, array( - 'action' => $this->generateUrl('{_locale}_admin_role_create'), + $form = $this->createForm($this->get('chill.event.form.role_type'), $entity, array( + 'action' => $this->generateUrl('chill_event_admin_role_create'), 'method' => 'POST', )); @@ -142,8 +143,9 @@ class RoleController extends Controller */ private function createEditForm(Role $entity) { - $form = $this->createForm(new RoleType(), $entity, array( - 'action' => $this->generateUrl('{_locale}_admin_role_update', array('id' => $entity->getId())), + $form = $this->createForm($this->get('chill.event.form.role_type'), $entity, array( + 'action' => $this->generateUrl('chill_event_admin_role_update', + array('id' => $entity->getId())), 'method' => 'PUT', )); @@ -172,7 +174,8 @@ class RoleController extends Controller if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('{_locale}_admin_role_edit', array('id' => $id))); + return $this->redirect($this->generateUrl('chill_event_admin_role_edit', + array('id' => $id))); } return $this->render('ChillEventBundle:Role:edit.html.twig', array( @@ -202,7 +205,7 @@ class RoleController extends Controller $em->flush(); } - return $this->redirect($this->generateUrl('{_locale}_admin_role')); + return $this->redirect($this->generateUrl('chill_event_admin_role')); } /** @@ -215,7 +218,7 @@ class RoleController extends Controller private function createDeleteForm($id) { return $this->createFormBuilder() - ->setAction($this->generateUrl('{_locale}_admin_role_delete', array('id' => $id))) + ->setAction($this->generateUrl('chill_event_admin_role_delete', array('id' => $id))) ->setMethod('DELETE') ->add('submit', 'submit', array('label' => 'Delete')) ->getForm() diff --git a/Controller/StatusController.php b/Controller/StatusController.php index e0a57ba51..211153b94 100644 --- a/Controller/StatusController.php +++ b/Controller/StatusController.php @@ -44,7 +44,7 @@ class StatusController extends Controller $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('fr_admin_event_status_show', array('id' => $entity->getId()))); + return $this->redirect($this->generateUrl('chill_event_admin_status_show', array('id' => $entity->getId()))); } return $this->render('ChillEventBundle:Status:new.html.twig', array( @@ -63,7 +63,7 @@ class StatusController extends Controller private function createCreateForm(Status $entity) { $form = $this->createForm(new StatusType(), $entity, array( - 'action' => $this->generateUrl('fr_admin_event_status_create'), + 'action' => $this->generateUrl('chill_event_admin_status_create'), 'method' => 'POST', )); @@ -143,7 +143,7 @@ class StatusController extends Controller private function createEditForm(Status $entity) { $form = $this->createForm(new StatusType(), $entity, array( - 'action' => $this->generateUrl('fr_admin_event_status_update', array('id' => $entity->getId())), + 'action' => $this->generateUrl('chill_event_admin_status_update', array('id' => $entity->getId())), 'method' => 'PUT', )); @@ -172,7 +172,7 @@ class StatusController extends Controller if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('fr_admin_event_status_edit', array('id' => $id))); + return $this->redirect($this->generateUrl('chill_event_admin_status_edit', array('id' => $id))); } return $this->render('ChillEventBundle:Status:edit.html.twig', array( @@ -202,7 +202,7 @@ class StatusController extends Controller $em->flush(); } - return $this->redirect($this->generateUrl('fr_admin_event_status')); + return $this->redirect($this->generateUrl('chill_event_admin_status')); } /** @@ -215,7 +215,7 @@ class StatusController extends Controller private function createDeleteForm($id) { return $this->createFormBuilder() - ->setAction($this->generateUrl('fr_admin_event_status_delete', array('id' => $id))) + ->setAction($this->generateUrl('chill_event_admin_status_delete', array('id' => $id))) ->setMethod('DELETE') ->add('submit', 'submit', array('label' => 'Delete')) ->getForm() diff --git a/Form/EventTypeType.php b/Form/EventTypeType.php index 9616f9f59..b72a9f186 100644 --- a/Form/EventTypeType.php +++ b/Form/EventTypeType.php @@ -5,6 +5,7 @@ namespace Chill\EventBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Chill\MainBundle\Form\Type\TranslatableStringFormType; class EventTypeType extends AbstractType { @@ -15,7 +16,7 @@ class EventTypeType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('name') + ->add('name', TranslatableStringFormType::class) ->add('active') ; } diff --git a/Form/RoleType.php b/Form/RoleType.php index 4f8fb3c53..d3483e917 100644 --- a/Form/RoleType.php +++ b/Form/RoleType.php @@ -5,9 +5,23 @@ namespace Chill\EventBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Chill\MainBundle\Form\Type\TranslatableStringFormType; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Chill\EventBundle\Entity\EventType; class RoleType extends AbstractType { + /** + * + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + public function __construct(TranslatableStringHelper $translatableStringHelper) { + $this->translatableStringHelper = $translatableStringHelper; + } + /** * @param FormBuilderInterface $builder * @param array $options @@ -15,9 +29,14 @@ class RoleType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('name') + ->add('name', TranslatableStringFormType::class) ->add('active') - ->add('type') + ->add('type', EntityType::class, array( + 'class' => EventType::class, + 'choice_label' => function (EventType $e) { + return $this->translatableStringHelper->localize($e->getName()); + } + )) ; } diff --git a/Form/StatusType.php b/Form/StatusType.php index 1bef97168..d02b21781 100644 --- a/Form/StatusType.php +++ b/Form/StatusType.php @@ -5,6 +5,8 @@ namespace Chill\EventBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Chill\MainBundle\Form\Type\TranslatableStringFormType; +use Chill\EventBundle\Form\Type\PickEventType; class StatusType extends AbstractType { @@ -15,9 +17,9 @@ class StatusType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('name') + ->add('name', TranslatableStringFormType::class) ->add('active') - ->add('type') + ->add('type', PickEventType::class) ; } diff --git a/Resources/config/routing/eventtype.yml b/Resources/config/routing/eventtype.yml index cdf54fe85..305c27af8 100644 --- a/Resources/config/routing/eventtype.yml +++ b/Resources/config/routing/eventtype.yml @@ -1,30 +1,30 @@ -chill_event_admin: +chill_eventtype_admin: path: / defaults: { _controller: "ChillEventBundle:EventType:index" } -chill_event_admin_show: +chill_eventtype_admin_show: path: /{id}/show defaults: { _controller: "ChillEventBundle:EventType:show" } -chill_event_admin_new: +chill_eventtype_admin_new: path: /new defaults: { _controller: "ChillEventBundle:EventType:new" } -chill_event_admin_create: +chill_eventtype_admin_create: path: /create defaults: { _controller: "ChillEventBundle:EventType:create" } methods: POST -chill_event_admin_edit: +chill_eventtype_admin_edit: path: /{id}/edit defaults: { _controller: "ChillEventBundle:EventType:edit" } -chill_event_admin_update: +chill_eventtype_admin_update: path: /{id}/update defaults: { _controller: "ChillEventBundle:EventType:update" } methods: [POST, PUT] -chill_event_admin_delete: +chill_eventtype_admin_delete: path: /{id}/delete defaults: { _controller: "ChillEventBundle:EventType:delete" } methods: [POST, DELETE] diff --git a/Resources/config/routing/status.yml b/Resources/config/routing/status.yml index 396f72c39..383a704ff 100644 --- a/Resources/config/routing/status.yml +++ b/Resources/config/routing/status.yml @@ -1,30 +1,30 @@ -fr_admin_event_status: +chill_event_admin_status: path: / defaults: { _controller: "ChillEventBundle:Status:index" } -fr_admin_event_status_show: +chill_event_admin_status_show: path: /{id}/show defaults: { _controller: "ChillEventBundle:Status:show" } -fr_admin_event_status_new: +chill_event_admin_status_new: path: /new defaults: { _controller: "ChillEventBundle:Status:new" } -fr_admin_event_status_create: +chill_event_admin_status_create: path: /create defaults: { _controller: "ChillEventBundle:Status:create" } methods: POST -fr_admin_event_status_edit: +chill_event_admin_status_edit: path: /{id}/edit defaults: { _controller: "ChillEventBundle:Status:edit" } -fr_admin_event_status_update: +chill_event_admin_status_update: path: /{id}/update defaults: { _controller: "ChillEventBundle:Status:update" } methods: [POST, PUT] -fr_admin_event_status_delete: +chill_event_admin_status_delete: path: /{id}/delete defaults: { _controller: "ChillEventBundle:Status:delete" } methods: [POST, DELETE] diff --git a/Resources/config/services/forms.yml b/Resources/config/services/forms.yml index b587bac49..90981d31b 100644 --- a/Resources/config/services/forms.yml +++ b/Resources/config/services/forms.yml @@ -39,3 +39,10 @@ services: - "@chill_event.repository.status" tags: - { name: form.type } + + chill.event.form.role_type: + class: Chill\EventBundle\Form\RoleType + arguments: + - "@chill.main.helper.translatable_string" + tags: + - { name: form.type } diff --git a/Resources/views/EventType/edit.html.twig b/Resources/views/EventType/edit.html.twig index 5849fa686..92bf5a236 100644 --- a/Resources/views/EventType/edit.html.twig +++ b/Resources/views/EventType/edit.html.twig @@ -7,7 +7,7 @@
                                        • - + Back to the list
                                        • diff --git a/Resources/views/EventType/index.html.twig b/Resources/views/EventType/index.html.twig index b40ce7b0f..669384172 100644 --- a/Resources/views/EventType/index.html.twig +++ b/Resources/views/EventType/index.html.twig @@ -15,16 +15,16 @@
                                        {% for entity in entities %} - - + + @@ -35,7 +35,7 @@
                                        • - + Create a new entry
                                        • diff --git a/Resources/views/EventType/new.html.twig b/Resources/views/EventType/new.html.twig index 4e097dd92..69a8f2638 100644 --- a/Resources/views/EventType/new.html.twig +++ b/Resources/views/EventType/new.html.twig @@ -7,7 +7,7 @@
                                          • - + Back to the list
                                          • diff --git a/Resources/views/EventType/show.html.twig b/Resources/views/EventType/show.html.twig index 3e748ca85..df2712898 100644 --- a/Resources/views/EventType/show.html.twig +++ b/Resources/views/EventType/show.html.twig @@ -11,7 +11,7 @@
                                        - + @@ -22,12 +22,12 @@
                                        • - + Back to the list
                                        • - + Edit
                                        • diff --git a/Resources/views/Role/edit.html.twig b/Resources/views/Role/edit.html.twig index 1bf9dc66d..021c810d6 100644 --- a/Resources/views/Role/edit.html.twig +++ b/Resources/views/Role/edit.html.twig @@ -7,7 +7,7 @@
                                          • - + Back to the list
                                          • diff --git a/Resources/views/Role/index.html.twig b/Resources/views/Role/index.html.twig index b6dd692bc..5ac43d05e 100644 --- a/Resources/views/Role/index.html.twig +++ b/Resources/views/Role/index.html.twig @@ -15,16 +15,16 @@
                                        {% for entity in entities %} - - + + @@ -35,7 +35,7 @@
                                        • - + Create a new entry
                                        • diff --git a/Resources/views/Role/new.html.twig b/Resources/views/Role/new.html.twig index a9ea41a1b..fd3c82044 100644 --- a/Resources/views/Role/new.html.twig +++ b/Resources/views/Role/new.html.twig @@ -7,7 +7,7 @@
                                          • - + Back to the list
                                          • diff --git a/Resources/views/Role/show.html.twig b/Resources/views/Role/show.html.twig index 99207becc..5a6956e76 100644 --- a/Resources/views/Role/show.html.twig +++ b/Resources/views/Role/show.html.twig @@ -11,7 +11,7 @@
                                        - + @@ -22,12 +22,12 @@
                                        • - + Back to the list
                                        • - + Edit
                                        • diff --git a/Resources/views/Status/edit.html.twig b/Resources/views/Status/edit.html.twig index f9c2f7bda..8c610c130 100644 --- a/Resources/views/Status/edit.html.twig +++ b/Resources/views/Status/edit.html.twig @@ -7,7 +7,7 @@
                                          • - + Back to the list
                                          • diff --git a/Resources/views/Status/index.html.twig b/Resources/views/Status/index.html.twig index 67d138ce9..38f34f955 100644 --- a/Resources/views/Status/index.html.twig +++ b/Resources/views/Status/index.html.twig @@ -15,16 +15,16 @@
                                        {% for entity in entities %} - - + + @@ -35,7 +35,7 @@
                                        • - + Create a new entry
                                        • diff --git a/Resources/views/Status/new.html.twig b/Resources/views/Status/new.html.twig index 7cd7093b1..bd2d824fa 100644 --- a/Resources/views/Status/new.html.twig +++ b/Resources/views/Status/new.html.twig @@ -7,7 +7,7 @@
                                          • - + Back to the list
                                          • diff --git a/Resources/views/Status/show.html.twig b/Resources/views/Status/show.html.twig index 2b56d32eb..8aa32d1a2 100644 --- a/Resources/views/Status/show.html.twig +++ b/Resources/views/Status/show.html.twig @@ -11,7 +11,7 @@
                                        - + @@ -22,12 +22,12 @@
                                        • - + Back to the list
                                        • - + Edit
                                        • From 2a10929d36e7bddc68c304ebd3492471e853310c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 19 Aug 2016 21:35:41 +0200 Subject: [PATCH 059/179] implementing the pagination api and the search preview --- Resources/config/services/search.yml | 1 + Resources/views/Event/list.html.twig | 13 +++++++++++++ Search/EventSearch.php | 25 ++++++++++++++++++++++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Resources/config/services/search.yml b/Resources/config/services/search.yml index a1e0b2f17..2df3db26f 100644 --- a/Resources/config/services/search.yml +++ b/Resources/config/services/search.yml @@ -6,6 +6,7 @@ services: - "@chill_event.repository.event" - "@chill.main.security.authorization.helper" - "@templating" + - "@chill_main.paginator_factory" tags: - { name: chill.search, alias: 'event_regular' } diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig index 10d274e2d..6da14a82f 100644 --- a/Resources/views/Event/list.html.twig +++ b/Resources/views/Event/list.html.twig @@ -2,6 +2,7 @@

                                          {% transchoice total with { '%pattern%' : pattern } %}%total% events match the search %pattern%{% endtranschoice %}

                                          +

                                          {{ 'Results %start%-%end% of %total%'|trans({ '%start%' : start, '%end%': start + events|length, '%total%' : total } ) }}

                                          {% if events|length > 0 %}
                                        {{ 'Name'|trans }}
                                        {{ entity.id }}{{ entity.name }}{{ entity.id }}{{ entity.name|localize_translatable_string }} {{ entity.active }}
                                        Name{{ entity.name }}{{ entity.name|localize_translatable_string }}
                                        Active
                                        {{ entity.id }}{{ entity.name }}{{ entity.id }}{{ entity.name|localize_translatable_string }} {{ entity.active }}
                                        Name{{ entity.name }}{{ entity.name|localize_translatable_string }}
                                        Active
                                        {{ entity.id }}{{ entity.name }}{{ entity.id }}{{ entity.name|localize_translatable_string }} {{ entity.active }}
                                        Name{{ entity.name }}{{ entity.name|localize_translatable_string }}
                                        Active
                                        @@ -48,5 +49,17 @@ {{ 'New event'|trans }} + + {% if preview == true and events|length < total %} +
                                      • + + {{ 'See all results'|trans }} +
                                      • + {% endif %} + + +{% if preview == false %} +{{ chill_pagination(paginator) }} +{% endif %} diff --git a/Search/EventSearch.php b/Search/EventSearch.php index d04d0e3eb..baf379a5d 100644 --- a/Search/EventSearch.php +++ b/Search/EventSearch.php @@ -10,6 +10,8 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Symfony\Component\Templating\EngineInterface as TemplatingEngine; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Security\Core\Role\Role; +use Chill\MainBundle\Pagination\PaginatorFactory; +use Chill\MainBundle\Search\SearchInterface; /** * Search within Events. @@ -55,18 +57,27 @@ class EventSearch extends AbstractSearch */ private $templating; + /** + * + * @var PaginatorFactory + */ + private $paginationFactory; + + const NAME = 'event_regular'; public function __construct( TokenStorageInterface $tokenStorage, EntityRepository $eventRepository, AuthorizationHelper $authorizationHelper, - TemplatingEngine $templating + TemplatingEngine $templating, + PaginatorFactory $paginatorFactory ) { $this->user = $tokenStorage->getToken()->getUser(); $this->er = $eventRepository; $this->helper = $authorizationHelper; $this->templating = $templating; + $this->paginationFactory = $paginatorFactory; } public function supports($domain) @@ -84,13 +95,21 @@ class EventSearch extends AbstractSearch return 3000; } - public function renderResult(array $terms, $start = 0, $limit = 50, array $options = array()) + public function renderResult(array $terms, $start = 0, $limit = 50, + array $options = array()) { + $total = $this->count($terms); + $paginator = $this->paginationFactory->create($total); + return $this->templating->render('ChillEventBundle:Event:list.html.twig', array( 'events' => $this->search($terms, $start, $limit, $options), 'pattern' => $this->recomposePattern($terms, $this->getAvailableTerms(), $terms['_domain']), - 'total' => $this->count($terms) + 'total' => $total, + 'start' => $start, + 'preview' => $options[SearchInterface::SEARCH_PREVIEW], + 'paginator' => $paginator, + 'search_name' => self::NAME )); } From 82b0fad8deee144d38e7970d3ba7f7c981c28b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 25 Aug 2016 22:18:40 +0200 Subject: [PATCH 060/179] renaming SearchInterface::SEARCH_PREVIEW => SEARCH_PREVIEW_OPTION --- Search/EventSearch.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Search/EventSearch.php b/Search/EventSearch.php index baf379a5d..ae900b4c3 100644 --- a/Search/EventSearch.php +++ b/Search/EventSearch.php @@ -15,17 +15,17 @@ use Chill\MainBundle\Search\SearchInterface; /** * Search within Events. - * + * * available terms : * - name: to search within the name * - date: search the event at a the given date * - date-from: search the event after the given date * - date-to : search the event before the given date - * + * * Default terms search within the name, but the term "name" has precedence. This - * means that if the search string is `@event xyz name:"abc"`, the searched + * means that if the search string is `@event xyz name:"abc"`, the searched * string will be "abc" and not xyz - * + * * * @author Julien Fastré * @author Champs Libres @@ -34,7 +34,7 @@ class EventSearch extends AbstractSearch { /** - * + * * @var EntityRepository */ private $er; @@ -47,7 +47,7 @@ class EventSearch extends AbstractSearch /** * - * @var AuthorizationHelper + * @var AuthorizationHelper */ private $helper; @@ -95,25 +95,25 @@ class EventSearch extends AbstractSearch return 3000; } - public function renderResult(array $terms, $start = 0, $limit = 50, + public function renderResult(array $terms, $start = 0, $limit = 50, array $options = array()) { $total = $this->count($terms); $paginator = $this->paginationFactory->create($total); - return $this->templating->render('ChillEventBundle:Event:list.html.twig', - array( + return $this->templating->render('ChillEventBundle:Event:list.html.twig', + array( 'events' => $this->search($terms, $start, $limit, $options), 'pattern' => $this->recomposePattern($terms, $this->getAvailableTerms(), $terms['_domain']), 'total' => $total, 'start' => $start, - 'preview' => $options[SearchInterface::SEARCH_PREVIEW], + 'preview' => $options[SearchInterface::SEARCH_PREVIEW_OPTION], 'paginator' => $paginator, 'search_name' => self::NAME )); } - protected function getAvailableTerms() + protected function getAvailableTerms() { return array('date-from', 'date-to', 'name', 'date'); } @@ -157,7 +157,7 @@ class EventSearch extends AbstractSearch $n = 0; $orWhere = $qb->expr()->orX(); foreach ($reachableCenters as $center) { - $circles = $this->helper->getReachableScopes($this->user, + $circles = $this->helper->getReachableScopes($this->user, new Role('CHILL_EVENT_SEE'), $center); $where = $qb->expr()->andX( $qb->expr()->eq('e.center', ':center_'.$n), @@ -180,7 +180,7 @@ class EventSearch extends AbstractSearch $where = $qb->expr()->like('UNACCENT(LOWER(e.name))', ':name'); $qb->setParameter('name', '%'.$name.'%'); - $qb->andWhere($where); + $qb->andWhere($where); } if (isset($terms['date'])) { From 99c1d488e3504bbf8c3d52eb1dffd9b767b1a233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 2 Sep 2016 08:24:25 +0200 Subject: [PATCH 061/179] adding condition for displaying message with number of result Now, the message "Result x-y of z" displays only if the number of events in result is > 0 --- Resources/views/Event/list.html.twig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig index 6da14a82f..6c78a49e1 100644 --- a/Resources/views/Event/list.html.twig +++ b/Resources/views/Event/list.html.twig @@ -2,9 +2,10 @@

                                        {% transchoice total with { '%pattern%' : pattern } %}%total% events match the search %pattern%{% endtranschoice %}

                                        -

                                        {{ 'Results %start%-%end% of %total%'|trans({ '%start%' : start, '%end%': start + events|length, '%total%' : total } ) }}

                                        - {% if events|length > 0 %} + +

                                        {{ 'Results %start%-%end% of %total%'|trans({ '%start%' : start, '%end%': start + events|length, '%total%' : total } ) }}

                                        +
                                        From 6c1586e37053343788fc025dab858ca10803de4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 20 Nov 2016 22:45:02 +0100 Subject: [PATCH 062/179] adding CI to project --- .gitlab-ci.yml | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..36433bea7 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,60 @@ +.test_definition: &test_definition + services: + - chill/database:latest + before_script: + - composer config github-oauth.github.com $GITHUB_TOKEN + - composer install + - cp Resources/test/Fixtures/App/config/parameters.gitlab-ci.yml Tests/Fixtures/App/config/parameters.yml + - php Resources/test/Fixtures/App/console --env=test cache:warmup + - php Resources/test/Fixtures/App/console doctrine:migrations:migrate --env=test --no-interaction + - php Resources/test/Fixtures/App/console doctrine:fixtures:load --env=test --no-interaction + + +stages: + - build-doc + - deploy-doc + - test + - deploy + + + + +test:php-5.6: + stage: test + <<: *test_definition + image: chill/ci-image:php-5.6 + script: phpunit + +test:php-7: + stage: test + <<: *test_definition + image: chill/ci-image:php-7 + script: phpunit + +# deploy documentation +api-doc-build: + stage: build-doc + environment: api-doc + image: chill/ci-image:php-7 + before_script: + - mkdir api-doc + script: apigen generate --destination api-doc/$CI_PROJECT_NAME/$CI_BUILD_REF_NAME + artifacts: + paths: + - "api-doc/" + name: api + expire_in: '2h' + only: + - master + - tags + +deploy-packagist: + stage: deploy + image: chill/ci-image:php-7 + before_script: + # test that PACKAGIST USERNAME and PACKAGIST_TOKEN variable are set + - if [ -z ${PACKAGIST_USERNAME+x} ]; then echo "Please set PACKAGIST_USERNAME variable"; exit -1; fi + - if [ -z ${PACKAGIST_TOKEN+x} ]; then echo "Please set PACKAGIST_TOKEN variable"; exit -1; fi + script: + - STATUSCODE=$(curl -XPOST -H'content-type:application/json' "https://packagist.org/api/update-package?username=$PACKAGIST_USERNAME&apiToken=$PACKAGIST_TOKEN" -d"{\"repository\":{\"url\":\"$CI_PROJECT_URL.git\"}}" --silent --output /dev/stderr --write-out "%{http_code}") + - if [ $STATUSCODE = "202" ]; then exit 0; else exit $STATUSCODE; fi From a8115853308c52fc395d72eed76060974b45b193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 20 Nov 2016 22:49:38 +0100 Subject: [PATCH 063/179] adding phpdoc --- phpdoc.dist.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 phpdoc.dist.xml diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml new file mode 100644 index 000000000..30c71f606 --- /dev/null +++ b/phpdoc.dist.xml @@ -0,0 +1,15 @@ + + + + data/output + Chill\MainBundle + + + data/output + + + . + Tests/Fixtures/App/AppKernel.php + Resources/test/* + + From cb4396b6d16b01654c7a9f77862eb67a4d4c9928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 20 Nov 2016 22:54:50 +0100 Subject: [PATCH 064/179] replacing phpDocumentor by apigen --- apigen.neon | 12 ++++++++++++ phpdoc.dist.xml | 15 --------------- 2 files changed, 12 insertions(+), 15 deletions(-) create mode 100644 apigen.neon delete mode 100644 phpdoc.dist.xml diff --git a/apigen.neon b/apigen.neon new file mode 100644 index 000000000..e651150f6 --- /dev/null +++ b/apigen.neon @@ -0,0 +1,12 @@ +# configuration for apigen + + +source: + - . + +exclude: + - vendor/* + - Resource/test/* + +title: Chill EventBundle + diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml deleted file mode 100644 index 30c71f606..000000000 --- a/phpdoc.dist.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - data/output - Chill\MainBundle - - - data/output - - - . - Tests/Fixtures/App/AppKernel.php - Resources/test/* - - From 209aa24866e7be33832d11cdd449f6dc0e1b29c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 20 Nov 2016 23:03:19 +0100 Subject: [PATCH 065/179] fixing error in CI before_secript --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36433bea7..7d6e38953 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ before_script: - composer config github-oauth.github.com $GITHUB_TOKEN - composer install - - cp Resources/test/Fixtures/App/config/parameters.gitlab-ci.yml Tests/Fixtures/App/config/parameters.yml + - cp Resources/test/Fixtures/App/config/parameters.gitlab-ci.yml Resources/test/Fixtures/App/config/parameters.yml - php Resources/test/Fixtures/App/console --env=test cache:warmup - php Resources/test/Fixtures/App/console doctrine:migrations:migrate --env=test --no-interaction - php Resources/test/Fixtures/App/console doctrine:fixtures:load --env=test --no-interaction From 8e6f2d4355543f93710f1d1bf6c2db29ab3f5f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Nov 2016 22:36:02 +0100 Subject: [PATCH 066/179] fix tests --- Tests/Search/EventSearchTest.php | 176 ++++++++++++++++++++++++++----- 1 file changed, 149 insertions(+), 27 deletions(-) diff --git a/Tests/Search/EventSearchTest.php b/Tests/Search/EventSearchTest.php index ab5e732c9..bb31a7bfa 100644 --- a/Tests/Search/EventSearchTest.php +++ b/Tests/Search/EventSearchTest.php @@ -167,7 +167,7 @@ class EventSearchTest extends WebTestCase 'q' => '@events' )); - $this->assertGreaterThan(2, $crawler->filter('table.events tr')->count(), + $this->assertGreaterThanOrEqual(2, $crawler->filter('table.events tr')->count(), 'assert than more than 2 tr are present'); } @@ -205,49 +205,171 @@ class EventSearchTest extends WebTestCase 'assert that the word "printemps" is present'); } - public function testSearchByDate() + public function testSearchByDateDateFromOnly() { // search with date from $crawler = $this->client->request('GET', '/fr/search', array( 'q' => '@events date-from:2016-05-30' )); + /* @var $dateFrom \DateTime the date from in DateTime */ + $dateFrom = \DateTime::createFromFormat("Y-m-d", "2016-05-30"); - $this->assertEquals( - 1, - $crawler->filter('tr:contains("Printemps")')->count(), - 'assert that the word "printemps" is present'); - $this->assertEquals( - 1, - $crawler->filter('tr:contains("Hiver")')->count(), - 'assert that the word "Hiver" is present'); + $dates = $this->iterateOnRowsToFindDate($crawler->filter("tr")); + foreach($dates as $date) { + $this->assertGreaterThanOrEqual($dateFrom, $date); + } + + // click on link "Voir tous les résultats" + $crawlerAllResults = $this->client->click($crawler + ->selectLink("Voir tous les résultats")->link()); + $dates = $this->iterateOnRowsToFindDate($crawlerAllResults->filter("tr")); + + foreach ($dates as $date) { + $this->assertGreaterThanOrEqual($dateFrom, $date); + } + + //iterate on pagination + $crawlerAllResults->filter(".pagination a")->each(function($a, $i) use ($dateFrom) { + $page = $this->client->click($a->link()); + $dates = $this->iterateOnRowsToFindDate($page->filter("tr")); + + foreach($dates as $date) { + $this->assertGreaterThanOrEqual($dateFrom, $date); + } + }); + } + + public function testSearchByDateDateBetween() + { // serach with date from **and** date-to $crawler = $this->client->request('GET', '/fr/search', array( 'q' => '@events date-from:2016-05-30 date-to:2016-06-20' )); - - $this->assertEquals( - 1, - $crawler->filter('tr:contains("Printemps")')->count(), - 'assert that the word "printemps" is present'); - $this->assertEquals( - 0, - $crawler->filter('tr:contains("Hiver")')->count(), - 'assert that the word "Hiver" is not present'); + + /* @var $dateFrom \DateTime the date from in DateTime */ + $dateFrom = \DateTime::createFromFormat("Y-m-d", "2016-05-30"); + $dateTo = \DateTime::createFromFormat("Y-m-d", "2016-06-20"); + + $dates = $this->iterateOnRowsToFindDate($crawler->filter("tr")); + + foreach($dates as $date) { + $this->assertGreaterThanOrEqual($dateFrom, $date); + $this->assertLessThanOrEqual($dateTo, $date); + } + + // there should not have any other results, but if any other bundle + // add some other event, we go on next pages + + if ($crawler->selectLink("Voir tous les résultats")->count() == 0) { + return ; + } + + // click on link "Voir tous les résultats" + $crawlerAllResults = $this->client->click($crawler + ->selectLink("Voir tous les résultats")->link()); + $dates = $this->iterateOnRowsToFindDate($crawlerAllResults->filter("tr")); + + foreach ($dates as $date) { + $this->assertGreaterThanOrEqual($dateFrom, $date); + $this->assertLessThanOrEqual($dateTo, $date); + } + + //iterate on pagination + $crawlerAllResults->filter(".pagination a")->each(function($a, $i) use ($dateFrom) { + $page = $this->client->click($a->link()); + $dates = $this->iterateOnRowsToFindDate($page->filter("tr")); + + foreach($dates as $date) { + $this->assertGreaterThanOrEqual($dateFrom, $date); + $this->assertLessThanOrEqual($dateTo, $date); + } + }); + } + + public function testSearchByDateDateTo() + { // serach with date from **and** date-to $crawler = $this->client->request('GET', '/fr/search', array( 'q' => '@events date:2016-05-30' )); - $this->assertEquals( - 1, - $crawler->filter('tr:contains("Printemps")')->count(), - 'assert that the word "printemps" is present'); - $this->assertEquals( - 0, - $crawler->filter('tr:contains("Hiver")')->count(), - 'assert that the word "Hiver" is not present'); + /* @var $dateFrom \DateTime the date from in DateTime */ + $dateTo = \DateTime::createFromFormat("Y-m-d", "2016-05-30"); + + $dates = $this->iterateOnRowsToFindDate($crawler->filter("tr")); + + foreach($dates as $date) { + $this->assertLessThanOrEqual($dateTo, $date); + } + + if ($crawler->selectLink("Voir tous les résultats")->count() == 0) { + return ; + } + + // click on link "Voir tous les résultats" + $crawlerAllResults = $this->client->click($crawler + ->selectLink("Voir tous les résultats")->link()); + $dates = $this->iterateOnRowsToFindDate($crawlerAllResults->filter("tr")); + + foreach ($dates as $date) { + $this->assertLessThanOrEqual($dateTo, $date); + } + + //iterate on pagination + $crawlerAllResults->filter(".pagination a")->each(function($a, $i) use ($dateFrom) { + $page = $this->client->click($a->link()); + $dates = $this->iterateOnRowsToFindDate($page->filter("tr")); + + foreach($dates as $date) { + $this->assertLessThanOrEqual($dateTo, $date); + } + }); + + } + + /** + * this function iterate on row from results of events and return the content + * of the second column (which should contains the date) in DateTime objects + * + * @param \Symfony\Component\DomCrawler\Crawler $trs + * @return \DateTime[] + */ + private function iterateOnRowsToFindDate(\Symfony\Component\DomCrawler\Crawler $trs) + { + $months = array( + "janvier" => 1, + "février" => 2, + "mars" => 3, + "avril" => 4, + "mai" => 5, + "juin" => 6, + "juillet" => 7, + "août" => 8, + "septembre" => 9, + "octobre" => 10, + "novembre" => 11, + "décembre" => 12 + ); + + + $results = $trs->each(function($tr, $i) use ($months) { + // we skip the first row + if ($i > 0) { + // get the second node, which should contains a date + $tdDate = $tr->filter("td")->eq(1); + // transform the date, which should be in french, into a DateTime object + $parts = explode(" ", $tdDate->text()); + return \DateTime::createFromFormat("Y-m-d", $parts[2]. + "-".$months[$parts[1]]."-".$parts[0]); + } + }); + + // remove the first row + unset($results[0]); + + return $results; } /** From 7763bddc8004aefac6b387584dddcdc3316aada4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 14 Dec 2016 16:20:55 +0100 Subject: [PATCH 067/179] adding deploy doc stage --- .gitlab-ci.yml | 28 +++++++++++++++------------- apigen.neon | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7d6e38953..45154b95a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,10 +11,10 @@ stages: - - build-doc - - deploy-doc - test - deploy + - build-doc + - deploy-doc @@ -31,6 +31,18 @@ test:php-7: image: chill/ci-image:php-7 script: phpunit + +deploy-packagist: + stage: deploy + image: chill/ci-image:php-7 + before_script: + # test that PACKAGIST USERNAME and PACKAGIST_TOKEN variable are set + - if [ -z ${PACKAGIST_USERNAME+x} ]; then echo "Please set PACKAGIST_USERNAME variable"; exit -1; fi + - if [ -z ${PACKAGIST_TOKEN+x} ]; then echo "Please set PACKAGIST_TOKEN variable"; exit -1; fi + script: + - STATUSCODE=$(curl -XPOST -H'content-type:application/json' "https://packagist.org/api/update-package?username=$PACKAGIST_USERNAME&apiToken=$PACKAGIST_TOKEN" -d"{\"repository\":{\"url\":\"$CI_PROJECT_URL.git\"}}" --silent --output /dev/stderr --write-out "%{http_code}") + - if [ $STATUSCODE = "202" ]; then exit 0; else exit $STATUSCODE; fi + # deploy documentation api-doc-build: stage: build-doc @@ -47,14 +59,4 @@ api-doc-build: only: - master - tags - -deploy-packagist: - stage: deploy - image: chill/ci-image:php-7 - before_script: - # test that PACKAGIST USERNAME and PACKAGIST_TOKEN variable are set - - if [ -z ${PACKAGIST_USERNAME+x} ]; then echo "Please set PACKAGIST_USERNAME variable"; exit -1; fi - - if [ -z ${PACKAGIST_TOKEN+x} ]; then echo "Please set PACKAGIST_TOKEN variable"; exit -1; fi - script: - - STATUSCODE=$(curl -XPOST -H'content-type:application/json' "https://packagist.org/api/update-package?username=$PACKAGIST_USERNAME&apiToken=$PACKAGIST_TOKEN" -d"{\"repository\":{\"url\":\"$CI_PROJECT_URL.git\"}}" --silent --output /dev/stderr --write-out "%{http_code}") - - if [ $STATUSCODE = "202" ]; then exit 0; else exit $STATUSCODE; fi + diff --git a/apigen.neon b/apigen.neon index e651150f6..7b4c4afc0 100644 --- a/apigen.neon +++ b/apigen.neon @@ -6,7 +6,7 @@ source: exclude: - vendor/* - - Resource/test/* + - Resources/test/* title: Chill EventBundle From 98b6174cd212b359849cc9eb9c577f1cdb8f0d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 14 Dec 2016 16:27:42 +0100 Subject: [PATCH 068/179] fixing deploy-doc stage --- .gitlab-ci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 45154b95a..a84bc1602 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -60,3 +60,16 @@ api-doc-build: - master - tags +api-doc-deploy: + stage: deploy-doc + image: pallet/swiftclient:latest + before_script: + # test that CONTAINER_API variable is set + - if [ -z ${CONTAINER_API+x} ]; then echo "Please set CONTAINER_API variable"; exit -1; fi + # go to api-doc to have and url with PROJECT/BUILD + - cd api-doc + # upload, and keep files during 1 year + script: "swift upload --header \"X-Delete-After: 31536000\" $CONTAINER_API $CI_BUILD_REF_NAME/$CI_PROJECT_NAME" + only: + - master + - tags From 7a6b2c3fe7af2f5659cbf44386862b9e2628f7f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 14 Dec 2016 16:36:34 +0100 Subject: [PATCH 069/179] fixing path in deploy-doc stage --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a84bc1602..183d218e6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,7 +50,7 @@ api-doc-build: image: chill/ci-image:php-7 before_script: - mkdir api-doc - script: apigen generate --destination api-doc/$CI_PROJECT_NAME/$CI_BUILD_REF_NAME + script: apigen generate --destination api-doc/$CI_BUILD_REF_NAME/$CI_PROJECT_NAME artifacts: paths: - "api-doc/" From 6eef0fcf88915bbd60b2efe28a1e6c065499eb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 18 Dec 2016 22:46:18 +0100 Subject: [PATCH 070/179] removing memory limit on composer install --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 183d218e6..ffd3e3a9f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ - chill/database:latest before_script: - composer config github-oauth.github.com $GITHUB_TOKEN - - composer install + - php -d memory_limit=-1 /usr/local/bin/composer install - cp Resources/test/Fixtures/App/config/parameters.gitlab-ci.yml Resources/test/Fixtures/App/config/parameters.yml - php Resources/test/Fixtures/App/console --env=test cache:warmup - php Resources/test/Fixtures/App/console doctrine:migrations:migrate --env=test --no-interaction From 21974a048e0ebce1996164f39b09fcfac2eabf1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Apr 2017 21:43:42 +0200 Subject: [PATCH 071/179] fix translation and add role hierarchy --- Resources/translations/messages.fr.yml | 7 +++++++ Security/Authorization/EventVoter.php | 10 ++++++++-- Security/Authorization/ParticipationVoter.php | 9 +++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 0a38cf10b..d2b2d533c 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -42,3 +42,10 @@ The participations were created: Les participations ont été créées #search Event search: Recherche d'événements '%total% events match the search %pattern%' : '{0} Aucun événement ne correspond aux termes de recherche "%pattern%" | {1} Un événement a été trouvé par la recherche "%pattern%" | ]1,Inf] %total% événements correspondent aux termes de recherche "%pattern%".' + +CHILL_EVENT_UPDATE: Modifier un événement +CHILL_EVENT_CREATE: Créer un événement +CHILL_EVENT_PARTICIPATION_CREATE: Créer une participation à un événement +CHILL_EVENT_PARTICIPATION_UPDATE: Modifier une participation à un événement +CHILL_EVENT_SEE: Voir un événement +CHILL_EVENT_SEE_DETAILS: Voir les détails d'un événement diff --git a/Security/Authorization/EventVoter.php b/Security/Authorization/EventVoter.php index dc7a63971..8f74e649a 100644 --- a/Security/Authorization/EventVoter.php +++ b/Security/Authorization/EventVoter.php @@ -5,7 +5,7 @@ namespace Chill\EventBundle\Security\Authorization; use Chill\MainBundle\Security\Authorization\AbstractChillVoter; -use Chill\MainBundle\Security\ProvideRoleInterface; +use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; use Chill\EventBundle\Entity\Event; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Entity\User; @@ -16,7 +16,7 @@ use Chill\MainBundle\Entity\User; * @author Julien Fastré * @author Champs Libres */ -class EventVoter extends AbstractChillVoter implements ProvideRoleInterface +class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { const SEE = 'CHILL_EVENT_SEE'; @@ -60,5 +60,11 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleInterface { return null; } + + + public function getRolesWithHierarchy() + { + return [ 'Event' => $this->getRoles() ]; + } } diff --git a/Security/Authorization/ParticipationVoter.php b/Security/Authorization/ParticipationVoter.php index e8ba27548..385796a71 100644 --- a/Security/Authorization/ParticipationVoter.php +++ b/Security/Authorization/ParticipationVoter.php @@ -19,7 +19,7 @@ namespace Chill\EventBundle\Security\Authorization; -use Chill\MainBundle\Security\ProvideRoleInterface; +use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; use Chill\MainBundle\Security\Authorization\AbstractChillVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\EventBundle\Entity\Participation; @@ -30,7 +30,7 @@ use Chill\MainBundle\Entity\User; * * @author Julien Fastré */ -class ParticipationVoter extends AbstractChillVoter implements ProvideRoleInterface +class ParticipationVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { /** * @@ -78,5 +78,10 @@ class ParticipationVoter extends AbstractChillVoter implements ProvideRoleInterf { return null; } + + public function getRolesWithHierarchy() + { + return [ 'Event' => $this->getRoles() ]; + } } From f0c145f1be58b3fbe4ef9e61d91807cc240ec0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Apr 2017 21:43:54 +0200 Subject: [PATCH 072/179] allow dev packages and prefer-stable --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 14fc5af95..0a887a2d0 100644 --- a/composer.json +++ b/composer.json @@ -57,5 +57,7 @@ }, "extra": { "app-migrations-dir": "Resources/test/Fixtures/App/DoctrineMigrations" - } + }, + "minimum-stability": "dev", + "prefer-stable": true } From d85a6612531cba751900baa314cab3c6440b6e15 Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 19 Dec 2018 14:54:35 +0100 Subject: [PATCH 073/179] prepare composer.json before migrate to symfony 3 --- composer.json | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 0a887a2d0..b98b9fd00 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "chill-project/event", "description": "This bundle extend chill software. This bundle allow to define event and participation to those events.", "type": "symfony-bundle", - "license": "AGPL-3.0", + "license": "AGPL-3.0-only", "keywords" : ["chill", "social work"], "homepage" : "https://git.framasoft.org/Chill-project/Chill-Group", "autoload": { @@ -21,28 +21,9 @@ } ], "require": { - "twig/extensions": "^1.2", - "symfony/assetic-bundle": "~2.3", - "symfony/framework-bundle": "~2.7", - "symfony/yaml": "~2.8", - "symfony/symfony": "~2.8", - "doctrine/dbal": "~2.5", - "doctrine/orm": "~2.4", - "doctrine/common": "~2.4", - "doctrine/doctrine-bundle": "~1.2", - "chill-project/main": "dev-master@dev", - "chill-project/person": "dev-master@dev", - "champs-libres/composer-bundle-migration": "~1.0", - "doctrine/doctrine-migrations-bundle": "~1.1", - "chill-project/custom-fields": "dev-master@dev", - "doctrine/migrations": "~1.0", - "monolog/monolog": "^1.14" + "chill-project/person": "~1.5" }, "require-dev": { - "doctrine/doctrine-fixtures-bundle": "~2.2", - "fzaninotto/faker": "~1", - "symfony/monolog-bundle": "^2.7", - "sensio/generator-bundle": "^2.5" }, "suggest" : { "chill-project/group": "dev-master@dev" From 49aeb075a4bd9c16bd045b8318366303183d7e6a Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 20 Dec 2018 11:25:46 +0100 Subject: [PATCH 074/179] fix fatal errors --- Search/EventSearch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Search/EventSearch.php b/Search/EventSearch.php index ae900b4c3..4fc5fc19a 100644 --- a/Search/EventSearch.php +++ b/Search/EventSearch.php @@ -80,7 +80,7 @@ class EventSearch extends AbstractSearch $this->paginationFactory = $paginatorFactory; } - public function supports($domain) + public function supports($domain, $format) { return 'event' === $domain or 'events' === $domain; } @@ -96,7 +96,7 @@ class EventSearch extends AbstractSearch } public function renderResult(array $terms, $start = 0, $limit = 50, - array $options = array()) + array $options = array(), $format = 'html') { $total = $this->count($terms); $paginator = $this->paginationFactory->create($total); From 9f168a3a3c845522d918dd24974ab2e2e1032edc Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 20 Dec 2018 11:36:39 +0100 Subject: [PATCH 075/179] fix new events page depreciations --- Controller/EventController.php | 2 +- Form/EventType.php | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index cb2301e6d..1885a26ae 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -68,7 +68,7 @@ class EventController extends Controller 'method' => 'POST' )); - $form->add('submit', 'submit', array('label' => 'Create')); + $form->add('submit', SubmitType::class, array('label' => 'Create')); return $form; } diff --git a/Form/EventType.php b/Form/EventType.php index 2d4895efa..fe365fbe6 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -3,6 +3,7 @@ namespace Chill\EventBundle\Form; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; use Chill\EventBundle\Form\Type\PickEventType; @@ -68,10 +69,7 @@ class EventType extends AbstractType $builder ->add('name') - ->add( - 'date', - 'date', - array( + ->add('date', DateType::class, array( 'required' => true, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy' From cf93fc10fdd1034e880fe91e911bf31bb8bb706f Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 20 Dec 2018 12:19:40 +0100 Subject: [PATCH 076/179] fix admin_event_status depreciations --- Controller/StatusController.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Controller/StatusController.php b/Controller/StatusController.php index 211153b94..9147a89b8 100644 --- a/Controller/StatusController.php +++ b/Controller/StatusController.php @@ -2,6 +2,7 @@ namespace Chill\EventBundle\Controller; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; @@ -62,12 +63,12 @@ class StatusController extends Controller */ private function createCreateForm(Status $entity) { - $form = $this->createForm(new StatusType(), $entity, array( + $form = $this->createForm(StatusType::class, $entity, array( 'action' => $this->generateUrl('chill_event_admin_status_create'), 'method' => 'POST', )); - $form->add('submit', 'submit', array('label' => 'Create')); + $form->add('submit', SubmitType::class, array('label' => 'Create')); return $form; } @@ -142,12 +143,12 @@ class StatusController extends Controller */ private function createEditForm(Status $entity) { - $form = $this->createForm(new StatusType(), $entity, array( + $form = $this->createForm(StatusType::class, $entity, array( 'action' => $this->generateUrl('chill_event_admin_status_update', array('id' => $entity->getId())), 'method' => 'PUT', )); - $form->add('submit', 'submit', array('label' => 'Update')); + $form->add('submit', SubmitType::class, array('label' => 'Update')); return $form; } @@ -217,7 +218,7 @@ class StatusController extends Controller return $this->createFormBuilder() ->setAction($this->generateUrl('chill_event_admin_status_delete', array('id' => $id))) ->setMethod('DELETE') - ->add('submit', 'submit', array('label' => 'Delete')) + ->add('submit', SubmitType::class, array('label' => 'Delete')) ->getForm() ; } From 7de5cf03b6ecbc649957ecaedade177bef5d109f Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 20 Dec 2018 12:40:12 +0100 Subject: [PATCH 077/179] fix admin_eventtype depreciations --- Controller/EventTypeController.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Controller/EventTypeController.php b/Controller/EventTypeController.php index 760594600..c30c656bf 100644 --- a/Controller/EventTypeController.php +++ b/Controller/EventTypeController.php @@ -2,6 +2,7 @@ namespace Chill\EventBundle\Controller; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; @@ -63,12 +64,12 @@ class EventTypeController extends Controller */ private function createCreateForm(EventType $entity) { - $form = $this->createForm(new EventTypeType(), $entity, array( + $form = $this->createForm(EventTypeType::class, $entity, array( 'action' => $this->generateUrl('chill_eventtype_admin_create'), 'method' => 'POST', )); - $form->add('submit', 'submit', array('label' => 'Create')); + $form->add('submit', SubmitType::class, array('label' => 'Create')); return $form; } @@ -143,13 +144,13 @@ class EventTypeController extends Controller */ private function createEditForm(EventType $entity) { - $form = $this->createForm(new EventTypeType(), $entity, array( + $form = $this->createForm(EventTypeType::class, $entity, array( 'action' => $this->generateUrl('chill_eventtype_admin_update', array('id' => $entity->getId())), 'method' => 'PUT', )); - $form->add('submit', 'submit', array('label' => 'Update')); + $form->add('submit', SubmitType::class, array('label' => 'Update')); return $form; } @@ -221,7 +222,7 @@ class EventTypeController extends Controller ->setAction($this->generateUrl('chill_eventtype_admin_delete', array('id' => $id))) ->setMethod('DELETE') - ->add('submit', 'submit', array('label' => 'Delete')) + ->add('submit', SubmitType::class, array('label' => 'Delete')) ->getForm() ; } From 403d1749e378732225e6e58443a9032ea191fc2e Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 20 Dec 2018 12:50:54 +0100 Subject: [PATCH 078/179] fix admin_event_role depreciations --- Controller/RoleController.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Controller/RoleController.php b/Controller/RoleController.php index b1c560292..5f0fe0499 100644 --- a/Controller/RoleController.php +++ b/Controller/RoleController.php @@ -2,6 +2,7 @@ namespace Chill\EventBundle\Controller; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; @@ -63,12 +64,12 @@ class RoleController extends Controller */ private function createCreateForm(Role $entity) { - $form = $this->createForm($this->get('chill.event.form.role_type'), $entity, array( + $form = $this->createForm(RoleType::class, $entity, array( 'action' => $this->generateUrl('chill_event_admin_role_create'), 'method' => 'POST', )); - $form->add('submit', 'submit', array('label' => 'Create')); + $form->add('submit', SubmitType::class, array('label' => 'Create')); return $form; } @@ -143,13 +144,13 @@ class RoleController extends Controller */ private function createEditForm(Role $entity) { - $form = $this->createForm($this->get('chill.event.form.role_type'), $entity, array( + $form = $this->createForm(RoleType::class, $entity, array( 'action' => $this->generateUrl('chill_event_admin_role_update', array('id' => $entity->getId())), 'method' => 'PUT', )); - $form->add('submit', 'submit', array('label' => 'Update')); + $form->add('submit', SubmitType::class, array('label' => 'Update')); return $form; } @@ -220,7 +221,7 @@ class RoleController extends Controller return $this->createFormBuilder() ->setAction($this->generateUrl('chill_event_admin_role_delete', array('id' => $id))) ->setMethod('DELETE') - ->add('submit', 'submit', array('label' => 'Delete')) + ->add('submit', SubmitType::class, array('label' => 'Delete')) ->getForm() ; } From bc30998164dc7dd56da2e3e09bcb647ca52f823b Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 20 Dec 2018 15:55:17 +0100 Subject: [PATCH 079/179] fix edit events depreciations --- Controller/EventController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index 1885a26ae..74fa339f2 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -189,7 +189,7 @@ class EventController extends Controller $form->remove('center'); - $form->add('submit', 'submit', array('label' => 'Update')); + $form->add('submit', SubmitType::class, array('label' => 'Update')); return $form; } From d123e4137f7fd3857006d697e606e3e5776ed296 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 20 Dec 2018 16:41:25 +0100 Subject: [PATCH 080/179] fix event_participation depreciations --- Resources/config/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/validation.yml b/Resources/config/validation.yml index d6a12b418..d5c7d2243 100644 --- a/Resources/config/validation.yml +++ b/Resources/config/validation.yml @@ -7,7 +7,7 @@ Chill\EventBundle\Entity\Participation: person: - NotNull: ~ constraints: - - Callback: [isConsistent] + - Callback: isConsistent Chill\EventBundle\Entity\Event: From 7b8f2d120626af6e38e5586df08c2c0525ab0370 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 10 Jan 2019 15:31:40 +0100 Subject: [PATCH 081/179] add time to field date, prepare and run migration script --- Resources/config/doctrine/Event.orm.yml | 2 +- .../migrations/Version20190110140538.php | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 Resources/migrations/Version20190110140538.php diff --git a/Resources/config/doctrine/Event.orm.yml b/Resources/config/doctrine/Event.orm.yml index eb02041e4..3d7e0ec5a 100644 --- a/Resources/config/doctrine/Event.orm.yml +++ b/Resources/config/doctrine/Event.orm.yml @@ -12,7 +12,7 @@ Chill\EventBundle\Entity\Event: type: string length: '150' date: - type: date + type: datetime oneToMany: participations: targetEntity: Chill\EventBundle\Entity\Participation diff --git a/Resources/migrations/Version20190110140538.php b/Resources/migrations/Version20190110140538.php new file mode 100644 index 000000000..545f58f58 --- /dev/null +++ b/Resources/migrations/Version20190110140538.php @@ -0,0 +1,29 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_event_event ALTER date TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE chill_event_event ALTER date DROP DEFAULT'); + + } + + public function down(Schema $schema) : void + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_event_event ALTER date TYPE DATE'); + $this->addSql('ALTER TABLE chill_event_event ALTER date DROP DEFAULT'); + } +} From e1b5ec49f5776eb1237a2ab26fa4ca44cb486bb8 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 10 Jan 2019 15:52:19 +0100 Subject: [PATCH 082/179] font-awesome pictos are now managed in css --- Resources/views/Event/edit.html.twig | 1 - Resources/views/Event/list.html.twig | 1 - 2 files changed, 2 deletions(-) diff --git a/Resources/views/Event/edit.html.twig b/Resources/views/Event/edit.html.twig index a5752fb73..03519eff9 100644 --- a/Resources/views/Event/edit.html.twig +++ b/Resources/views/Event/edit.html.twig @@ -18,7 +18,6 @@
                                        • - {{ 'Back to the most recent events'|trans }}
                                        • diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig index 6c78a49e1..93eaf0312 100644 --- a/Resources/views/Event/list.html.twig +++ b/Resources/views/Event/list.html.twig @@ -47,7 +47,6 @@
                                          • - {{ 'New event'|trans }}
                                          • From 97d79c5a22d324136ec0f3a8fa27b3ecf0e1bec6 Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 15 Jan 2019 11:12:06 +0100 Subject: [PATCH 083/179] make fixtures works for event module --- DependencyInjection/ChillEventExtension.php | 1 + Resources/config/services/fixtures.yml | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 Resources/config/services/fixtures.yml diff --git a/DependencyInjection/ChillEventExtension.php b/DependencyInjection/ChillEventExtension.php index 29e273178..1e0443899 100644 --- a/DependencyInjection/ChillEventExtension.php +++ b/DependencyInjection/ChillEventExtension.php @@ -30,6 +30,7 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface $loader->load('search.yml'); $loader->load('authorization.yml'); $loader->load('forms.yml'); + $loader->load('fixtures.yml'); } /* (non-PHPdoc) diff --git a/Resources/config/services/fixtures.yml b/Resources/config/services/fixtures.yml new file mode 100644 index 000000000..a51618f43 --- /dev/null +++ b/Resources/config/services/fixtures.yml @@ -0,0 +1,4 @@ +services: + Chill\EventBundle\DataFixtures\ORM\: + resource: ../../../DataFixtures/ORM + tags: [ 'doctrine.fixture.orm' ] From 7836ece3eefb1958c8ab5d3bb59e7f74b32deff5 Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 15 Jan 2019 14:10:45 +0100 Subject: [PATCH 084/179] add time to event dates --- Form/EventType.php | 8 +++----- Resources/views/Event/list.html.twig | 2 +- Resources/views/Event/show.html.twig | 2 +- Resources/views/Participation/edit-multiple.html.twig | 3 +-- Resources/views/Participation/edit.html.twig | 3 +-- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Form/EventType.php b/Form/EventType.php index fe365fbe6..913acb08e 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -2,8 +2,8 @@ namespace Chill\EventBundle\Form; +use Chill\MainBundle\Form\Type\ChillDateTimeType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; use Chill\EventBundle\Form\Type\PickEventType; @@ -69,10 +69,8 @@ class EventType extends AbstractType $builder ->add('name') - ->add('date', DateType::class, array( - 'required' => true, - 'widget' => 'single_text', - 'format' => 'dd-MM-yyyy' + ->add('date', ChillDateTimeType::class, array( + 'required' => true ) ) ->add('center', EntityType::class, array( diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig index 93eaf0312..b6c051a3d 100644 --- a/Resources/views/Event/list.html.twig +++ b/Resources/views/Event/list.html.twig @@ -19,7 +19,7 @@ {% for event in events %}
                                        - + - + diff --git a/Resources/views/Participation/edit-multiple.html.twig b/Resources/views/Participation/edit-multiple.html.twig index 747b53260..1d6a8c5c7 100644 --- a/Resources/views/Participation/edit-multiple.html.twig +++ b/Resources/views/Participation/edit-multiple.html.twig @@ -13,7 +13,7 @@ - +
                                        {{ event.name }}{{ event.date|localizeddate('long', 'none') }}{{ event.date|localizeddate('long', 'short') }} {{ event.type.name|localize_translatable_string }}
                                          diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index e2aa9caf3..3d878295c 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -15,7 +15,7 @@
                                        {{ 'Date'|trans }}{{ event.date|localizeddate('long', 'none') }}{{ event.date|localizeddate('long', 'short') }}
                                        {{ 'Event type'|trans }}
                                        {{ 'Date'|trans }} {{ event.date|localizeddate('long', 'none') }}{{ event.date|localizeddate('long', 'short') }}
                                        @@ -47,7 +47,6 @@
                                        • - {{ 'Back to the event'|trans }}
                                        • diff --git a/Resources/views/Participation/edit.html.twig b/Resources/views/Participation/edit.html.twig index a778eeef7..dd6df62ef 100644 --- a/Resources/views/Participation/edit.html.twig +++ b/Resources/views/Participation/edit.html.twig @@ -17,7 +17,7 @@ {{ 'Date'|trans }} - {{ participation.event.date|localizeddate('long', 'none') }} + {{ participation.event.date|localizeddate('long', 'short') }} @@ -29,7 +29,6 @@
                                          • - {{ 'Back to the event'|trans }}
                                          • From ca6f836195c3d1050a3de6b6f5582f7880e0d392 Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 15 Jan 2019 16:01:04 +0100 Subject: [PATCH 085/179] add a new moderator field on events --- Entity/Event.php | 26 ++++++++++++++- Form/EventType.php | 6 ++++ Resources/config/doctrine/Event.orm.yml | 3 ++ .../migrations/Version20190115140042.php | 32 +++++++++++++++++++ Resources/translations/messages.fr.yml | 1 + Resources/views/Event/edit.html.twig | 1 + Resources/views/Event/show.html.twig | 5 +++ 7 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 Resources/migrations/Version20190115140042.php diff --git a/Entity/Event.php b/Entity/Event.php index 0246be6fd..87cc9bab1 100644 --- a/Entity/Event.php +++ b/Entity/Event.php @@ -4,6 +4,7 @@ namespace Chill\EventBundle\Entity; use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\HasScopeInterface; +use Doctrine\ORM\Mapping as ORM; /** * Event @@ -47,7 +48,12 @@ class Event implements HasCenterInterface, HasScopeInterface * @var \Doctrine\Common\Collections\Collection */ private $participations; - + + /** + * @var integer + */ + private $moderator; + /** * Constructor */ @@ -215,4 +221,22 @@ class Event implements HasCenterInterface, HasScopeInterface { return $this->participations; } + + /** + * @return int + */ + public function getModerator() + { + return $this->moderator; + } + + /** + * @param int $moderator + * @return Event + */ + public function setModerator($moderator) + { + $this->moderator = $moderator; + return $this; + } } diff --git a/Form/EventType.php b/Form/EventType.php index 913acb08e..df4744178 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -3,6 +3,7 @@ namespace Chill\EventBundle\Form; use Chill\MainBundle\Form\Type\ChillDateTimeType; +use Chill\PersonBundle\Entity\Person; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; @@ -104,6 +105,11 @@ class EventType extends AbstractType }, )) ->add('type', PickEventType::class) + ->add('moderator', EntityType::class, array( + 'class' => Person::class, + 'required' => false, + 'placeholder' => '' + )) ; } diff --git a/Resources/config/doctrine/Event.orm.yml b/Resources/config/doctrine/Event.orm.yml index 3d7e0ec5a..88bc2e9d1 100644 --- a/Resources/config/doctrine/Event.orm.yml +++ b/Resources/config/doctrine/Event.orm.yml @@ -24,4 +24,7 @@ Chill\EventBundle\Entity\Event: targetEntity: Chill\EventBundle\Entity\EventType circle: targetEntity: Chill\MainBundle\Entity\Scope + moderator: + targetEntity: Chill\PersonBundle\Entity\Person + lifecycleCallbacks: { } diff --git a/Resources/migrations/Version20190115140042.php b/Resources/migrations/Version20190115140042.php new file mode 100644 index 000000000..275fabd21 --- /dev/null +++ b/Resources/migrations/Version20190115140042.php @@ -0,0 +1,32 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_event_event ADD moderator_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_event_event ADD CONSTRAINT FK_FA320FC8D0AFA354 FOREIGN KEY (moderator_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_FA320FC8D0AFA354 ON chill_event_event (moderator_id)'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_event_event DROP CONSTRAINT FK_FA320FC8D0AFA354'); + $this->addSql('DROP INDEX IDX_FA320FC8D0AFA354'); + $this->addSql('ALTER TABLE chill_event_event DROP moderator_id'); + } +} diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index d2b2d533c..992b1c2e0 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -12,6 +12,7 @@ Participations: Participations Status: Statut Last update: Dernière mise à jour '%count% participations to this event': '{0} Aucun participant à l''événement | {1} Un participant à l''événement | ]1,Inf] %count% participants à l''événement' +Moderator: Animateur #CRUD event Details of an event: Détails d'un événement diff --git a/Resources/views/Event/edit.html.twig b/Resources/views/Event/edit.html.twig index 03519eff9..448a6eed1 100644 --- a/Resources/views/Event/edit.html.twig +++ b/Resources/views/Event/edit.html.twig @@ -14,6 +14,7 @@ {{ form_row(edit_form.name) }} {{ form_row(edit_form.date) }} {{ form_row(edit_form.type, { 'label': 'Event type' }) }} + {{ form_row(edit_form.moderator) }}
                                            • diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 3d878295c..c97342528 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -25,6 +25,11 @@ {{ 'Circle'|trans }} {{ event.circle.name|localize_translatable_string }} + + {{ 'Moderator'|trans }} + {{ event.moderator|trans|default('-') }} + + From 3042b1b0ca03cc6eebc145eeed054e0a37ecfe4d Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 15 Jan 2019 16:35:25 +0100 Subject: [PATCH 086/179] fixtures: add an event type 'visit' --- DataFixtures/ORM/LoadEventTypes.php | 48 ++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/DataFixtures/ORM/LoadEventTypes.php b/DataFixtures/ORM/LoadEventTypes.php index 40e9b76b0..4210ab02a 100644 --- a/DataFixtures/ORM/LoadEventTypes.php +++ b/DataFixtures/ORM/LoadEventTypes.php @@ -32,6 +32,7 @@ class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface ->setName(array('fr' => 'Échange de savoirs', 'en' => 'Exchange of knowledge')) ; $manager->persist($type); + $this->addReference('event_type_knowledge', $type); self::$refs[] = 'event_type_knowledge'; @@ -67,6 +68,7 @@ class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface ->setName(array('fr' => 'Formation', 'en' => 'Course', 'nl' => 'Opleiding')) ; $manager->persist($type); + $this->addReference('event_type_course', $type); self::$refs[] = 'event_type_course'; @@ -83,12 +85,50 @@ class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface ->setType($type) ; $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'En liste d\'attente')) + ->setType($type) + ; + $manager->persist($status); + + + $type = (new EventType()) + ->setActive(true) + ->setName(array('fr' => 'Visite', 'en' => 'Visit')) + ; + $manager->persist($type); + + $this->addReference('event_type_visit', $type); + self::$refs[] = 'event_type_visit'; + + $role = (new Role()) + ->setActive(true) + ->setName(array('fr' => 'Participant', 'nl' => 'Deelneemer', 'en' => 'Participant')) + ->setType($type) + ; + $manager->persist($role); $status = (new Status()) - ->setActive(true) - ->setName(array('fr' => 'En liste d\'attente')) - ->setType($type) - ; + ->setActive(true) + ->setName(array('fr' => 'Présent')) + ->setType($type) + ; + $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Absent')) + ->setType($type) + ; + $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Excusé')) + ->setType($type) + ; $manager->persist($status); $manager->flush(); From d18f3dd3dd7eaa6f7a3f9c5597564c310f701029 Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 16 Jan 2019 11:23:50 +0100 Subject: [PATCH 087/179] styles: display date and time fields on same line --- Resources/views/Event/edit.html.twig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Resources/views/Event/edit.html.twig b/Resources/views/Event/edit.html.twig index 448a6eed1..164d75be5 100644 --- a/Resources/views/Event/edit.html.twig +++ b/Resources/views/Event/edit.html.twig @@ -12,7 +12,15 @@ {{ form_row(edit_form.center) }} {% endif %} {{ form_row(edit_form.name) }} + + {# TODO temporaire: chaque fois qu'on a une date + une heure, on veut afficher sur une seule ligne #} + {{ form_row(edit_form.date) }} + {{ form_row(edit_form.type, { 'label': 'Event type' }) }} {{ form_row(edit_form.moderator) }} From d89e440784bd76645b78b1eedce1a5361133ebe1 Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 16 Jan 2019 16:19:40 +0100 Subject: [PATCH 088/179] add item 'events participation' in person menu --- Controller/EventController.php | 8 +++ DependencyInjection/ChillEventExtension.php | 1 + Menu/PersonMenuBuilder.php | 71 +++++++++++++++++++++ Resources/config/routing/event.yml | 4 ++ Resources/config/services/menu.yml | 8 +++ Resources/translations/messages.fr.yml | 1 + 6 files changed, 93 insertions(+) create mode 100644 Menu/PersonMenuBuilder.php create mode 100644 Resources/config/services/menu.yml diff --git a/Controller/EventController.php b/Controller/EventController.php index 74fa339f2..986efc24d 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -224,4 +224,12 @@ class EventController extends Controller 'edit_form' => $editForm->createView(), )); } + + /** + * List events subscriptions for a person + * @param $person_id + */ + public function listByPersonAction($person_id) + { + } } diff --git a/DependencyInjection/ChillEventExtension.php b/DependencyInjection/ChillEventExtension.php index 1e0443899..1026b1e08 100644 --- a/DependencyInjection/ChillEventExtension.php +++ b/DependencyInjection/ChillEventExtension.php @@ -31,6 +31,7 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface $loader->load('authorization.yml'); $loader->load('forms.yml'); $loader->load('fixtures.yml'); + $loader->load('menu.yml'); } /* (non-PHPdoc) diff --git a/Menu/PersonMenuBuilder.php b/Menu/PersonMenuBuilder.php new file mode 100644 index 000000000..5ce5e8e65 --- /dev/null +++ b/Menu/PersonMenuBuilder.php @@ -0,0 +1,71 @@ +tokenStorage = $tokenStorage; + $this->translator = $translator; + $this->authorizationHelper = $authorizationHelper; + } + + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + /* @var $person \Chill\PersonBundle\Entity\Person */ + $person = $parameters['person']; + + $user = $this->tokenStorage->getToken()->getUser(); + $roleSee = new Role(EventVoter::SEE); + + // ASK use authorizationHelper or authorizationChecker ?? + if ($this->authorizationHelper->userHasAccess($user, $person, $roleSee)) { + + $menu->addChild($this->translator->trans('Events participation'), [ + 'route' => 'chill_event__list_by_person', + 'routeParameters' => [ + 'person_id' => $person->getId() + ] + ]) + ->setExtras([ + 'order' => 500 + ]); + } + } + + public static function getMenuIds(): array + { + return [ 'person' ]; + } +} \ No newline at end of file diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index 256850e5c..1bdb59e62 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -35,3 +35,7 @@ chill_event__event_update: path: /{event_id}/update defaults: { _controller: "ChillEventBundle:Event:update" } methods: [POST, PUT] + +chill_event__list_by_person: + path: /{person_id}/list + defaults: { _controller: "ChillEventBundle:Event:listByPerson" } diff --git a/Resources/config/services/menu.yml b/Resources/config/services/menu.yml new file mode 100644 index 000000000..209d208a7 --- /dev/null +++ b/Resources/config/services/menu.yml @@ -0,0 +1,8 @@ +services: + Chill\EventBundle\Menu\PersonMenuBuilder: + arguments: + $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' + $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' + $translator: '@Symfony\Component\Translation\TranslatorInterface' + tags: + - { name: 'chill.menu_builder' } \ No newline at end of file diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 992b1c2e0..08a62287f 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -39,6 +39,7 @@ Participation Edit: Modifier une participation There are no participation to edit for this event: Il n'y a pas de participation pour cet événement The participations have been successfully updated.: Les participations ont été mises à jour. The participations were created: Les participations ont été créées +Events participation: Participation aux événements #search Event search: Recherche d'événements From 735425f2fdb0d00464556524c96b789d658f77af Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 16 Jan 2019 16:24:09 +0100 Subject: [PATCH 089/179] template page for list events participation by person --- Controller/EventController.php | 20 ++++++++++++++ Resources/views/Event/listByPerson.html.twig | 28 ++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Resources/views/Event/listByPerson.html.twig diff --git a/Controller/EventController.php b/Controller/EventController.php index 986efc24d..474e2b14b 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -2,6 +2,7 @@ namespace Chill\EventBundle\Controller; +use Chill\EventBundle\Entity\Participation; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Chill\PersonBundle\Form\Type\PickPersonType; @@ -231,5 +232,24 @@ class EventController extends Controller */ public function listByPersonAction($person_id) { + $em = $this->getDoctrine()->getManager(); + + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + + if ($person === NULL) { + throw $this->createNotFoundException('Person not found'); + } + + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + + $participations = $em->getRepository('ChillEventBundle:Participation') + ->findBy( + array('person' => $person) + ); + + return $this->render('ChillEventBundle:Event:listByPerson.html.twig', array( + 'participations' => $participations, + 'person' => $person + )); } } diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig new file mode 100644 index 000000000..dc5b21706 --- /dev/null +++ b/Resources/views/Event/listByPerson.html.twig @@ -0,0 +1,28 @@ +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "ChillPersonBundle::layout.html.twig" %} + + +{% set activeRouteKey = 'chill_event__list_by_person' %} + +{% block title %}{{ 'Events participation' |trans }}{% endblock title %} + +{% block personcontent %} +

                                              {{ 'Events participation' |trans }}

                                              +hop + {{ dump() }} +{% endblock %} \ No newline at end of file From a9522d5b4b5150e384cf17732301d70257009374 Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 16 Jan 2019 16:27:03 +0100 Subject: [PATCH 090/179] add eventDispatcher for new page --- Controller/EventController.php | 23 +++++++++++++++++++++ DependencyInjection/ChillEventExtension.php | 1 + Resources/config/services/controller.yml | 5 +++++ 3 files changed, 29 insertions(+) create mode 100644 Resources/config/services/controller.yml diff --git a/Controller/EventController.php b/Controller/EventController.php index 474e2b14b..49f438713 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -3,6 +3,8 @@ namespace Chill\EventBundle\Controller; use Chill\EventBundle\Entity\Participation; +use Chill\PersonBundle\Privacy\PrivacyEvent; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Chill\PersonBundle\Form\Type\PickPersonType; @@ -20,6 +22,21 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType; */ class EventController extends Controller { + /** + * @var EventDispatcherInterface + */ + protected $eventDispatcher; + + /** + * EventController constructor. + * + * @param EventDispatcherInterface $eventDispatcher + */ + public function __construct(EventDispatcherInterface $eventDispatcher) + { + $this->eventDispatcher = $eventDispatcher; + } + public function mostRecentIndexAction() { @@ -247,6 +264,12 @@ class EventController extends Controller array('person' => $person) ); + $privacyEvent = new PrivacyEvent($person, array( + 'element_class' => Participation::class, + 'action' => 'list' + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $privacyEvent); + return $this->render('ChillEventBundle:Event:listByPerson.html.twig', array( 'participations' => $participations, 'person' => $person diff --git a/DependencyInjection/ChillEventExtension.php b/DependencyInjection/ChillEventExtension.php index 1026b1e08..8fe36b2e4 100644 --- a/DependencyInjection/ChillEventExtension.php +++ b/DependencyInjection/ChillEventExtension.php @@ -32,6 +32,7 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface $loader->load('forms.yml'); $loader->load('fixtures.yml'); $loader->load('menu.yml'); + $loader->load('controller.yml'); } /* (non-PHPdoc) diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml new file mode 100644 index 000000000..341bc9dcb --- /dev/null +++ b/Resources/config/services/controller.yml @@ -0,0 +1,5 @@ +services: + Chill\EventBundle\Controller\EventController: + arguments: + $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' + tags: ['controller.service_arguments'] From c861c48b376dea6e74f9a661abb92eab1eb07360 Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 16 Jan 2019 16:27:35 +0100 Subject: [PATCH 091/179] hop --- Form/EventType.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Form/EventType.php b/Form/EventType.php index df4744178..042acb125 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -72,8 +72,7 @@ class EventType extends AbstractType ->add('name') ->add('date', ChillDateTimeType::class, array( 'required' => true - ) - ) + )) ->add('center', EntityType::class, array( 'class' => Center::class, 'choices' => $userReachableCenters, From 7abf40346350ffa78396d8e17a5d423291f78804 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 17 Jan 2019 11:06:49 +0100 Subject: [PATCH 092/179] display table of events by person --- Menu/PersonMenuBuilder.php | 6 +- Resources/views/Event/listByPerson.html.twig | 77 +++++++++++++++++++- 2 files changed, 78 insertions(+), 5 deletions(-) diff --git a/Menu/PersonMenuBuilder.php b/Menu/PersonMenuBuilder.php index 5ce5e8e65..c7470fe2a 100644 --- a/Menu/PersonMenuBuilder.php +++ b/Menu/PersonMenuBuilder.php @@ -58,9 +58,9 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface 'person_id' => $person->getId() ] ]) - ->setExtras([ - 'order' => 500 - ]); + ->setExtras([ + 'order' => 500 + ]); } } diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index dc5b21706..f36278197 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -23,6 +23,79 @@ {% block personcontent %}

                                              {{ 'Events participation' |trans }}

                                              -hop - {{ dump() }} + + + + + + + + {# + + + #} + + + + + + + {% for participation in participations %} + + + + + {# + + + #} + + + + + {% endfor %} + +
                                              {{ 'Name'|trans }}{{ 'Date'|trans }}{{ 'Event type'|trans }}{{ 'Circle'|trans }}{{ 'Moderator'|trans }}{{ 'Role'|trans }}{{ 'Status'|trans }}
                                              + + {{ participation.event.name }} + + {{ participation.event.date|localizeddate('long', 'short') }}{{ participation.event.type.name|localize_translatable_string }}{{ participation.event.circle.name|localize_translatable_string }}{{ participation.event.moderator|trans|default('-') }}{{ participation.role.name|localize_translatable_string }}{{ participation.status.name|localize_translatable_string }} + +
                                              + + + +
                                              +/!\ dev notes
                                              +=============
                                              +- problème de cohérence avec le bouton voir et avec le bouton modifier
                                              +- checker les autorisations pour les boutons
                                              +- TODO pagination
                                              +- affichage différencié pour les événements passés/présents/futur
                                              +- person menu, utiliser authorizationHelper ou authorizationChecker ??
                                              +
                                              + +{# +{{ dump() }} +#} + {% endblock %} \ No newline at end of file From d07cbb15da434c6afef9a54172da30acbfaf72b0 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 17 Jan 2019 13:59:20 +0100 Subject: [PATCH 093/179] list events by person, add pagination --- Controller/EventController.php | 34 +++++++++++++++++--- Resources/views/Event/listByPerson.html.twig | 17 ++++++---- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index 49f438713..e98486ef7 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -259,11 +259,36 @@ class EventController extends Controller $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - $participations = $em->getRepository('ChillEventBundle:Participation') - ->findBy( - array('person' => $person) ); + $total = $em + ->createQuery(" + SELECT COUNT (participation.id) + FROM ChillEventBundle:Participation participation + WHERE participation.person = :person_id + ") + ->setParameter(':person_id', $person_id) + ->getSingleScalarResult(); + + /* @var $paginatorFactory \Chill\MainBundle\Pagination\PaginatorFactory */ + $paginatorFactory = $this->get('chill_main.paginator_factory'); + $paginator = $paginatorFactory->create($total); + + $participations = $em + ->createQuery(" + SELECT participation + FROM ChillEventBundle:Participation participation + WHERE participation.person = :person_id + ") + ->setParameters(array( + ':person_id' => $person_id, + )) + ->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber()) + ->setMaxResults($paginator->getItemsPerPage()) + ->getResult() + ; + + $privacyEvent = new PrivacyEvent($person, array( 'element_class' => Participation::class, 'action' => 'list' @@ -272,7 +297,8 @@ class EventController extends Controller return $this->render('ChillEventBundle:Event:listByPerson.html.twig', array( 'participations' => $participations, - 'person' => $person + 'person' => $person, + 'paginator' => $paginator )); } } diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index f36278197..2f553c284 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -58,11 +58,11 @@
                                              • - {# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #} - - {{ 'See'|trans }} - - {# {% endif %} #} + {% if is_granted('CHILL_EVENT_SEE_DETAILS', participation.event) %} #} + + {{ 'See'|trans }} + + {% endif %} {% if is_granted('CHILL_EVENT_UPDATE', participation.event) %} {{ 'Edit'|trans }} @@ -83,19 +83,22 @@ +{% if participations|length < paginator.getTotalItems %} + {{ chill_pagination(paginator) }} +{% endif %} +
                                                 /!\ dev notes
                                                 =============
                                                 - problème de cohérence avec le bouton voir et avec le bouton modifier
                                                 - checker les autorisations pour les boutons
                                                -- TODO pagination
                                                 - affichage différencié pour les événements passés/présents/futur
                                                 - person menu, utiliser authorizationHelper ou authorizationChecker ??
                                                 
                                                -{# {{ dump() }} +{# #} {% endblock %} \ No newline at end of file From 42c9a24472e1695aa148f8c9a54111152467d55a Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 17 Jan 2019 14:33:31 +0100 Subject: [PATCH 094/179] listByPerson, display only events for current circle --- Controller/EventController.php | 18 +++++++++++++++++- Resources/config/services/controller.yml | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index e98486ef7..fb5ea0052 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -3,6 +3,8 @@ namespace Chill\EventBundle\Controller; use Chill\EventBundle\Entity\Participation; +use Chill\EventBundle\Security\Authorization\EventVoter; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Privacy\PrivacyEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; @@ -27,14 +29,20 @@ class EventController extends Controller */ protected $eventDispatcher; + /** + * @var AuthorizationHelper + */ + protected $authorizationHelper; + /** * EventController constructor. * * @param EventDispatcherInterface $eventDispatcher */ - public function __construct(EventDispatcherInterface $eventDispatcher) + public function __construct(EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper) { $this->eventDispatcher = $eventDispatcher; + $this->authorizationHelper = $authorizationHelper; } @@ -259,6 +267,11 @@ class EventController extends Controller $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + $reachablesCircles = $this->authorizationHelper + ->getReachableCircles( + $this->getUser(), + new Role(EventVoter::SEE), + $person->getCenter() ); $total = $em @@ -278,10 +291,13 @@ class EventController extends Controller ->createQuery(" SELECT participation FROM ChillEventBundle:Participation participation + JOIN participation.event event WHERE participation.person = :person_id + AND event.circle IN (:reachable_circles) ") ->setParameters(array( ':person_id' => $person_id, + ':reachable_circles' => $reachablesCircles )) ->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber()) ->setMaxResults($paginator->getItemsPerPage()) diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml index 341bc9dcb..ed37ca7a6 100644 --- a/Resources/config/services/controller.yml +++ b/Resources/config/services/controller.yml @@ -2,4 +2,5 @@ services: Chill\EventBundle\Controller\EventController: arguments: $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' + $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' tags: ['controller.service_arguments'] From c235fb75a7a1670fabe0aed1a3173e4e591a1a4a Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 17 Jan 2019 15:13:02 +0100 Subject: [PATCH 095/179] sort events by date (DESC) --- Controller/EventController.php | 1 + Resources/views/Event/listByPerson.html.twig | 13 ++----------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index fb5ea0052..518c084c3 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -294,6 +294,7 @@ class EventController extends Controller JOIN participation.event event WHERE participation.person = :person_id AND event.circle IN (:reachable_circles) + ORDER BY event.date DESC ") ->setParameters(array( ':person_id' => $person_id, diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index 2f553c284..9c174bb92 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -30,10 +30,6 @@ {{ 'Name'|trans }} {{ 'Date'|trans }} {{ 'Event type'|trans }} - {# - {{ 'Circle'|trans }} - {{ 'Moderator'|trans }} - #} {{ 'Role'|trans }} {{ 'Status'|trans }} @@ -49,10 +45,6 @@ {{ participation.event.date|localizeddate('long', 'short') }} {{ participation.event.type.name|localize_translatable_string }} - {# - {{ participation.event.circle.name|localize_translatable_string }} - {{ participation.event.moderator|trans|default('-') }} - #} {{ participation.role.name|localize_translatable_string }} {{ participation.status.name|localize_translatable_string }} @@ -69,8 +61,7 @@
                                                {% endif %} {% if is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %} - + {{ 'Edit'|trans }} {% endif %} @@ -88,6 +79,7 @@ {% endif %} +{#
                                                 /!\ dev notes
                                                 =============
                                                @@ -98,7 +90,6 @@
                                                 
                                                {{ dump() }} -{# #} {% endblock %} \ No newline at end of file From f71e273aaee5263b617d74f8a9db930ba9527ba1 Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 21 Jan 2019 09:52:59 +0100 Subject: [PATCH 096/179] new event form, like edit form --- Resources/views/Event/edit.html.twig | 2 +- Resources/views/Event/new.html.twig | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Resources/views/Event/edit.html.twig b/Resources/views/Event/edit.html.twig index 164d75be5..34158ef88 100644 --- a/Resources/views/Event/edit.html.twig +++ b/Resources/views/Event/edit.html.twig @@ -25,7 +25,7 @@ {{ form_row(edit_form.moderator) }}
                                                  -
                                                • +
                                                • {{ 'Back to the most recent events'|trans }} diff --git a/Resources/views/Event/new.html.twig b/Resources/views/Event/new.html.twig index 1c29a495d..478e54ffd 100644 --- a/Resources/views/Event/new.html.twig +++ b/Resources/views/Event/new.html.twig @@ -10,13 +10,21 @@ {{ form_row(form.circle) }} {{ form_row(form.center) }} {{ form_row(form.name) }} + + {# TODO temporaire: chaque fois qu'on a une date + une heure, on veut afficher sur une seule ligne #} + {{ form_row(form.date) }} + {{ form_row(form.type, { 'label': 'Event type' }) }} + {{ form_row(form.moderator) }}
                                                    -
                                                  • +
                                                  • - {{ 'Back to the most recent events'|trans }}
                                                  • From 91124893fd5122301d1564de421e50f6cc885e99 Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 21 Jan 2019 10:38:43 +0100 Subject: [PATCH 097/179] improve actions buttons display for granted cases --- Resources/views/Event/listByPerson.html.twig | 65 ++++++++++---------- Resources/views/Participation/edit.html.twig | 2 +- Resources/views/Participation/new.html.twig | 2 +- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index 9c174bb92..daa5eb540 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -16,7 +16,6 @@ #} {% extends "ChillPersonBundle::layout.html.twig" %} - {% set activeRouteKey = 'chill_event__list_by_person' %} {% block title %}{{ 'Events participation' |trans }}{% endblock title %} @@ -38,11 +37,7 @@ {% for participation in participations %} - - - {{ participation.event.name }} - - + {{ participation.event.name }} {{ participation.event.date|localizeddate('long', 'short') }} {{ participation.event.type.name|localize_translatable_string }} {{ participation.role.name|localize_translatable_string }} @@ -50,20 +45,39 @@ @@ -73,23 +87,12 @@ - {% if participations|length < paginator.getTotalItems %} {{ chill_pagination(paginator) }} {% endif %} - {# -
                                                    -/!\ dev notes
                                                    -=============
                                                    -- problème de cohérence avec le bouton voir et avec le bouton modifier
                                                    -- checker les autorisations pour les boutons
                                                    -- affichage différencié pour les événements passés/présents/futur
                                                    -- person menu, utiliser authorizationHelper ou authorizationChecker ??
                                                    -
                                                    - -{{ dump() }} #} +{{ dump() }} {% endblock %} \ No newline at end of file diff --git a/Resources/views/Participation/edit.html.twig b/Resources/views/Participation/edit.html.twig index dd6df62ef..004108a26 100644 --- a/Resources/views/Participation/edit.html.twig +++ b/Resources/views/Participation/edit.html.twig @@ -27,7 +27,7 @@ {{ form_row(form.status) }}
                                                      -
                                                    • +
                                                    • {{ 'Back to the event'|trans }} diff --git a/Resources/views/Participation/new.html.twig b/Resources/views/Participation/new.html.twig index 7ec10fa5f..ba90e3eda 100644 --- a/Resources/views/Participation/new.html.twig +++ b/Resources/views/Participation/new.html.twig @@ -32,7 +32,7 @@
                                                        -
                                                      • +
                                                      • {{ 'Back to the event'|trans }} From 3c434852d56eae20b7868a3d4c18419d079079e0 Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 21 Jan 2019 15:42:25 +0100 Subject: [PATCH 098/179] actions buttons, set return values in url --- Resources/translations/messages.fr.yml | 1 + Resources/views/Event/edit.html.twig | 8 ++- Resources/views/Event/listByPerson.html.twig | 71 +++++++++++++++++--- Resources/views/Event/show.html.twig | 18 +++-- Resources/views/Participation/edit.html.twig | 8 ++- 5 files changed, 88 insertions(+), 18 deletions(-) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 08a62287f..cb9392ac0 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -18,6 +18,7 @@ Moderator: Animateur Details of an event: Détails d'un événement New event: Nouvel événement Back to the most recent events: Retour aux derniers événements +Back to the person events: Retour aux événements de la personne Event creation: Création d'un événement Add an event: Ajouter un événement Event edit: Modifier un événement diff --git a/Resources/views/Event/edit.html.twig b/Resources/views/Event/edit.html.twig index 34158ef88..a85995ebb 100644 --- a/Resources/views/Event/edit.html.twig +++ b/Resources/views/Event/edit.html.twig @@ -26,8 +26,12 @@
                                                        • - - {{ 'Back to the most recent events'|trans }} + + {% set returnPath = app.request.get('return_path') %} + {% set returnLabel = app.request.get('return_label') %} + + + {{ returnLabel |default('Back to the most recent events'|trans) }}
                                                        • diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index daa5eb540..4c17630e4 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -45,8 +45,46 @@ diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index c97342528..c5af27003 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -34,11 +34,19 @@

                                                          {{ 'Participations'|trans }}

                                                          diff --git a/Resources/views/Participation/edit.html.twig b/Resources/views/Participation/edit.html.twig index 004108a26..86b9422a2 100644 --- a/Resources/views/Participation/edit.html.twig +++ b/Resources/views/Participation/edit.html.twig @@ -28,8 +28,12 @@
                                                          • - - {{ 'Back to the event'|trans }} + + {% set returnPath = app.request.get('return_path') %} + {% set returnLabel = app.request.get('return_label') %} + + + {{ returnLabel |default('Back to the event'|trans) }}
                                                          • From 835ead6ccd28922b03165715b9019166ad9a19e5 Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 21 Jan 2019 16:43:02 +0100 Subject: [PATCH 099/179] dynamic back message in return values --- Resources/translations/messages.fr.yml | 2 +- Resources/views/Event/listByPerson.html.twig | 7 ++++--- Resources/views/Event/show.html.twig | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index cb9392ac0..ed5b31596 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -18,7 +18,7 @@ Moderator: Animateur Details of an event: Détails d'un événement New event: Nouvel événement Back to the most recent events: Retour aux derniers événements -Back to the person events: Retour aux événements de la personne +'Back to %person% events': Retour aux événements de %person% Event creation: Création d'un événement Add an event: Ajouter un événement Event edit: Modifier un événement diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index 4c17630e4..ea18e8d19 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -17,6 +17,7 @@ {% extends "ChillPersonBundle::layout.html.twig" %} {% set activeRouteKey = 'chill_event__list_by_person' %} +{% set currentPerson = person.firstName ~ ' ' ~ person.lastName %} {% block title %}{{ 'Events participation' |trans }}{% endblock title %} @@ -46,7 +47,7 @@
                                                            • {% set currentPath = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %} - {% set returnLabel = 'Back to the person events'|trans %} + {% set returnLabel = 'Back to %person% events'|trans({ '%person%' : currentPerson } ) %} {# temporaire -- TODO corriger EventVoter.php pour régler les autorisations sur les boutons, puis remplacer ci-dessous par le code commenté #} @@ -84,7 +85,7 @@ 'event_id' : participation.event.id, 'return_path' : currentPath, 'return_label' : returnLabel - } ) }}" class="sc-button bt-show"> + } ) }}" class="sc-button bt-show"> {% endif %} {% if is_granted('CHILL_EVENT_UPDATE', participation.event) @@ -145,7 +146,7 @@ {% endif %} {# -#} {{ dump() }} +#} {% endblock %} \ No newline at end of file diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index c5af27003..451c52e4e 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -34,8 +34,10 @@
                                                                + {% set returnPath = app.request.get('return_path') %} {% set returnLabel = app.request.get('return_label') %} + {% if returnPath and returnLabel %}
                                                              • {{ returnLabel }} From 15ff92257c3d758dc93efc120ea1d2996b38b32a Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 17 Jan 2019 16:21:35 +0100 Subject: [PATCH 100/179] wip.. adapt EventVoter to sf3 --- Menu/PersonMenuBuilder.php | 24 +--- Resources/config/services/authorization.yml | 2 + Resources/config/services/menu.yml | 3 +- Resources/views/Event/listByPerson.html.twig | 4 +- Security/Authorization/EventVoter.php | 117 ++++++++++++++----- 5 files changed, 103 insertions(+), 47 deletions(-) diff --git a/Menu/PersonMenuBuilder.php b/Menu/PersonMenuBuilder.php index c7470fe2a..130622c2c 100644 --- a/Menu/PersonMenuBuilder.php +++ b/Menu/PersonMenuBuilder.php @@ -2,21 +2,15 @@ namespace Chill\EventBundle\Menu; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Security\Core\Role\Role; use Knp\Menu\MenuItem; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; -use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\EventBundle\Security\Authorization\EventVoter; class PersonMenuBuilder implements LocalMenuBuilderInterface { - /** - * - * @var TokenStorageInterface - */ - protected $tokenStorage; /** * @@ -26,18 +20,16 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface /** * - * @var AuthorizationHelper + * @var AuthorizationCheckerInterface */ - protected $authorizationHelper; + protected $authorizationChecker; public function __construct( - AuthorizationHelper $authorizationHelper, - TokenStorageInterface $tokenStorage, + AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator ) { - $this->tokenStorage = $tokenStorage; + $this->authorizationChecker = $authorizationChecker; $this->translator = $translator; - $this->authorizationHelper = $authorizationHelper; } @@ -46,11 +38,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface /* @var $person \Chill\PersonBundle\Entity\Person */ $person = $parameters['person']; - $user = $this->tokenStorage->getToken()->getUser(); - $roleSee = new Role(EventVoter::SEE); - - // ASK use authorizationHelper or authorizationChecker ?? - if ($this->authorizationHelper->userHasAccess($user, $person, $roleSee)) { + if ($this->authorizationChecker->isGranted(EventVoter::SEE, $person)) { $menu->addChild($this->translator->trans('Events participation'), [ 'route' => 'chill_event__list_by_person', diff --git a/Resources/config/services/authorization.yml b/Resources/config/services/authorization.yml index d44f1e9d9..131469f65 100644 --- a/Resources/config/services/authorization.yml +++ b/Resources/config/services/authorization.yml @@ -2,7 +2,9 @@ services: chill_event.event_voter: class: Chill\EventBundle\Security\Authorization\EventVoter arguments: + - "@security.access.decision_manager" - "@chill.main.security.authorization.helper" + - "@logger" tags: - { name: chill.role } - { name: security.voter } diff --git a/Resources/config/services/menu.yml b/Resources/config/services/menu.yml index 209d208a7..a2451122f 100644 --- a/Resources/config/services/menu.yml +++ b/Resources/config/services/menu.yml @@ -1,8 +1,7 @@ services: Chill\EventBundle\Menu\PersonMenuBuilder: arguments: - $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' - $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' + $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' $translator: '@Symfony\Component\Translation\TranslatorInterface' tags: - { name: 'chill.menu_builder' } \ No newline at end of file diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index 9c174bb92..cc99cff4f 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -50,7 +50,8 @@
                                                                • - {% if is_granted('CHILL_EVENT_SEE_DETAILS', participation.event) %} #} + {# + {% if is_granted('CHILL_EVENT_SEE_DETAILS', participation.event) %} {{ 'See'|trans }} @@ -65,6 +66,7 @@ {{ 'Edit'|trans }} {% endif %} + #}
                                                                diff --git a/Security/Authorization/EventVoter.php b/Security/Authorization/EventVoter.php index 8f74e649a..77548f1a5 100644 --- a/Security/Authorization/EventVoter.php +++ b/Security/Authorization/EventVoter.php @@ -9,6 +9,10 @@ use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; use Chill\EventBundle\Entity\Event; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Entity\User; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; +use Psr\Log\LoggerInterface; + /** * Description of EventVoter @@ -18,53 +22,114 @@ use Chill\MainBundle\Entity\User; */ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { - const SEE = 'CHILL_EVENT_SEE'; const SEE_DETAILS = 'CHILL_EVENT_SEE_DETAILS'; const CREATE = 'CHILL_EVENT_CREATE'; const UPDATE = 'CHILL_EVENT_UPDATE'; + const ROLES = [ + self::SEE, + self::SEE_DETAILS, + self::CREATE, + self::UPDATE + ]; + + /** + * @var AuthorizationHelper + */ protected $authorizationHelper; - public function __construct(AuthorizationHelper $helper) + /** + * @var AccessDecisionManagerInterface + */ + protected $accessDecisionManager; + + /** + * @var LoggerInterface + */ + protected $logger; + + public function __construct( + AccessDecisionManagerInterface $accessDecisionManager, + AuthorizationHelper $authorizationHelper, + LoggerInterface $logger + ) { - $this->authorizationHelper = $helper; + $this->accessDecisionManager = $accessDecisionManager; + $this->authorizationHelper = $authorizationHelper; + $this->logger = $logger; } - protected function getSupportedAttributes() + public function supports($attribute, $subject) { - return array(self::SEE, self::SEE_DETAILS, - self::CREATE, self::UPDATE); + return ($subject instanceof Event && in_array($attribute, self::ROLES)) + || + ($subject instanceof Person && \in_array($attribute, [ self::CREATE, self::SEE ])) + || + (NULL === $subject && $attribute === self::SEE ) + ; } - - protected function getSupportedClasses() + + /** + * + * @param string $attribute + * @param Event $subject + * @param TokenInterface $token + * @return boolean + */ + protected function voteOnAttribute($attribute, $subject, TokenInterface $token) { - return array(Event::class); - } - - protected function isGranted($attribute, $event, $user = null) - { - if (!$user instanceof User) { - return false; - } + $this->logger->debug(sprintf("Voting from %s class", self::class)); - return $this->authorizationHelper->userHasAccess($user, $event, $attribute); + if (!$token->getUser() instanceof User) { + return false; + } + + if ($subject instanceof Event) { + if ($subject->getPerson() === null) { + throw new \LogicException("You should associate a person with event " + . "in order to check autorizations"); + } + $person = $subject->getPerson(); + + } elseif ($subject instanceof Person) { + $person = $subject; + + } else { + // subject is null. We check that at least one center is reachable + $centers = $this->authorizationHelper->getReachableCenters($token->getUser(), new Role($attribute)); + + return count($centers) > 0; + } + + if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $person)) { + + return false; + } + + return $this->authorizationHelper->userHasAccess( + $token->getUser(), + $subject, + $attribute + ); } - + + public function getRoles() { - return $this->getSupportedAttributes(); + return self::ROLES; + } + + public function getRolesWithHierarchy() + { + return [ + 'Event' => self::ROLES + ]; } public function getRolesWithoutScope() { - return null; + return []; } - - public function getRolesWithHierarchy() - { - return [ 'Event' => $this->getRoles() ]; - } - } From 1e082677de9c26d55ff7af2d4bc0cd407c1a0b36 Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 22 Jan 2019 12:05:11 +0100 Subject: [PATCH 101/179] return values of return values cases --- Resources/translations/messages.fr.yml | 1 + Resources/views/Event/show.html.twig | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index ed5b31596..6fb1545ba 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -16,6 +16,7 @@ Moderator: Animateur #CRUD event Details of an event: Détails d'un événement +Back to details of an event: Retour aux détails d'un événement New event: Nouvel événement Back to the most recent events: Retour aux derniers événements 'Back to %person% events': Retour aux événements de %person% diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 451c52e4e..a2b0cc130 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -42,13 +42,22 @@
                                                              • {{ returnLabel }}
                                                              • +
                                                              • + {{ 'Edit'|trans }} + +
                                                              • + {% else %} +
                                                              • + + {{ 'Edit'|trans }} + +
                                                              • {% endif %} -
                                                              • - - {{ 'Edit'|trans }} - -

                                                              {{ 'Participations'|trans }}

                                                              From a10d48642fa4ad8908ba4bc7e58be5248dfc5f09 Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 23 Jan 2019 09:11:53 +0100 Subject: [PATCH 102/179] wip.. corrections --- Resources/views/Event/listByPerson.html.twig | 2 +- Security/Authorization/EventVoter.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index cc99cff4f..f0337b300 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -50,7 +50,6 @@ diff --git a/Security/Authorization/EventVoter.php b/Security/Authorization/EventVoter.php index 77548f1a5..f3ef499f0 100644 --- a/Security/Authorization/EventVoter.php +++ b/Security/Authorization/EventVoter.php @@ -9,6 +9,7 @@ use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; use Chill\EventBundle\Entity\Event; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Entity\User; +use Chill\PersonBundle\Security\Authorization\PersonVoter; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; use Psr\Log\LoggerInterface; @@ -86,11 +87,11 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInter } if ($subject instanceof Event) { - if ($subject->getPerson() === null) { + if ($subject->getId() === null) { throw new \LogicException("You should associate a person with event " . "in order to check autorizations"); } - $person = $subject->getPerson(); + $person = $subject->getId(); // liaison event --> person } elseif ($subject instanceof Person) { $person = $subject; From f8caaafa5a30e8a51f323bcc331aad3f60d9b456 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 24 Jan 2019 16:21:29 +0100 Subject: [PATCH 103/179] add fixtures contents, event_types and ACL --- DataFixtures/ORM/LoadEventTypes.php | 155 +++++++++++++++++++++++++++- DataFixtures/ORM/LoadRolesACL.php | 17 ++- 2 files changed, 168 insertions(+), 4 deletions(-) diff --git a/DataFixtures/ORM/LoadEventTypes.php b/DataFixtures/ORM/LoadEventTypes.php index 4210ab02a..7fc384035 100644 --- a/DataFixtures/ORM/LoadEventTypes.php +++ b/DataFixtures/ORM/LoadEventTypes.php @@ -27,6 +27,9 @@ class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface public function load(ObjectManager $manager) { + /* + * Echange de savoirs + */ $type = (new EventType()) ->setActive(true) ->setName(array('fr' => 'Échange de savoirs', 'en' => 'Exchange of knowledge')) @@ -62,7 +65,9 @@ class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface ; $manager->persist($status); - + /* + * Formation + */ $type = (new EventType()) ->setActive(true) ->setName(array('fr' => 'Formation', 'en' => 'Course', 'nl' => 'Opleiding')) @@ -93,7 +98,9 @@ class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface ; $manager->persist($status); - + /* + * Visite + */ $type = (new EventType()) ->setActive(true) ->setName(array('fr' => 'Visite', 'en' => 'Visit')) @@ -130,8 +137,150 @@ class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface ->setType($type) ; $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Inscrit')) + ->setType($type) + ; + $manager->persist($status); + + /* + * Réunion + */ + $type = (new EventType()) + ->setActive(true) + ->setName(array('fr' => 'Réunion', 'en' => 'Meeting')) + ; + $manager->persist($type); + + $this->addReference('event_type_meeting', $type); + self::$refs[] = 'event_type_meeting'; + + $role = (new Role()) + ->setActive(true) + ->setName(array('fr' => 'Participant', 'nl' => 'Deelneemer', 'en' => 'Participant')) + ->setType($type) + ; + $manager->persist($role); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Présent')) + ->setType($type) + ; + $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Absent')) + ->setType($type) + ; + $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Excusé')) + ->setType($type) + ; + $manager->persist($status); + + /* + * Atelier + */ + $type = (new EventType()) + ->setActive(true) + ->setName(array('fr' => 'Atelier', 'en' => 'Workshop')) + ; + $manager->persist($type); + + $this->addReference('event_type_workshop', $type); + self::$refs[] = 'event_type_workshop'; + + $role = (new Role()) + ->setActive(true) + ->setName(array('fr' => 'Participant', 'nl' => 'Deelneemer', 'en' => 'Participant')) + ->setType($type) + ; + $manager->persist($role); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Présent')) + ->setType($type) + ; + $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Absent')) + ->setType($type) + ; + $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Excusé')) + ->setType($type) + ; + $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Inscrit')) + ->setType($type) + ; + $manager->persist($status); + + + /* + * Séance d'info + */ + $type = (new EventType()) + ->setActive(true) + ->setName(array('fr' => "Séance d'info", 'en' => 'Info')) + ; + $manager->persist($type); + + $this->addReference('event_type_info', $type); + self::$refs[] = 'event_type_info'; + + $role = (new Role()) + ->setActive(true) + ->setName(array('fr' => 'Participant', 'nl' => 'Deelneemer', 'en' => 'Participant')) + ->setType($type) + ; + $manager->persist($role); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Présent')) + ->setType($type) + ; + $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Absent')) + ->setType($type) + ; + $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Excusé')) + ->setType($type) + ; + $manager->persist($status); + + $status = (new Status()) + ->setActive(true) + ->setName(array('fr' => 'Inscrit')) + ->setType($type) + ; + $manager->persist($status); + $manager->flush(); } - } diff --git a/DataFixtures/ORM/LoadRolesACL.php b/DataFixtures/ORM/LoadRolesACL.php index 08c0a8feb..c2c698819 100644 --- a/DataFixtures/ORM/LoadRolesACL.php +++ b/DataFixtures/ORM/LoadRolesACL.php @@ -57,10 +57,12 @@ class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface } printf("Adding CHILL_EVENT_UPDATE & CHILL_EVENT_CREATE " - . "CHILL_EVENT_PARTICIPATION_UPDATE & CHILL_EVENT_PARTICIPATION_CREATE " + . "& CHILL_EVENT_PARTICIPATION_UPDATE & CHILL_EVENT_PARTICIPATION_CREATE " + . "& CHILL_EVENT_SEE & CHILL_EVENT_SEE_DETAILS " . "to %s " . "permission group, scope '%s' \n", $permissionsGroup->getName(), $scope->getName()['en']); + $roleScopeUpdate = (new RoleScope()) ->setRole('CHILL_EVENT_UPDATE') ->setScope($scope); @@ -69,6 +71,7 @@ class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface ->setScope($scope); $permissionsGroup->addRoleScope($roleScopeUpdate); $permissionsGroup->addRoleScope($roleScopeUpdate2); + $roleScopeCreate = (new RoleScope()) ->setRole('CHILL_EVENT_CREATE') ->setScope($scope); @@ -77,10 +80,22 @@ class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface ->setScope($scope); $permissionsGroup->addRoleScope($roleScopeCreate); $permissionsGroup->addRoleScope($roleScopeCreate2); + + $roleScopeSee = (new RoleScope()) + ->setRole('CHILL_EVENT_SEE') + ->setScope($scope); + $roleScopeSee2 = (new RoleScope()) + ->setRole('CHILL_EVENT_SEE_DETAILS') + ->setScope($scope); + $permissionsGroup->addRoleScope($roleScopeSee); + $permissionsGroup->addRoleScope($roleScopeSee2); + $manager->persist($roleScopeUpdate); $manager->persist($roleScopeUpdate2); $manager->persist($roleScopeCreate); $manager->persist($roleScopeCreate2); + $manager->persist($roleScopeSee); + $manager->persist($roleScopeSee2); } } From 07b5f2f2ff70255560e0d93a81b8ca3f95745d8c Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 25 Jan 2019 10:31:44 +0100 Subject: [PATCH 104/179] listByPerson: improve translations --- Resources/translations/messages.fr.yml | 5 ++++- Resources/views/Event/listByPerson.html.twig | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 6fb1545ba..48d8678ba 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -16,6 +16,7 @@ Moderator: Animateur #CRUD event Details of an event: Détails d'un événement +See details of the event: Voir les détails de l'événement Back to details of an event: Retour aux détails d'un événement New event: Nouvel événement Back to the most recent events: Retour aux derniers événements @@ -23,11 +24,14 @@ Back to the most recent events: Retour aux derniers événements Event creation: Création d'un événement Add an event: Ajouter un événement Event edit: Modifier un événement +Edit the event: Modifier l'événement The event was updated: L'événement a été modifié The event was created: L'événement a été créé #crud participation Edit all the participations: Modifier toutes les participations +Edit the participation: Modifier la participation +Participation Edit: Modifier une participation Add a participation: Ajouter un participant Participation creation: Ajouter une participation Associated person: Personne associée @@ -35,7 +39,6 @@ Associated event: Événement associé Back to the event: Retour à l'événement The participation was created: La participation a été créée The participation was updated: La participation a été mise à jour -Participation Edit: Modifier une participation 'None of the requested people may participate the event: they are maybe already participating.': 'Aucune des personnes indiquées ne peut être ajoutée à l''événement: elles sont peut-être déjà inscrites comme participantes.' 'The following people have been ignored because they are already participating on the event': '{1} La personne suivante a été ignorée parce qu''elle participe déjà à l''événement | ]1,Inf] Les personnes suivantes ont été ignorées parce qu''elles participent déjà à l''événement' There are no participation to edit for this event: Il n'y a pas de participation pour cet événement diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index ea18e8d19..8c31dad29 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -56,7 +56,7 @@ 'event_id' : participation.event.id, 'return_path' : currentPath, 'return_label' : returnLabel - }) }}" class="sc-button bt-show"> + }) }}" class="sc-button bt-show" title="{{ 'See details of the event'|trans }}">
                                                              @@ -66,14 +66,14 @@ 'event_id' : participation.event.id, 'return_path' : currentPath, 'return_label' : returnLabel - }) }}" class="sc-button bt-update">{{ 'Event edit'|trans }} + }) }}" class="sc-button bt-update">{{ 'Edit the event'|trans }} {{ 'Participation Edit'|trans }} + }) }}" class="sc-button bt-update">{{ 'Edit the participation'|trans }}
                                                              From 78acb56b43870c0ccf334d80d743cf8b74634008 Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 25 Jan 2019 11:17:29 +0100 Subject: [PATCH 105/179] move styles in new css, adapt webpack config --- Resources/public/css/chillevent.css | 4 ++++ Resources/views/Event/edit.html.twig | 7 ------- Resources/views/Event/new.html.twig | 7 ------- chill.webpack.config.js | 4 ++++ 4 files changed, 8 insertions(+), 14 deletions(-) create mode 100644 Resources/public/css/chillevent.css create mode 100644 chill.webpack.config.js diff --git a/Resources/public/css/chillevent.css b/Resources/public/css/chillevent.css new file mode 100644 index 000000000..fc2365989 --- /dev/null +++ b/Resources/public/css/chillevent.css @@ -0,0 +1,4 @@ +div#event_date { display: flex; flex-direction: row; flex-wrap: nowrap; } +div#event_date input#event_date_date { margin-right: 1em; } +div#event_date div#event_date_time { min-width: 140px; } + diff --git a/Resources/views/Event/edit.html.twig b/Resources/views/Event/edit.html.twig index a85995ebb..2e46b56de 100644 --- a/Resources/views/Event/edit.html.twig +++ b/Resources/views/Event/edit.html.twig @@ -12,13 +12,6 @@ {{ form_row(edit_form.center) }} {% endif %} {{ form_row(edit_form.name) }} - - {# TODO temporaire: chaque fois qu'on a une date + une heure, on veut afficher sur une seule ligne #} - {{ form_row(edit_form.date) }} {{ form_row(edit_form.type, { 'label': 'Event type' }) }} diff --git a/Resources/views/Event/new.html.twig b/Resources/views/Event/new.html.twig index 478e54ffd..33ffe6893 100644 --- a/Resources/views/Event/new.html.twig +++ b/Resources/views/Event/new.html.twig @@ -10,13 +10,6 @@ {{ form_row(form.circle) }} {{ form_row(form.center) }} {{ form_row(form.name) }} - - {# TODO temporaire: chaque fois qu'on a une date + une heure, on veut afficher sur une seule ligne #} - {{ form_row(form.date) }} {{ form_row(form.type, { 'label': 'Event type' }) }} diff --git a/chill.webpack.config.js b/chill.webpack.config.js new file mode 100644 index 000000000..b7cd46970 --- /dev/null +++ b/chill.webpack.config.js @@ -0,0 +1,4 @@ +// this file loads all assets from the Chill event bundle + +// css +require('./Resources/public/css/chillevent.css'); From a36c6125422a9e2dd57dbb2be1f8c9a04e93f599 Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 25 Jan 2019 13:29:47 +0100 Subject: [PATCH 106/179] invert sort list events --- Controller/EventController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index 518c084c3..c64f712f9 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -294,7 +294,7 @@ class EventController extends Controller JOIN participation.event event WHERE participation.person = :person_id AND event.circle IN (:reachable_circles) - ORDER BY event.date DESC + ORDER BY event.date ASC ") ->setParameters(array( ':person_id' => $person_id, From 1cf02cd1ccb42335dffcdedfad91ed05586e7bd8 Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 25 Jan 2019 13:30:07 +0100 Subject: [PATCH 107/179] correct moderator field select in new form --- Form/EventType.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Form/EventType.php b/Form/EventType.php index 042acb125..d7e4d4d65 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -3,7 +3,6 @@ namespace Chill\EventBundle\Form; use Chill\MainBundle\Form\Type\ChillDateTimeType; -use Chill\PersonBundle\Entity\Person; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; @@ -105,7 +104,7 @@ class EventType extends AbstractType )) ->add('type', PickEventType::class) ->add('moderator', EntityType::class, array( - 'class' => Person::class, + 'class' => User::class, 'required' => false, 'placeholder' => '' )) From 2d295d8e433164ae11e36e00155cf6ef3f80859b Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 25 Jan 2019 13:45:34 +0100 Subject: [PATCH 108/179] test --- Security/Authorization/EventVoter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Security/Authorization/EventVoter.php b/Security/Authorization/EventVoter.php index f3ef499f0..c41a200b1 100644 --- a/Security/Authorization/EventVoter.php +++ b/Security/Authorization/EventVoter.php @@ -91,7 +91,7 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInter throw new \LogicException("You should associate a person with event " . "in order to check autorizations"); } - $person = $subject->getId(); // liaison event --> person + $person = $subject->getId(); // liaison event --> person } elseif ($subject instanceof Person) { $person = $subject; From 31876ee8b6200027e1456ae7639de52695f55346 Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 25 Jan 2019 15:39:44 +0100 Subject: [PATCH 109/179] wip.. EVENT_SEE and _CREATE works in twig test, not in php test --- Menu/PersonMenuBuilder.php | 13 +++++++++++-- Resources/views/Event/listByPerson.html.twig | 7 +++++++ Security/Authorization/EventVoter.php | 15 ++++++--------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Menu/PersonMenuBuilder.php b/Menu/PersonMenuBuilder.php index 130622c2c..7411d482b 100644 --- a/Menu/PersonMenuBuilder.php +++ b/Menu/PersonMenuBuilder.php @@ -4,7 +4,6 @@ namespace Chill\EventBundle\Menu; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Security\Core\Role\Role; use Knp\Menu\MenuItem; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\EventBundle\Security\Authorization\EventVoter; @@ -36,7 +35,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface public function buildMenu($menuId, MenuItem $menu, array $parameters) { /* @var $person \Chill\PersonBundle\Entity\Person */ - $person = $parameters['person']; + $person = $parameters['person'] ?? null; if ($this->authorizationChecker->isGranted(EventVoter::SEE, $person)) { @@ -49,7 +48,17 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface ->setExtras([ 'order' => 500 ]); + } + //// + else { + dump('not see'); } + if ($this->authorizationChecker->isGranted(EventVoter::CREATE, $person)) { + dump('create'); + } else { + dump('not create'); + } + //// } public static function getMenuIds(): array diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index f0337b300..82742674f 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -50,6 +50,13 @@
                                                              • + {% if is_granted('CHILL_EVENT_SEE', participation.event) %} + see {% else %} not see + {% endif %} + {% if is_granted('CHILL_EVENT_CREATE', participation.event) %} + create {% else %} not create + {% endif %} + {% if is_granted('CHILL_EVENT_SEE_DETAILS', participation.event) %} {{ 'See'|trans }} diff --git a/Security/Authorization/EventVoter.php b/Security/Authorization/EventVoter.php index c41a200b1..0cdbabfb3 100644 --- a/Security/Authorization/EventVoter.php +++ b/Security/Authorization/EventVoter.php @@ -87,18 +87,15 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInter } if ($subject instanceof Event) { - if ($subject->getId() === null) { - throw new \LogicException("You should associate a person with event " - . "in order to check autorizations"); - } - $person = $subject->getId(); // liaison event --> person - + return $this->authorizationHelper->userHasAccess($token->getUser(), $subject, $attribute); + } elseif ($subject instanceof Person) { - $person = $subject; - + return $this->authorizationHelper->userHasAccess($token->getUser(), $subject, $attribute); + } else { // subject is null. We check that at least one center is reachable - $centers = $this->authorizationHelper->getReachableCenters($token->getUser(), new Role($attribute)); + $centers = $this->authorizationHelper + ->getReachableCenters($token->getUser(), new Role($attribute)); return count($centers) > 0; } From 29b764152836b7e83a6c484f1b94767cee2e675a Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 25 Jan 2019 18:01:37 +0100 Subject: [PATCH 110/179] Fix error on EventVoter --- Menu/PersonMenuBuilder.php | 10 ------- Resources/views/Event/listByPerson.html.twig | 7 ----- Security/Authorization/EventVoter.php | 29 +++++++++++++++----- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Menu/PersonMenuBuilder.php b/Menu/PersonMenuBuilder.php index 7411d482b..0133409b8 100644 --- a/Menu/PersonMenuBuilder.php +++ b/Menu/PersonMenuBuilder.php @@ -48,17 +48,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface ->setExtras([ 'order' => 500 ]); - } - //// - else { - dump('not see'); } - if ($this->authorizationChecker->isGranted(EventVoter::CREATE, $person)) { - dump('create'); - } else { - dump('not create'); - } - //// } public static function getMenuIds(): array diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index 82742674f..f0337b300 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -50,13 +50,6 @@
                                                                • - {% if is_granted('CHILL_EVENT_SEE', participation.event) %} - see {% else %} not see - {% endif %} - {% if is_granted('CHILL_EVENT_CREATE', participation.event) %} - create {% else %} not create - {% endif %} - {% if is_granted('CHILL_EVENT_SEE_DETAILS', participation.event) %} {{ 'See'|trans }} diff --git a/Security/Authorization/EventVoter.php b/Security/Authorization/EventVoter.php index 0cdbabfb3..ead7917a7 100644 --- a/Security/Authorization/EventVoter.php +++ b/Security/Authorization/EventVoter.php @@ -1,6 +1,20 @@ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ namespace Chill\EventBundle\Security\Authorization; @@ -9,16 +23,16 @@ use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; use Chill\EventBundle\Entity\Event; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Entity\User; +use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; use Psr\Log\LoggerInterface; - /** * Description of EventVoter * - * @author Julien Fastré + * @author Mathieu Jaumotte * @author Champs Libres */ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface @@ -93,23 +107,24 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInter return $this->authorizationHelper->userHasAccess($token->getUser(), $subject, $attribute); } else { + // subject is null. We check that at least one center is reachable $centers = $this->authorizationHelper ->getReachableCenters($token->getUser(), new Role($attribute)); return count($centers) > 0; } - + if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $person)) { - return false; } - + return $this->authorizationHelper->userHasAccess( $token->getUser(), $subject, $attribute ); + } From 6d2ea8caab471c60ae81c0e06a74c8755256e2f2 Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 25 Jan 2019 19:04:20 +0100 Subject: [PATCH 111/179] improve message translation --- Resources/translations/messages.fr.yml | 2 +- Resources/views/Event/show.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 48d8678ba..ed65e2df4 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -17,7 +17,7 @@ Moderator: Animateur #CRUD event Details of an event: Détails d'un événement See details of the event: Voir les détails de l'événement -Back to details of an event: Retour aux détails d'un événement +Back to details of the event: Retour aux détails de l'événement New event: Nouvel événement Back to the most recent events: Retour aux derniers événements 'Back to %person% events': Retour aux événements de %person% diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index a2b0cc130..a283add84 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -46,7 +46,7 @@ {{ 'Edit'|trans }}
                                                                • From fda14a52e0ad90c07c2bab6741f11e32456fdd2d Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 28 Jan 2019 17:51:51 +0100 Subject: [PATCH 112/179] add a first step to pick center in new event form --- Controller/EventController.php | 69 ++++++++++++++++++- Resources/config/routing/event.yml | 10 ++- Resources/config/services/controller.yml | 1 + Resources/translations/messages.fr.yml | 5 ++ Resources/views/Event/newPickCenter.html.twig | 26 +++++++ 5 files changed, 105 insertions(+), 6 deletions(-) create mode 100644 Resources/views/Event/newPickCenter.html.twig diff --git a/Controller/EventController.php b/Controller/EventController.php index c64f712f9..c0b64a5f0 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -16,6 +16,10 @@ use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; +use Chill\EventBundle\Form\Type\PickCenterType; +use Chill\MainBundle\Entity\Center; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Component\Form\FormFactoryInterface; /** @@ -34,15 +38,25 @@ class EventController extends Controller */ protected $authorizationHelper; + /** + * @var FormFactoryInterface + */ + protected $formFactoryInterface; + /** * EventController constructor. * * @param EventDispatcherInterface $eventDispatcher */ - public function __construct(EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper) + public function __construct( + EventDispatcherInterface $eventDispatcher, + AuthorizationHelper $authorizationHelper, + FormFactoryInterface $formFactoryInterface + ) { $this->eventDispatcher = $eventDispatcher; $this->authorizationHelper = $authorizationHelper; + $this->formFactoryInterface = $formFactoryInterface; } @@ -98,14 +112,63 @@ class EventController extends Controller return $form; } + + /** + * First step of new Event form + */ + public function newPickCenterAction() + { + $role = new Role('CHILL_EVENT_CREATE'); + /** @var Center $centers */ + $centers = $this->authorizationHelper->getReachableCenters($this->getUser(), $role); + + $form = $this->formFactoryInterface + ->createNamedBuilder(null) + ->setMethod('GET') + ->setAction( + $this->generateUrl('chill_event__event_new')) + ->add('center_id', EntityType::class, array( + 'class' => Center::class, + 'choices' => $centers, + 'placeholder' => '', + 'label' => 'To which centre should the event be associated ?' + )) + ->add('submit', SubmitType::class, array( + 'label' => 'Next step' + )) + ->getForm(); + + if (count($centers) === 1) + { + return $this->redirectToRoute('chill_event__event_new', array( + 'center_id' => $centers[0]->getId() + )); + } + + return $this->render('ChillEventBundle:Event:newPickCenter.html.twig', array( + 'form' => $form->createView() + )); + + } + /** * Displays a form to create a new Event entity. - * + * @param Center $center + * @param Request $request + * @return \Symfony\Component\HttpFoundation\Response */ - public function newAction() + public function newAction(Center $center = null, Request $request) { + if ($center === null) + { + $center_id = $request->query->get('center_id'); + $center = $this->getDoctrine()->getRepository(Center::class)->find($center_id); + } + $entity = new Event(); + $entity->setCenter($center); + $form = $this->createCreateForm($entity); return $this->render('ChillEventBundle:Event:new.html.twig', array( diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index 1bdb59e62..26ce81c2d 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -12,9 +12,9 @@ chill_event__event_show: path: /{event_id}/show defaults: { _controller: "ChillEventBundle:Event:show" } -chill_event__event_new: - path: /new - defaults: { _controller: "ChillEventBundle:Event:new" } +chill_event__event_new_pickcenter: + path: /new/pick-center + defaults: { _controller: "ChillEventBundle:Event:newPickCenter" } options: menus: section: @@ -22,6 +22,10 @@ chill_event__event_new: label: Add an event icons: [plus, calendar-o] +chill_event__event_new: + path: /new + defaults: { _controller: "ChillEventBundle:Event:new" } + chill_event__event_create: path: /create defaults: { _controller: "ChillEventBundle:Event:create" } diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml index ed37ca7a6..30e53e62d 100644 --- a/Resources/config/services/controller.yml +++ b/Resources/config/services/controller.yml @@ -3,4 +3,5 @@ services: arguments: $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' + $formFactoryInterface: '@Symfony\Component\Form\FormFactoryInterface' tags: ['controller.service_arguments'] diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index ed65e2df4..27a56aa80 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -56,3 +56,8 @@ CHILL_EVENT_PARTICIPATION_CREATE: Créer une participation à un événement CHILL_EVENT_PARTICIPATION_UPDATE: Modifier une participation à un événement CHILL_EVENT_SEE: Voir un événement CHILL_EVENT_SEE_DETAILS: Voir les détails d'un événement + +# TODO check place to put this +Next step: Étape suivante +To which centre should the event be associated ?: À quel centre doit être associé l'événement ? + diff --git a/Resources/views/Event/newPickCenter.html.twig b/Resources/views/Event/newPickCenter.html.twig new file mode 100644 index 000000000..753610009 --- /dev/null +++ b/Resources/views/Event/newPickCenter.html.twig @@ -0,0 +1,26 @@ +{% extends 'ChillEventBundle::layout.html.twig' %} + +{% block title 'Event creation'|trans %} + +{% block event_content -%} +

                                                                  {{ 'Event creation'|trans }}

                                                                  + + {{ form_start(form) }} + {{ form_errors(form) }} + + {{ form_row(form.center_id) }} + + + + {{ form_end(form) }} + +{% endblock %} From aa02597541777022ffb67a0a3c16be10a6cbf8e5 Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 29 Jan 2019 14:28:27 +0100 Subject: [PATCH 113/179] adapt select moderator field in new event form --- Controller/EventController.php | 24 ++++++++++++++- Form/EventType.php | 56 +++++++++++++++++++++++++--------- 2 files changed, 64 insertions(+), 16 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index c0b64a5f0..3925023bb 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -1,5 +1,25 @@ , + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + namespace Chill\EventBundle\Controller; use Chill\EventBundle\Entity\Participation; @@ -105,7 +125,9 @@ class EventController extends Controller { $form = $this->createForm(EventType::class, $entity, array( 'action' => $this->generateUrl('chill_event__event_create'), - 'method' => 'POST' + 'method' => 'POST', + 'center' => $entity->getCenter(), + 'role' => new Role('CHILL_EVENT_CREATE') )); $form->add('submit', SubmitType::class, array('label' => 'Create')); diff --git a/Form/EventType.php b/Form/EventType.php index d7e4d4d65..645461e8d 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -1,21 +1,42 @@ , + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + namespace Chill\EventBundle\Form; -use Chill\MainBundle\Form\Type\ChillDateTimeType; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; use Chill\EventBundle\Form\Type\PickEventType; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Chill\MainBundle\Security\Authorization\AuthorizationHelper; -use Doctrine\Common\Persistence\ObjectManager; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Entity\User; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Scope; - +use Chill\MainBundle\Form\Type\ChillDateTimeType; +use Chill\MainBundle\Form\Type\UserPickerType; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityRepository; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Role\Role; class EventType extends AbstractType @@ -76,6 +97,7 @@ class EventType extends AbstractType 'class' => Center::class, 'choices' => $userReachableCenters, 'attr' => array('class' => 'select2 chill-category-link-parent'), + 'disabled' => true, 'choice_attr' => function (Center $center) { return array( 'class' => ' chill-category-link-parent', @@ -103,22 +125,26 @@ class EventType extends AbstractType }, )) ->add('type', PickEventType::class) - ->add('moderator', EntityType::class, array( - 'class' => User::class, - 'required' => false, - 'placeholder' => '' + ->add('moderator', UserPickerType::class, array( + 'center' => $options['center'], + 'role' => $options['role'] )) ; } /** - * @param OptionsResolverInterface $resolver + * @param OptionsResolver $resolver */ - public function setDefaultOptions(OptionsResolverInterface $resolver) + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'data_class' => 'Chill\EventBundle\Entity\Event' )); + $resolver + ->setRequired(array('center', 'role')) + ->setAllowedTypes('center', Center::class) + ->setAllowedTypes('role', Role::class) + ; } /** From ed3f0e9657b1f299982b50dd7c6e0f09d7c83dc5 Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 1 Feb 2019 15:23:54 +0100 Subject: [PATCH 114/179] remove center field of event form --- Form/EventType.php | 12 ------------ Resources/views/Event/edit.html.twig | 3 --- Resources/views/Event/new.html.twig | 1 - 3 files changed, 16 deletions(-) diff --git a/Form/EventType.php b/Form/EventType.php index 645461e8d..e7859a3b0 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -93,18 +93,6 @@ class EventType extends AbstractType ->add('date', ChillDateTimeType::class, array( 'required' => true )) - ->add('center', EntityType::class, array( - 'class' => Center::class, - 'choices' => $userReachableCenters, - 'attr' => array('class' => 'select2 chill-category-link-parent'), - 'disabled' => true, - 'choice_attr' => function (Center $center) { - return array( - 'class' => ' chill-category-link-parent', - 'data-link-category' => $center->getId() - ); - }, - )) ->add('circle', EntityType::class, array( 'class' => Scope::class, 'choices' => array_values($userReachableCirclesByCircleId), diff --git a/Resources/views/Event/edit.html.twig b/Resources/views/Event/edit.html.twig index 2e46b56de..a5b69a420 100644 --- a/Resources/views/Event/edit.html.twig +++ b/Resources/views/Event/edit.html.twig @@ -8,9 +8,6 @@ {{ form_start(edit_form) }} {{ form_errors(edit_form) }} {{ form_row(edit_form.circle) }} - {% if edit_form.center is defined %} - {{ form_row(edit_form.center) }} - {% endif %} {{ form_row(edit_form.name) }} {{ form_row(edit_form.date) }} diff --git a/Resources/views/Event/new.html.twig b/Resources/views/Event/new.html.twig index 33ffe6893..2da0a6bac 100644 --- a/Resources/views/Event/new.html.twig +++ b/Resources/views/Event/new.html.twig @@ -8,7 +8,6 @@ {{ form_start(form) }} {{ form_errors(form) }} {{ form_row(form.circle) }} - {{ form_row(form.center) }} {{ form_row(form.name) }} {{ form_row(form.date) }} From c7ee9b8ebbffecca9c3659c0b185226f9c7c3d16 Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 1 Feb 2019 15:26:54 +0100 Subject: [PATCH 115/179] correction of moderator relation (user not person) --- Resources/config/doctrine/Event.orm.yml | 2 +- .../migrations/Version20190201143121.php | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 Resources/migrations/Version20190201143121.php diff --git a/Resources/config/doctrine/Event.orm.yml b/Resources/config/doctrine/Event.orm.yml index 88bc2e9d1..7dabeb880 100644 --- a/Resources/config/doctrine/Event.orm.yml +++ b/Resources/config/doctrine/Event.orm.yml @@ -25,6 +25,6 @@ Chill\EventBundle\Entity\Event: circle: targetEntity: Chill\MainBundle\Entity\Scope moderator: - targetEntity: Chill\PersonBundle\Entity\Person + targetEntity: Chill\MainBundle\Entity\User lifecycleCallbacks: { } diff --git a/Resources/migrations/Version20190201143121.php b/Resources/migrations/Version20190201143121.php new file mode 100644 index 000000000..3687e4c2d --- /dev/null +++ b/Resources/migrations/Version20190201143121.php @@ -0,0 +1,31 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_event_event DROP CONSTRAINT FK_FA320FC8D0AFA354'); + $this->addSql('ALTER TABLE chill_event_event ADD CONSTRAINT FK_FA320FC8D0AFA354 FOREIGN KEY (moderator_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_event_event DROP CONSTRAINT fk_fa320fc8d0afa354'); + $this->addSql('ALTER TABLE chill_event_event ADD CONSTRAINT fk_fa320fc8d0afa354 FOREIGN KEY (moderator_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + + } +} From 4578625bb2311484dbae9a53a549d9bc3adacbde Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 1 Feb 2019 16:09:31 +0100 Subject: [PATCH 116/179] controller: merge newAction and createAction --- Controller/EventController.php | 40 +++++++++--------------------- Resources/config/routing/event.yml | 6 +---- 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index 3925023bb..4218dbedb 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -86,33 +86,6 @@ class EventController extends Controller 'q' => '@event' )); } - - /** - * Creates a new Event entity. - * - */ - public function createAction(Request $request) - { - $entity = new Event(); - $form = $this->createCreateForm($entity); - $form->handleRequest($request); - - if ($form->isValid()) { - $em = $this->getDoctrine()->getManager(); - $em->persist($entity); - $em->flush(); - - $this->addFlash('success', $this->get('translator') - ->trans('The event was created')); - - return $this->redirect($this->generateUrl('chill_event__event_show', array('event_id' => $entity->getId()))); - } - - return $this->render('ChillEventBundle:Event:new.html.twig', array( - 'entity' => $entity, - 'form' => $form->createView(), - )); - } /** * Creates a form to create a Event entity. @@ -124,7 +97,6 @@ class EventController extends Controller private function createCreateForm(Event $entity) { $form = $this->createForm(EventType::class, $entity, array( - 'action' => $this->generateUrl('chill_event__event_create'), 'method' => 'POST', 'center' => $entity->getCenter(), 'role' => new Role('CHILL_EVENT_CREATE') @@ -192,6 +164,18 @@ class EventController extends Controller $entity->setCenter($center); $form = $this->createCreateForm($entity); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($entity); + $em->flush(); + + $this->addFlash('success', $this->get('translator') + ->trans('The event was created')); + + return $this->redirect($this->generateUrl('chill_event__event_show', array('event_id' => $entity->getId()))); + } return $this->render('ChillEventBundle:Event:new.html.twig', array( 'entity' => $entity, diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index 26ce81c2d..20580c37a 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -25,11 +25,7 @@ chill_event__event_new_pickcenter: chill_event__event_new: path: /new defaults: { _controller: "ChillEventBundle:Event:new" } - -chill_event__event_create: - path: /create - defaults: { _controller: "ChillEventBundle:Event:create" } - methods: POST + methods: [ GET, POST ] chill_event__event_edit: path: /{event_id}/edit From 156f306daa63b10e49bc0a09caef76167cb6ace7 Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 1 Feb 2019 16:13:43 +0100 Subject: [PATCH 117/179] improve form attributes --- Controller/EventController.php | 17 +++++++++-------- Form/EventType.php | 4 +++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index 4218dbedb..a31f3cc52 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -117,6 +117,13 @@ class EventController extends Controller /** @var Center $centers */ $centers = $this->authorizationHelper->getReachableCenters($this->getUser(), $role); + if (count($centers) === 1) + { + return $this->redirectToRoute('chill_event__event_new', array( + 'center_id' => $centers[0]->getId() + )); + } + $form = $this->formFactoryInterface ->createNamedBuilder(null) ->setMethod('GET') @@ -126,19 +133,13 @@ class EventController extends Controller 'class' => Center::class, 'choices' => $centers, 'placeholder' => '', - 'label' => 'To which centre should the event be associated ?' + 'label' => 'To which centre should the event be associated ?', + 'csrf_protection' => false // works ?! )) ->add('submit', SubmitType::class, array( 'label' => 'Next step' )) ->getForm(); - - if (count($centers) === 1) - { - return $this->redirectToRoute('chill_event__event_new', array( - 'center_id' => $centers[0]->getId() - )); - } return $this->render('ChillEventBundle:Event:newPickCenter.html.twig', array( 'form' => $form->createView() diff --git a/Form/EventType.php b/Form/EventType.php index e7859a3b0..6e60b5199 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -115,7 +115,9 @@ class EventType extends AbstractType ->add('type', PickEventType::class) ->add('moderator', UserPickerType::class, array( 'center' => $options['center'], - 'role' => $options['role'] + 'role' => $options['role'], + 'placeholder' => '', + 'required' => false )) ; } From 8bf4621911870a873f504a381bf4a568be37ca5c Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 1 Feb 2019 16:17:24 +0100 Subject: [PATCH 118/179] were missing role and center in edit form --- Controller/EventController.php | 43 ++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index a31f3cc52..8a16b6b6c 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -87,26 +87,7 @@ class EventController extends Controller )); } - /** - * Creates a form to create a Event entity. - * - * @param Event $entity The entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createCreateForm(Event $entity) - { - $form = $this->createForm(EventType::class, $entity, array( - 'method' => 'POST', - 'center' => $entity->getCenter(), - 'role' => new Role('CHILL_EVENT_CREATE') - )); - - $form->add('submit', SubmitType::class, array('label' => 'Create')); - - return $form; - } - + /** * First step of new Event form */ @@ -147,6 +128,26 @@ class EventController extends Controller } + /** + * Creates a form to create a Event entity. + * + * @param Event $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createCreateForm(Event $entity) + { + $form = $this->createForm(EventType::class, $entity, array( + 'method' => 'POST', + 'center' => $entity->getCenter(), + 'role' => new Role('CHILL_EVENT_CREATE') + )); + + $form->add('submit', SubmitType::class, array('label' => 'Create')); + + return $form; + } + /** * Displays a form to create a new Event entity. * @param Center $center @@ -281,6 +282,8 @@ class EventController extends Controller $form = $this->createForm(EventType::class, $entity, array( 'action' => $this->generateUrl('chill_event__event_update', array('event_id' => $entity->getId())), 'method' => 'PUT', + 'center' => $entity->getCenter(), + 'role' => new Role('CHILL_EVENT_CREATE') )); $form->remove('center'); From 2ff22a73fa93440d1266ae8db41c2437c8c3ec46 Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 8 Feb 2019 16:39:12 +0100 Subject: [PATCH 119/179] add and display events in history timeline --- DependencyInjection/ChillEventExtension.php | 1 + Resources/config/services/timeline.yml | 9 + Resources/views/EventReason/macro.html.twig | 3 + .../Timeline/event_person_context.html.twig | 61 +++++ Timeline/TimelineEventProvider.php | 242 ++++++++++++++++++ 5 files changed, 316 insertions(+) create mode 100644 Resources/config/services/timeline.yml create mode 100644 Resources/views/EventReason/macro.html.twig create mode 100644 Resources/views/Timeline/event_person_context.html.twig create mode 100644 Timeline/TimelineEventProvider.php diff --git a/DependencyInjection/ChillEventExtension.php b/DependencyInjection/ChillEventExtension.php index 8fe36b2e4..462b17dd6 100644 --- a/DependencyInjection/ChillEventExtension.php +++ b/DependencyInjection/ChillEventExtension.php @@ -33,6 +33,7 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface $loader->load('fixtures.yml'); $loader->load('menu.yml'); $loader->load('controller.yml'); + $loader->load('timeline.yml'); } /* (non-PHPdoc) diff --git a/Resources/config/services/timeline.yml b/Resources/config/services/timeline.yml new file mode 100644 index 000000000..44efe2205 --- /dev/null +++ b/Resources/config/services/timeline.yml @@ -0,0 +1,9 @@ +services: + chill.event.timeline: + class: Chill\EventBundle\Timeline\TimelineEventProvider + arguments: + - '@doctrine.orm.entity_manager' + - '@chill.main.security.authorization.helper' + - '@security.token_storage' + tags: + - { name: chill.timeline, context: 'person' } diff --git a/Resources/views/EventReason/macro.html.twig b/Resources/views/EventReason/macro.html.twig new file mode 100644 index 000000000..c9e3e3729 --- /dev/null +++ b/Resources/views/EventReason/macro.html.twig @@ -0,0 +1,3 @@ +{%- macro reason(r) -%} +  {{ r.name | localize_translatable_string }} +{%- endmacro -%} \ No newline at end of file diff --git a/Resources/views/Timeline/event_person_context.html.twig b/Resources/views/Timeline/event_person_context.html.twig new file mode 100644 index 000000000..ff4e7723a --- /dev/null +++ b/Resources/views/Timeline/event_person_context.html.twig @@ -0,0 +1,61 @@ +{% import 'ChillEventBundle:EventReason:macro.html.twig' as m %} + +{{ dump() }} +{% for participation in event.participations %} + {{ participation.id }} ---> + {{ participation.lastupdate|localizeddate('long', 'none') }} +
                                                                  +{% endfor %} + +{# +TODO +- user a inscrit la personne à l'événement machin +- user a modifié le statut de la personne inscrite à l'événement machin. nouveau statut : +- user a modifié le rôle de la personne inscrite à l'événement machin. nouveau rôle : +- participation de la personne à l'événement machin +#} + +
                                                                  +

                                                                  {{ event.date|localizeddate('long', 'none') }} / {{ 'Event'|trans }}

                                                                  +
                                                                  + {{ '%user% has done an %event_type%'|trans( + { + '%user%' : user, + '%event_type%': event.type.name|localize_translatable_string, + '%date%' : event.date|localizeddate('long', 'none') } + ) }} + + + {% if is_granted(constant('Chill\\ActivityBundle\\Security\\Authorization\\ActivityVoter::SEE_DETAILS'), event) %} +
                                                                  +
                                                                  {{ 'Remark'|trans }}
                                                                  +
                                                                  {% if event.remark is empty %}{{ 'No remarks'|trans }}{% else %}
                                                                  {{ event.remark|nl2br }}
                                                                  {% endif %}
                                                                  + +
                                                                  {{ 'Reasons'|trans }}
                                                                  + {%- if event.reasons is empty -%} +
                                                                  {{ 'No reason associated'|trans }}
                                                                  + {%- else -%} +
                                                                  {% for r in event.reasons %}{{ m.reason(r) }} {% endfor %}
                                                                  + {%- endif -%} + +
                                                                  + {% endif %} + +
                                                                  + + +
                                                                  diff --git a/Timeline/TimelineEventProvider.php b/Timeline/TimelineEventProvider.php new file mode 100644 index 000000000..a718882d4 --- /dev/null +++ b/Timeline/TimelineEventProvider.php @@ -0,0 +1,242 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\EventBundle\Timeline; + +use Chill\EventBundle\Entity\Event; +use Chill\MainBundle\Entity\Scope; +use Chill\MainBundle\Timeline\TimelineProviderInterface; +use Doctrine\ORM\EntityManager; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; +use Symfony\Component\Security\Core\Role\Role; +use Doctrine\ORM\Mapping\ClassMetadata; +use Chill\PersonBundle\Entity\Person; +use Chill\MainBundle\Entity\User; + +/** + * Class TimelineEventProvider + * + * @package Chill\EventBundle\Timeline + * @author Mathieu Jaumotte jaum_mathieu@collectifs.net + */ +class TimelineEventProvider implements TimelineProviderInterface +{ + /** + * @var EntityManager + */ + protected $em; + + /** + * @var AuthorizationHelper + */ + protected $helper; + + /** + * @var User + */ + protected $user; + + /** + * TimelineEventProvider constructor. + * + * @param EntityManager $em + * @param AuthorizationHelper $helper + * @param TokenStorage $storage + */ + public function __construct( + EntityManager $em, + AuthorizationHelper $helper, + TokenStorage $storage + ) { + $this->em = $em; + $this->helper = $helper; + if (!$storage->getToken()->getUser() instanceof User) { + throw new \RuntimeException('A user should be authenticated !'); + } + $this->user = $storage->getToken()->getUser(); + } + + /** + * @param string $context + * @param array $args + * @return array|string[] + * @throws \Doctrine\ORM\Mapping\MappingException + */ + public function fetchQuery($context, array $args) + { + $this->checkContext($context); + + $metadataEvent = $this->em->getClassMetadata('ChillEventBundle:Event'); + $metadataParticipation = $this->em->getClassMetadata('ChillEventBundle:Participation'); + $metadataPerson = $this->em->getClassMetadata('ChillPersonBundle:Person'); + + $query = array( + 'id' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('id'), + 'type' => 'event', + 'date' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('date'), + 'FROM' => $this->getFromClause($metadataEvent, $metadataParticipation, $metadataPerson), + 'WHERE' => $this->getWhereClause($metadataEvent, $metadataParticipation, $metadataPerson, $args['person']) + ); + + dump($query); + return $query; + } + + /** + * @param ClassMetadata $metadataEvent + * @param ClassMetadata $metadataParticipation + * @param ClassMetadata $metadataPerson + * @return string + * @throws \Doctrine\ORM\Mapping\MappingException + */ + private function getFromClause( + ClassMetadata $metadataEvent, + ClassMetadata $metadataParticipation, + ClassMetadata $metadataPerson + ) { + $eventParticipationMapping = $metadataParticipation->getAssociationMapping('event'); + $participationPersonMapping = $metadataParticipation->getAssociationMapping('person'); + + return $metadataEvent->getTableName() + + .' JOIN '.$metadataParticipation->getTableName() + .' ON ' .$metadataParticipation->getTableName() + .'.' .$eventParticipationMapping['joinColumns'][0]['name'] + .' = ' .$metadataEvent->getTableName() + .'.' .$eventParticipationMapping['joinColumns'][0]['referencedColumnName'] + + .' JOIN '.$metadataPerson->getTableName() + .' ON ' .$metadataPerson->getTableName() + .'.' .$participationPersonMapping['joinColumns'][0]['referencedColumnName'] + .' = ' .$metadataParticipation->getTableName() + .'.' .$participationPersonMapping['joinColumns'][0]['name'] + ; + } + + /** + * @param ClassMetadata $metadataEvent + * @param ClassMetadata $metadataParticipation + * @param ClassMetadata $metadataPerson + * @param Person $person + * @return string + * @throws \Doctrine\ORM\Mapping\MappingException + */ + private function getWhereClause( + ClassMetadata $metadataEvent, + ClassMetadata $metadataParticipation, + ClassMetadata $metadataPerson, + Person $person + ) { + $role = new Role('CHILL_EVENT_SEE'); + + $reachableCenters = $this->helper->getReachableCenters($this->user, $role); + $associationMapping = $metadataParticipation->getAssociationMapping('person'); + + if (count($reachableCenters) === 0) { + return 'FALSE = TRUE'; + } + + $whereClause = sprintf( '%s = %d', + $associationMapping['joinColumns'][0]['name'], + $person->getId()); + + // and + $centerAndScopeLines = array(); + foreach ($reachableCenters as $center) { + $reachableCircleId = array_map( + function (Scope $scope) { return $scope->getId(); }, + $this->helper->getReachableCircles($this->user, $role, $person->getCenter()) + ); + $centerAndScopeLines[] = sprintf( + '(%s = %d AND %s IN (%s))', + $metadataPerson->getTableName() . '.' . + $metadataPerson->getAssociationMapping('center')['joinColumns'][0]['name'], + $center->getId(), + $metadataEvent->getTableName() . '.' . + $metadataEvent->getAssociationMapping('circle')['joinColumns'][0]['name'], + implode(',', $reachableCircleId) + ); + } + $whereClause .= ' AND ('. implode(' OR ', $centerAndScopeLines) .')'; + + return $whereClause; + } + + /** + * check if the context is supported + * + * @param string $context + * @throws \LogicException if the context is not supported + */ + private function checkContext($context) + { + if ($context !== 'person') { + throw new \LogicException("The context '$context' is not " + . "supported. Currently only 'person' is supported"); + } + } + + /** + * @param string $type + * @return bool + */ + public function supportsType($type) + { + return $type === 'event'; + } + + /** + * @param array $ids + * @return array|mixed[] + */ + public function getEntities(array $ids) { + + $events = $this->em->getRepository(Event::class) + ->findBy(array('id' => $ids)); + + $result = array(); + foreach ($events as $event) { + $result[$event->getId()] = $event; + } + return $result; + } + + /** + * @param Event $entity + * @param string $context + * @param array $args + * @return array|mixed[] + */ + public function getEntityTemplate($entity, $context, array $args) { + + $this->checkContext($context); + + return array( + 'template' => 'ChillEventBundle:Timeline:event_person_context.html.twig', + 'template_data' => array( + 'event' => $entity, + 'person' => $args['person'], + 'user' => $this->user + ) + ); + } + +} \ No newline at end of file From b2b6cb6d6ae8e6466a031772d9ad1c47cd4ae3e4 Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 8 Feb 2019 17:29:00 +0100 Subject: [PATCH 120/179] disable csrf_protection on first step new event form --- Controller/EventController.php | 51 ++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index 8a16b6b6c..d10b561b2 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -3,7 +3,7 @@ /* * Chill is a software for social workers * - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + * Copyright (C) 2014-2019, Champs Libres Cooperative SCRLFS, * , * * This program is free software: you can redistribute it and/or modify @@ -36,7 +36,6 @@ use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Chill\EventBundle\Form\Type\PickCenterType; use Chill\MainBundle\Entity\Center; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormFactoryInterface; @@ -62,11 +61,13 @@ class EventController extends Controller * @var FormFactoryInterface */ protected $formFactoryInterface; - + /** * EventController constructor. * * @param EventDispatcherInterface $eventDispatcher + * @param AuthorizationHelper $authorizationHelper + * @param FormFactoryInterface $formFactoryInterface */ public function __construct( EventDispatcherInterface $eventDispatcher, @@ -95,7 +96,9 @@ class EventController extends Controller { $role = new Role('CHILL_EVENT_CREATE'); - /** @var Center $centers */ + /** + * @var Center $centers + */ $centers = $this->authorizationHelper->getReachableCenters($this->getUser(), $role); if (count($centers) === 1) @@ -106,7 +109,9 @@ class EventController extends Controller } $form = $this->formFactoryInterface - ->createNamedBuilder(null) + ->createNamedBuilder(null, FormType::class, null, array( + 'csrf_protection' => false + )) ->setMethod('GET') ->setAction( $this->generateUrl('chill_event__event_new')) @@ -114,8 +119,7 @@ class EventController extends Controller 'class' => Center::class, 'choices' => $centers, 'placeholder' => '', - 'label' => 'To which centre should the event be associated ?', - 'csrf_protection' => false // works ?! + 'label' => 'To which centre should the event be associated ?' )) ->add('submit', SubmitType::class, array( 'label' => 'Next step' @@ -132,8 +136,7 @@ class EventController extends Controller * Creates a form to create a Event entity. * * @param Event $entity The entity - * - * @return \Symfony\Component\Form\Form The form + * @return \Symfony\Component\Form\FormInterface */ private function createCreateForm(Event $entity) { @@ -188,13 +191,15 @@ class EventController extends Controller /** * Finds and displays a Event entity. * + * @param $event_id + * @return \Symfony\Component\HttpFoundation\Response */ public function showAction($event_id) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository('ChillEventBundle:Event')->find($event_id); - + if (!$entity) { throw $this->createNotFoundException('Unable to find Event entity.'); } @@ -212,7 +217,8 @@ class EventController extends Controller /** * create a form to add a participation with a person - * + * + * @param Event $event * @return \Symfony\Component\Form\FormInterface */ protected function createAddParticipationByPersonForm(Event $event) @@ -251,6 +257,8 @@ class EventController extends Controller /** * Displays a form to edit an existing Event entity. * + * @param $event_id + * @return \Symfony\Component\HttpFoundation\Response */ public function editAction($event_id) { @@ -271,12 +279,11 @@ class EventController extends Controller } /** - * Creates a form to edit a Event entity. - * - * @param Event $entity The entity - * - * @return \Symfony\Component\Form\Form The form - */ + * Creates a form to edit a Event entity. + * + * @param Event $entity + * @return \Symfony\Component\Form\FormInterface + */ private function createEditForm(Event $entity) { $form = $this->createForm(EventType::class, $entity, array( @@ -292,9 +299,13 @@ class EventController extends Controller return $form; } + /** * Edits an existing Event entity. * + * @param Request $request + * @param $event_id + * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response */ public function updateAction(Request $request, $event_id) { @@ -326,7 +337,9 @@ class EventController extends Controller /** * List events subscriptions for a person + * * @param $person_id + * @return \Symfony\Component\HttpFoundation\Response */ public function listByPersonAction($person_id) { @@ -356,7 +369,9 @@ class EventController extends Controller ->setParameter(':person_id', $person_id) ->getSingleScalarResult(); - /* @var $paginatorFactory \Chill\MainBundle\Pagination\PaginatorFactory */ + /** + * @var $paginatorFactory \Chill\MainBundle\Pagination\PaginatorFactory + */ $paginatorFactory = $this->get('chill_main.paginator_factory'); $paginator = $paginatorFactory->create($total); From 44487e3ea3a8eb94dfbc7ba244bd40dd069bbe4d Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 8 Feb 2019 18:00:10 +0100 Subject: [PATCH 121/179] minors changes --- Entity/Role.php | 2 +- Form/EventType.php | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Entity/Role.php b/Entity/Role.php index c50665b11..c917dffda 100644 --- a/Entity/Role.php +++ b/Entity/Role.php @@ -94,7 +94,7 @@ class Role * * @return Role */ - public function setType(\Chill\EventBundle\Entity\EventType $type = null) + public function setType(EventType $type = null) { $this->type = $type; diff --git a/Form/EventType.php b/Form/EventType.php index 6e60b5199..50e05ae80 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -30,8 +30,6 @@ use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Form\Type\ChillDateTimeType; use Chill\MainBundle\Form\Type\UserPickerType; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; -use Doctrine\Common\Persistence\ObjectManager; -use Doctrine\ORM\EntityRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; @@ -42,7 +40,7 @@ use Symfony\Component\Security\Core\Role\Role; class EventType extends AbstractType { - /** @var the user running this form */ + /** @var User */ protected $user; /** @var AuthorizationHelper */ From cfae470089fd2b814866d09dfb627b35a53b4272 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 14 Feb 2019 10:36:28 +0100 Subject: [PATCH 122/179] wip.. context --- Resources/views/Timeline/event_person_context.html.twig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Resources/views/Timeline/event_person_context.html.twig b/Resources/views/Timeline/event_person_context.html.twig index ff4e7723a..c27dcdbaa 100644 --- a/Resources/views/Timeline/event_person_context.html.twig +++ b/Resources/views/Timeline/event_person_context.html.twig @@ -1,11 +1,14 @@ {% import 'ChillEventBundle:EventReason:macro.html.twig' as m %} {{ dump() }} +
                                                                  +    event :
                                                                  +| #{{ event.id }} | {{ event.date|localizeddate('short', 'short') }} | {{ event.name }} | center {{ event.center.id }} | circle {{ event.circle.id }} | type {{ event.type.id }} | {{ event.moderator }} |
                                                                  +    participations :
                                                                   {% for participation in event.participations %}
                                                                  -    {{ participation.id }} --->
                                                                  -    {{ participation.lastupdate|localizeddate('long', 'none') }}
                                                                  -    
                                                                  +| #{{ participation.id }} | {{ participation.person }} | {{ participation.role.name|localize_translatable_string }} | {{ participation.status.name|localize_translatable_string }} | lastupdate {{ participation.lastupdate|localizeddate('short', 'short') }} | {% endfor %} +
                                                                  {# TODO From 7212f086ccc5bb21e8b02a94e20707c93a36af4e Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 18 Feb 2019 15:22:23 +0100 Subject: [PATCH 123/179] timeline: template for events --- Resources/translations/messages.fr.yml | 5 +++ .../Timeline/event_person_context.html.twig | 45 ++++++++++--------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 27a56aa80..68860c593 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -61,3 +61,8 @@ CHILL_EVENT_SEE_DETAILS: Voir les détails d'un événement Next step: Étape suivante To which centre should the event be associated ?: À quel centre doit être associé l'événement ? +# timeline +past: passé +futur: futur +'subscribed by %user% to event "%event%" (%event_type%)': inscrit par %user% à l'événement "%event%" (%event_type%) +Show the event: Voir l'événement diff --git a/Resources/views/Timeline/event_person_context.html.twig b/Resources/views/Timeline/event_person_context.html.twig index c27dcdbaa..274ace1f3 100644 --- a/Resources/views/Timeline/event_person_context.html.twig +++ b/Resources/views/Timeline/event_person_context.html.twig @@ -1,32 +1,33 @@ {% import 'ChillEventBundle:EventReason:macro.html.twig' as m %} -{{ dump() }} -
                                                                  -    event :
                                                                  -| #{{ event.id }} | {{ event.date|localizeddate('short', 'short') }} | {{ event.name }} | center {{ event.center.id }} | circle {{ event.circle.id }} | type {{ event.type.id }} | {{ event.moderator }} |
                                                                  -    participations :
                                                                  -{% for participation in event.participations %}
                                                                  -| #{{ participation.id }} | {{ participation.person }} | {{ participation.role.name|localize_translatable_string }} | {{ participation.status.name|localize_translatable_string }} | lastupdate {{ participation.lastupdate|localizeddate('short', 'short') }} |
                                                                  -{% endfor %}
                                                                  -
                                                                  - {# -TODO -- user a inscrit la personne à l'événement machin -- user a modifié le statut de la personne inscrite à l'événement machin. nouveau statut : -- user a modifié le rôle de la personne inscrite à l'événement machin. nouveau rôle : -- participation de la personne à l'événement machin + {{ dump() }} +
                                                                  +        event :
                                                                  +    | #{{ event.id }} | {{ event.date|localizeddate('short', 'short') }} | {{ event.name }} | center {{ event.center.id }} | circle {{ event.circle.id }} | type {{ event.type.id }} | {{ event.moderator }} |
                                                                  +        participations :
                                                                  +    {% for participation in event.participations %}
                                                                  +    | #{{ participation.id }} | {{ participation.person }} | {{ participation.role.name|localize_translatable_string }} | {{ participation.status.name|localize_translatable_string }} | lastupdate {{ participation.lastupdate|localizeddate('short', 'short') }} |
                                                                  +    {% endfor %}
                                                                  +    
                                                                  #} +{% if "now"|date('d/m/Y') < event.date|date('d/m/Y') %} + {% set boolDate = 'past' %} +{% else %} + {% set boolDate = 'futur' %} +{% endif %}
                                                                  -

                                                                  {{ event.date|localizeddate('long', 'none') }} / {{ 'Event'|trans }}

                                                                  +

                                                                  {{ event.date|localizeddate('long', 'none') }} + / {{ 'Event'|trans }} {{ boolDate|trans }}

                                                                  - {{ '%user% has done an %event_type%'|trans( - { - '%user%' : user, - '%event_type%': event.type.name|localize_translatable_string, - '%date%' : event.date|localizeddate('long', 'none') } - ) }} + {{ 'subscribed by %user% to event "%event%" (%event_type%)'|trans({ + '%user%' : user, + '%person%' : person, + '%event%' : event.name, + '%event_type%': event.type.name|localize_translatable_string, + '%date%' : event.date|localizeddate('long', 'none') } + ) }} {% if is_granted(constant('Chill\\ActivityBundle\\Security\\Authorization\\ActivityVoter::SEE_DETAILS'), event) %} From 642ec803e80f894ef6702d10b882f47a1c2a517f Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 18 Apr 2019 12:09:53 +0200 Subject: [PATCH 124/179] timeline adapt view + corrections --- .../Timeline/event_person_context.html.twig | 32 ++++++++----------- Timeline/TimelineEventProvider.php | 2 +- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Resources/views/Timeline/event_person_context.html.twig b/Resources/views/Timeline/event_person_context.html.twig index 274ace1f3..01910c44f 100644 --- a/Resources/views/Timeline/event_person_context.html.twig +++ b/Resources/views/Timeline/event_person_context.html.twig @@ -11,23 +11,27 @@ {% endfor %} #} -{% if "now"|date('d/m/Y') < event.date|date('d/m/Y') %} +{% if "now"|date('U') > event.date|date('U') %} {% set boolDate = 'past' %} {% else %} {% set boolDate = 'futur' %} {% endif %}
                                                                  -

                                                                  {{ event.date|localizeddate('long', 'none') }} - / {{ 'Event'|trans }} {{ boolDate|trans }}

                                                                  +

                                                                  {{ event.date|localizeddate('long', 'short') }} + / + {% if boolDate|trans == 'futur' %} + Prochain événement + {% else %} + {{ 'Event'|trans }} passé + {% endif %} + +

                                                                  - {{ 'subscribed by %user% to event "%event%" (%event_type%)'|trans({ - '%user%' : user, - '%person%' : person, - '%event%' : event.name, - '%event_type%': event.type.name|localize_translatable_string, - '%date%' : event.date|localizeddate('long', 'none') } - ) }} +
                                                                    +
                                                                  • {{ 'Type: ' ~ event.type.name|localize_translatable_string }}
                                                                  • +
                                                                  • {{ 'Nom: ' ~ event.name }}
                                                                  • +
                                                                  {% if is_granted(constant('Chill\\ActivityBundle\\Security\\Authorization\\ActivityVoter::SEE_DETAILS'), event) %} @@ -53,13 +57,5 @@ {{ 'Show the event'|trans }} - {% if is_granted('CHILL_EVENT_UPDATE', event) %} -
                                                                • - - {{ 'Edit the event'|trans }} - -
                                                                • - {% endif %} -
                                                                diff --git a/Timeline/TimelineEventProvider.php b/Timeline/TimelineEventProvider.php index a718882d4..07b0f6829 100644 --- a/Timeline/TimelineEventProvider.php +++ b/Timeline/TimelineEventProvider.php @@ -96,7 +96,7 @@ class TimelineEventProvider implements TimelineProviderInterface 'WHERE' => $this->getWhereClause($metadataEvent, $metadataParticipation, $metadataPerson, $args['person']) ); - dump($query); + //dump($query); return $query; } From aa9141be1d03f05aeacde16c4e460ecb2181d07b Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 18 Apr 2019 12:58:59 +0200 Subject: [PATCH 125/179] hop --- Resources/views/Timeline/event_person_context.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/Timeline/event_person_context.html.twig b/Resources/views/Timeline/event_person_context.html.twig index 01910c44f..f105f87be 100644 --- a/Resources/views/Timeline/event_person_context.html.twig +++ b/Resources/views/Timeline/event_person_context.html.twig @@ -29,8 +29,8 @@
                                                                  +
                                                                • {{ event.name }}
                                                                • {{ 'Type: ' ~ event.type.name|localize_translatable_string }}
                                                                • -
                                                                • {{ 'Nom: ' ~ event.name }}
                                                                From ee8f303d258039b92dd47daf7c1dc37a02757fdb Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 2 May 2019 11:35:15 +0200 Subject: [PATCH 126/179] subscribe a person since listByPerson context (issue #19) --- Controller/EventController.php | 51 ++++- Form/ChoiceLoader/EventChoiceLoader.php | 138 ++++++++++++ Form/Type/PickSubscriptionType.php | 211 +++++++++++++++++++ Repository/EventRepository.php | 35 +++ Resources/config/doctrine/Event.orm.yml | 1 + Resources/config/routing/event.yml | 1 + Resources/config/services/forms.yml | 10 + Resources/config/services/repositories.yml | 5 +- Resources/translations/messages.fr.yml | 3 + Resources/views/Event/listByPerson.html.twig | 11 +- Search/EventSearch.php | 23 +- 11 files changed, 478 insertions(+), 11 deletions(-) create mode 100644 Form/ChoiceLoader/EventChoiceLoader.php create mode 100644 Form/Type/PickSubscriptionType.php create mode 100644 Repository/EventRepository.php diff --git a/Controller/EventController.php b/Controller/EventController.php index d10b561b2..ab7431b72 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -23,8 +23,10 @@ namespace Chill\EventBundle\Controller; use Chill\EventBundle\Entity\Participation; +use Chill\EventBundle\Form\Type\PickSubscriptionType; use Chill\EventBundle\Security\Authorization\EventVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Privacy\PrivacyEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; @@ -343,6 +345,7 @@ class EventController extends Controller */ public function listByPersonAction($person_id) { + $em = $this->getDoctrine()->getManager(); $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); @@ -393,17 +396,59 @@ class EventController extends Controller ->getResult() ; - $privacyEvent = new PrivacyEvent($person, array( 'element_class' => Participation::class, 'action' => 'list' )); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $privacyEvent); - + + $addParticipationByEventForm = $this->createAddParticipationByEventForm($person); + return $this->render('ChillEventBundle:Event:listByPerson.html.twig', array( 'participations' => $participations, 'person' => $person, - 'paginator' => $paginator + 'paginator' => $paginator, + 'form_add_participation_by_event' => $addParticipationByEventForm->createView() )); } + + /** + * create a form to add a participation with an event + * + * @param Person $person + * @return \Symfony\Component\Form\FormInterface + */ + protected function createAddParticipationByEventForm(Person $person) + { + /* @var $builder \Symfony\Component\Form\FormBuilderInterface */ + $builder = $this + ->get('form.factory') + ->createNamedBuilder( + null, + FormType::class, + null, + array( + 'method' => 'GET', + 'action' => $this->generateUrl('chill_event_participation_new'), + 'csrf_protection' => false + )) + ; + + $builder->add('event_id', PickSubscriptionType::class, array( + 'role' => new Role('CHILL_EVENT_CREATE'), + 'centers' => $person->getCenter() + )); + + $builder->add('person_id', HiddenType::class, array( + 'data' => $person->getId() + )); + + $builder->add('submit', SubmitType::class, + array( + 'label' => 'Subscribe an event' + )); + + return $builder->getForm(); + } + } diff --git a/Form/ChoiceLoader/EventChoiceLoader.php b/Form/ChoiceLoader/EventChoiceLoader.php new file mode 100644 index 000000000..c96e541f7 --- /dev/null +++ b/Form/ChoiceLoader/EventChoiceLoader.php @@ -0,0 +1,138 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\EventBundle\Form\ChoiceLoader; + +use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; +use Symfony\Component\Form\ChoiceList\ChoiceListInterface; +use Doctrine\ORM\EntityRepository; +use Chill\EventBundle\Entity\Event; + +/*** + * Class EventChoiceLoader + * + * @package Chill\EventBundle\Form\ChoiceLoader + * @author Mathieu Jaumotte jaum_mathieu@collectifs.net + */ +class EventChoiceLoader implements ChoiceLoaderInterface +{ + + /** + * @var EntityRepository + */ + protected $eventRepository; + + /** + * @var array + */ + protected $lazyLoadedEvents = []; + + /** + * @var array + */ + protected $centers = []; + + /** + * EventChoiceLoader constructor. + * + * @param EntityRepository $eventRepository + * @param array|null $centers + */ + public function __construct( + EntityRepository $eventRepository, + array $centers = null + ) { + $this->eventRepository = $eventRepository; + if (NULL !== $centers) { + $this->centers = $centers; + } + } + + /** + * @return bool + */ + protected function hasCenterFilter() + { + return count($this->centers) > 0; + } + + /** + * @param null $value + * @return ChoiceListInterface + */ + public function loadChoiceList($value = null): ChoiceListInterface + { + $list = new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( + $this->lazyLoadedEvents, + function(Event $p) use ($value) { + return \call_user_func($value, $p); + }); + + return $list; + } + + /** + * @param array $values + * @param null $value + * @return array + */ + public function loadChoicesForValues(array $values, $value = null) + { + $choices = []; + + foreach($values as $value) { + if (empty($value)) { + continue; + } + + $event = $this->eventRepository->find($value); + + if ($this->hasCenterFilter() && + !\in_array($event->getCenter(), $this->centers)) { + throw new \RuntimeException("chosen an event not in correct center"); + } + + $choices[] = $event; + } + + return $choices; + } + + /** + * @param array $choices + * @param null $value + * @return array|string[] + */ + public function loadValuesForChoices(array $choices, $value = null) + { + $values = []; + + foreach ($choices as $choice) { + if (NULL === $choice) { + $values[] = null; + continue; + } + + $id = \call_user_func($value, $choice); + $values[] = $id; + $this->lazyLoadedEvents[$id] = $choice; + } + return $values; + } + +} diff --git a/Form/Type/PickSubscriptionType.php b/Form/Type/PickSubscriptionType.php new file mode 100644 index 000000000..c782330db --- /dev/null +++ b/Form/Type/PickSubscriptionType.php @@ -0,0 +1,211 @@ +, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\EventBundle\Form\Type; + +use Chill\EventBundle\Entity\Event; +use Chill\EventBundle\Form\ChoiceLoader\EventChoiceLoader; +use Chill\EventBundle\Repository\EventRepository; +use Chill\EventBundle\Search\EventSearch; +use Chill\MainBundle\Entity\Center; +use Chill\MainBundle\Entity\GroupCenter; +use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Component\Finder\Exception\AccessDeniedException; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\OptionsResolver\Options; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Symfony\Component\Security\Core\Role\Role; +use Symfony\Component\Translation\TranslatorInterface; + +/** + * Class PickSubscriptionType + * + * @package Chill\EventBundle\Form\Type + * @author Mathieu Jaumotte jaum_mathieu@collectifs.net + */ +class PickSubscriptionType extends AbstractType +{ + + /** + * @var EventRepository + */ + protected $eventRepository; + + /** + * @var User + */ + protected $user; + + /** + * @var AuthorizationHelper + */ + protected $authorizationHelper; + + /** + * @var UrlGeneratorInterface + */ + protected $urlGenerator; + + /** + * @var TranslatorInterface + */ + protected $translator; + + /** + * PickSubscriptionType constructor. + * + * @param EventRepository $eventRepository + * @param TokenStorageInterface $tokenStorage + * @param AuthorizationHelper $authorizationHelper + * @param UrlGeneratorInterface $urlGenerator + * @param TranslatorInterface $translator + */ + public function __construct( + EventRepository $eventRepository, + TokenStorageInterface $tokenStorage, + AuthorizationHelper $authorizationHelper, + UrlGeneratorInterface $urlGenerator, + TranslatorInterface $translator + ) { + $this->eventRepository = $eventRepository; + $this->user = $tokenStorage->getToken()->getUser(); + $this->authorizationHelper = $authorizationHelper; + $this->urlGenerator = $urlGenerator; + $this->translator = $translator; + } + + /** + * @param OptionsResolver $resolver + */ + public function configureOptions(OptionsResolver $resolver) + { + parent::configureOptions($resolver); + + // add the possibles options for this type + $resolver + ->setDefined('centers') + ->addAllowedTypes('centers', array('array', Center::class, 'null')) + ->setDefault('centers', null) + ; + $resolver + ->setDefined('role') + ->addAllowedTypes('role', array(Role::class, 'null')) + ->setDefault('role', null) + ; + + // add the default options + $resolver->setDefaults(array( + 'class' => Event::class, + 'choice_label' => function(Event $e) { + return $e->getDate()->format('d-m-Y'). ' ' .$e->getName(); + // TODO ajouter si possible le type de l'événement ! + }, + 'placeholder' => 'Pick an event', + 'attr' => array('class' => 'select2 '), + 'choice_attr' => function(Event $e) { + return array('data-center' => $e->getCenter()->getId()); + }, + 'choiceloader' => function(Options $options) { + $centers = $this->filterCenters($options); + return new EventChoiceLoader($this->eventRepository, $centers); + } + )); + } + + /** + * @return null|string + */ + public function getParent() + { + return EntityType::class; + } + + /** + * @param \Symfony\Component\Form\FormView $view + * @param \Symfony\Component\Form\FormInterface $form + * @param array $options + */ + public function buildView(\Symfony\Component\Form\FormView $view, \Symfony\Component\Form\FormInterface $form, array $options) + { + $view->vars['attr']['data-person-picker'] = true; + $view->vars['attr']['data-select-interactive-loading'] = true; + $view->vars['attr']['data-search-url'] = $this->urlGenerator + ->generate('chill_main_search', [ 'name' => EventSearch::NAME, '_format' => 'json' ]); + $view->vars['attr']['data-placeholder'] = $this->translator->trans($options['placeholder']); + $view->vars['attr']['data-no-results-label'] = $this->translator->trans('select2.no_results'); + $view->vars['attr']['data-error-load-label'] = $this->translator->trans('select2.error_loading'); + $view->vars['attr']['data-searching-label'] = $this->translator->trans('select2.searching'); + } + + /** + * @param Options $options + * @return array + */ + protected function filterCenters(Options $options) + { + + if ($options['role'] === NULL) { + $centers = array_map( + function (GroupCenter $g) { + return $g->getCenter(); + }, + $this->user->getGroupCenters()->toArray() + ); + } else { + $centers = $this->authorizationHelper->getReachableCenters( + $this->user, + $options['role'] + ); + } + + if ($options['centers'] === NULL) + { + // we select all selected centers + $selectedCenters = $centers; + + } else { + $selectedCenters = array(); + $optionsCenters = is_array($options['centers']) ? + $options['centers'] : array($options['centers']); + + foreach ($optionsCenters as $c) { + // check that every member of the array is a center + if (!$c instanceof Center) { + throw new \RuntimeException('Every member of the "centers" ' + . 'option must be an instance of '.Center::class); + } + if (!in_array($c->getId(), array_map( + function(Center $c) { return $c->getId();}, + $centers))) { + throw new AccessDeniedException('The given center is not reachable'); + } + $selectedCenters[] = $c; + } + } + return $selectedCenters; + } + +} \ No newline at end of file diff --git a/Repository/EventRepository.php b/Repository/EventRepository.php new file mode 100644 index 000000000..a18e664ba --- /dev/null +++ b/Repository/EventRepository.php @@ -0,0 +1,35 @@ +, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\EventBundle\Repository; + +use Doctrine\ORM\EntityRepository; + +/** + * Class EventRepository + * + * @package Chill\EventBundle\Repository + * @author Mathieu Jaumotte jaum_mathieu@collectifs.net + */ +class EventRepository extends EntityRepository +{ + +} diff --git a/Resources/config/doctrine/Event.orm.yml b/Resources/config/doctrine/Event.orm.yml index 7dabeb880..bb0237c3f 100644 --- a/Resources/config/doctrine/Event.orm.yml +++ b/Resources/config/doctrine/Event.orm.yml @@ -1,6 +1,7 @@ Chill\EventBundle\Entity\Event: type: entity table: chill_event_event + repositoryClass: Chill\EventBundle\Repository\EventRepository id: id: type: integer diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index 20580c37a..4271c6d49 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -39,3 +39,4 @@ chill_event__event_update: chill_event__list_by_person: path: /{person_id}/list defaults: { _controller: "ChillEventBundle:Event:listByPerson" } + methods: [ GET ] diff --git a/Resources/config/services/forms.yml b/Resources/config/services/forms.yml index 90981d31b..1ad542dd1 100644 --- a/Resources/config/services/forms.yml +++ b/Resources/config/services/forms.yml @@ -46,3 +46,13 @@ services: - "@chill.main.helper.translatable_string" tags: - { name: form.type } + + Chill\EventBundle\Form\Type\PickSubscriptionType: + arguments: + $eventRepository: "@chill_event.repository.event" + $tokenStorage: "@security.token_storage" + $authorizationHelper: "@chill.main.security.authorization.helper" + $urlGenerator: '@Symfony\Component\Routing\Generator\UrlGeneratorInterface' + $translator: '@Symfony\Component\Translation\TranslatorInterface' + tags: + - { name: form.type } diff --git a/Resources/config/services/repositories.yml b/Resources/config/services/repositories.yml index d27130bcd..ca050ed4b 100644 --- a/Resources/config/services/repositories.yml +++ b/Resources/config/services/repositories.yml @@ -1,6 +1,7 @@ services: + chill_event.repository.event: - class: Doctrine\ORM\EntityRepository + class: Chill\EventBundle\Repository\EventRepository factory: ['@doctrine.orm.entity_manager', getRepository] arguments: - 'Chill\EventBundle\Entity\Event' @@ -15,4 +16,4 @@ services: class: Doctrine\ORM\EntityRepository factory: ['@doctrine.orm.entity_manager', getRepository] arguments: - - 'Chill\EventBundle\Entity\Status' \ No newline at end of file + - 'Chill\EventBundle\Entity\Status' diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 68860c593..2bfc74ac9 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -66,3 +66,6 @@ past: passé futur: futur 'subscribed by %user% to event "%event%" (%event_type%)': inscrit par %user% à l'événement "%event%" (%event_type%) Show the event: Voir l'événement + +Subscribe an event: Ajouter un événement +Pick an event: Choisir un événement \ No newline at end of file diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index 9d9fd7079..b8ae0b326 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -95,6 +95,7 @@ {% endfor %} + @@ -102,8 +103,12 @@ {{ chill_pagination(paginator) }} {% endif %} -{# -{{ dump() }} -#} +
                                                                + {{ form_start(form_add_participation_by_event) }} + {{ form_widget(form_add_participation_by_event.event_id, { 'attr' : { 'style' : 'width: 25em; display:inline-block; ' } } ) }} + {{ form_widget(form_add_participation_by_event.submit, { 'attr' : { 'class' : 'sc-button bt-create' } } ) }} + {{ form_rest(form_add_participation_by_event) }} + {{ form_end(form_add_participation_by_event) }} +
                                                                {% endblock %} \ No newline at end of file diff --git a/Search/EventSearch.php b/Search/EventSearch.php index 4fc5fc19a..bd87b5ad5 100644 --- a/Search/EventSearch.php +++ b/Search/EventSearch.php @@ -3,6 +3,7 @@ namespace Chill\EventBundle\Search; +use Chill\EventBundle\Entity\Event; use Chill\MainBundle\Search\AbstractSearch; use Doctrine\ORM\EntityRepository; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; @@ -101,7 +102,8 @@ class EventSearch extends AbstractSearch $total = $this->count($terms); $paginator = $this->paginationFactory->create($total); - return $this->templating->render('ChillEventBundle:Event:list.html.twig', + if ($format === 'html') { + return $this->templating->render('ChillEventBundle:Event:list.html.twig', array( 'events' => $this->search($terms, $start, $limit, $options), 'pattern' => $this->recomposePattern($terms, $this->getAvailableTerms(), $terms['_domain']), @@ -111,6 +113,23 @@ class EventSearch extends AbstractSearch 'paginator' => $paginator, 'search_name' => self::NAME )); + } + else if ($format === 'json') { + $results = []; + $search = $this->search($terms, $start, $limit, $options); + foreach ($search as $item) { + $results[] = [ + 'id' => $item->getId(), + 'text' => $item->getDate()->format('d-m-Y, H:i'). ' → ' .$item->getName() + ]; + } + return [ + 'results' => $results, + 'pagination' => [ + 'more' => $paginator->hasNextPage() + ] + ]; + } } protected function getAvailableTerms() @@ -207,8 +226,6 @@ class EventSearch extends AbstractSearch $qb->andWhere($where); } - - return $qb; } } From 8a6e7396cac5739ec1672d9eb94b0e86c2a64d1e Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 2 May 2019 12:11:40 +0200 Subject: [PATCH 127/179] Rename PickEventType to PickEventTypeType for type of events --- Form/EventType.php | 6 ++++-- Form/StatusType.php | 4 ++-- Form/Type/{PickEventType.php => PickEventTypeType.php} | 2 +- Resources/config/services/forms.yml | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) rename Form/Type/{PickEventType.php => PickEventTypeType.php} (98%) diff --git a/Form/EventType.php b/Form/EventType.php index 50e05ae80..b08d902e7 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -22,7 +22,7 @@ namespace Chill\EventBundle\Form; -use Chill\EventBundle\Form\Type\PickEventType; +use Chill\EventBundle\Form\Type\PickEventTypeType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\Center; @@ -110,7 +110,9 @@ class EventType extends AbstractType ); }, )) - ->add('type', PickEventType::class) + ->add('type', PickEventTypeType::class, array( + 'placeholder' => '' + )) ->add('moderator', UserPickerType::class, array( 'center' => $options['center'], 'role' => $options['role'], diff --git a/Form/StatusType.php b/Form/StatusType.php index d02b21781..bee55c8c9 100644 --- a/Form/StatusType.php +++ b/Form/StatusType.php @@ -6,7 +6,7 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; use Chill\MainBundle\Form\Type\TranslatableStringFormType; -use Chill\EventBundle\Form\Type\PickEventType; +use Chill\EventBundle\Form\Type\PickEventTypeType; class StatusType extends AbstractType { @@ -19,7 +19,7 @@ class StatusType extends AbstractType $builder ->add('name', TranslatableStringFormType::class) ->add('active') - ->add('type', PickEventType::class) + ->add('type', PickEventTypeType::class) ; } diff --git a/Form/Type/PickEventType.php b/Form/Type/PickEventTypeType.php similarity index 98% rename from Form/Type/PickEventType.php rename to Form/Type/PickEventTypeType.php index 0d41fb2e3..4821296ae 100644 --- a/Form/Type/PickEventType.php +++ b/Form/Type/PickEventTypeType.php @@ -34,7 +34,7 @@ use Chill\EventBundle\Entity\EventType; * * @author Champs-Libres Coop */ -class PickEventType extends AbstractType +class PickEventTypeType extends AbstractType { /** * @var TranslatableStringHelper diff --git a/Resources/config/services/forms.yml b/Resources/config/services/forms.yml index 1ad542dd1..1a1fbc035 100644 --- a/Resources/config/services/forms.yml +++ b/Resources/config/services/forms.yml @@ -1,6 +1,6 @@ services: chill.event.form.type.pick_event_type: - class: Chill\EventBundle\Form\Type\PickEventType + class: Chill\EventBundle\Form\Type\PickEventTypeType arguments: - "@chill.main.helper.translatable_string" tags: From c2b5e0f767df2f9fb64b69429924574fd470d7a6 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 2 May 2019 12:16:48 +0200 Subject: [PATCH 128/179] rename PickSubscriptionType to PickEventType --- Controller/EventController.php | 4 ++-- Form/Type/{PickSubscriptionType.php => PickEventType.php} | 6 +++--- Resources/config/services/forms.yml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) rename Form/Type/{PickSubscriptionType.php => PickEventType.php} (98%) diff --git a/Controller/EventController.php b/Controller/EventController.php index ab7431b72..f96dd0f50 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -23,7 +23,7 @@ namespace Chill\EventBundle\Controller; use Chill\EventBundle\Entity\Participation; -use Chill\EventBundle\Form\Type\PickSubscriptionType; +use Chill\EventBundle\Form\Type\PickEventType; use Chill\EventBundle\Security\Authorization\EventVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Entity\Person; @@ -434,7 +434,7 @@ class EventController extends Controller )) ; - $builder->add('event_id', PickSubscriptionType::class, array( + $builder->add('event_id', PickEventType::class, array( 'role' => new Role('CHILL_EVENT_CREATE'), 'centers' => $person->getCenter() )); diff --git a/Form/Type/PickSubscriptionType.php b/Form/Type/PickEventType.php similarity index 98% rename from Form/Type/PickSubscriptionType.php rename to Form/Type/PickEventType.php index c782330db..71f4d9b56 100644 --- a/Form/Type/PickSubscriptionType.php +++ b/Form/Type/PickEventType.php @@ -41,12 +41,12 @@ use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Translation\TranslatorInterface; /** - * Class PickSubscriptionType + * Class PickEventType * * @package Chill\EventBundle\Form\Type * @author Mathieu Jaumotte jaum_mathieu@collectifs.net */ -class PickSubscriptionType extends AbstractType +class PickEventType extends AbstractType { /** @@ -75,7 +75,7 @@ class PickSubscriptionType extends AbstractType protected $translator; /** - * PickSubscriptionType constructor. + * PickEventType constructor. * * @param EventRepository $eventRepository * @param TokenStorageInterface $tokenStorage diff --git a/Resources/config/services/forms.yml b/Resources/config/services/forms.yml index 1a1fbc035..1c9d819ec 100644 --- a/Resources/config/services/forms.yml +++ b/Resources/config/services/forms.yml @@ -47,7 +47,7 @@ services: tags: - { name: form.type } - Chill\EventBundle\Form\Type\PickSubscriptionType: + Chill\EventBundle\Form\Type\PickEventType: arguments: $eventRepository: "@chill_event.repository.event" $tokenStorage: "@security.token_storage" From 55afcc2184b10db5204685b3e6cfa93a5d8fd8b3 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 2 May 2019 15:10:16 +0200 Subject: [PATCH 129/179] move queries in repository --- Controller/EventController.php | 49 ++++------- Form/EventType.php | 10 ++- Form/Type/PickEventType.php | 3 +- Repository/ParticipationRepository.php | 83 +++++++++++++++++++ .../config/doctrine/Participation.orm.yml | 1 + Resources/config/services/repositories.yml | 8 +- Resources/translations/messages.fr.yml | 4 +- 7 files changed, 120 insertions(+), 38 deletions(-) create mode 100644 Repository/ParticipationRepository.php diff --git a/Controller/EventController.php b/Controller/EventController.php index f96dd0f50..3b0d2e93e 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -24,6 +24,7 @@ namespace Chill\EventBundle\Controller; use Chill\EventBundle\Entity\Participation; use Chill\EventBundle\Form\Type\PickEventType; +use Chill\EventBundle\Repository\ParticipationRepository; use Chill\EventBundle\Security\Authorization\EventVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Entity\Person; @@ -342,6 +343,7 @@ class EventController extends Controller * * @param $person_id * @return \Symfony\Component\HttpFoundation\Response + * @throws \Doctrine\ORM\NonUniqueResultException */ public function listByPersonAction($person_id) { @@ -356,46 +358,27 @@ class EventController extends Controller $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - $reachablesCircles = $this->authorizationHelper - ->getReachableCircles( - $this->getUser(), - new Role(EventVoter::SEE), - $person->getCenter() - ); + $reachablesCircles = $this->authorizationHelper->getReachableCircles( + $this->getUser(), + new Role(EventVoter::SEE), + $person->getCenter() + ); - $total = $em - ->createQuery(" - SELECT COUNT (participation.id) - FROM ChillEventBundle:Participation participation - WHERE participation.person = :person_id - ") - ->setParameter(':person_id', $person_id) - ->getSingleScalarResult(); + $total = $em->getRepository('ChillEventBundle:Participation')->countByPerson($person_id); /** * @var $paginatorFactory \Chill\MainBundle\Pagination\PaginatorFactory */ $paginatorFactory = $this->get('chill_main.paginator_factory'); $paginator = $paginatorFactory->create($total); - - $participations = $em - ->createQuery(" - SELECT participation - FROM ChillEventBundle:Participation participation - JOIN participation.event event - WHERE participation.person = :person_id - AND event.circle IN (:reachable_circles) - ORDER BY event.date ASC - ") - ->setParameters(array( - ':person_id' => $person_id, - ':reachable_circles' => $reachablesCircles - )) - ->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber()) - ->setMaxResults($paginator->getItemsPerPage()) - ->getResult() - ; - + + $participations = $em->getRepository('ChillEventBundle:Participation')->findByPersonInCircle( + $person_id, + $reachablesCircles, + $paginator->getCurrentPage()->getFirstItemNumber(), + $paginator->getItemsPerPage() + ); + $privacyEvent = new PrivacyEvent($person, array( 'element_class' => Participation::class, 'action' => 'list' diff --git a/Form/EventType.php b/Form/EventType.php index b08d902e7..fcf35eaea 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -111,12 +111,18 @@ class EventType extends AbstractType }, )) ->add('type', PickEventTypeType::class, array( - 'placeholder' => '' + 'placeholder' => 'Pick a type of event', + 'attr' => array( + 'class' => '' + ) )) ->add('moderator', UserPickerType::class, array( 'center' => $options['center'], 'role' => $options['role'], - 'placeholder' => '', + 'placeholder' => 'Pick a moderator', + 'attr' => array( + 'class' => '' + ), 'required' => false )) ; diff --git a/Form/Type/PickEventType.php b/Form/Type/PickEventType.php index 71f4d9b56..9d9d2bc96 100644 --- a/Form/Type/PickEventType.php +++ b/Form/Type/PickEventType.php @@ -166,7 +166,7 @@ class PickEventType extends AbstractType */ protected function filterCenters(Options $options) { - + // option role if ($options['role'] === NULL) { $centers = array_map( function (GroupCenter $g) { @@ -181,6 +181,7 @@ class PickEventType extends AbstractType ); } + // option center if ($options['centers'] === NULL) { // we select all selected centers diff --git a/Repository/ParticipationRepository.php b/Repository/ParticipationRepository.php new file mode 100644 index 000000000..29bd09e9a --- /dev/null +++ b/Repository/ParticipationRepository.php @@ -0,0 +1,83 @@ +, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\EventBundle\Repository; + +use Doctrine\ORM\EntityRepository; + +/** + * Class ParticipationRepository + * + * @package Chill\EventBundle\Repository + * @author Mathieu Jaumotte jaum_mathieu@collectifs.net + */ +class ParticipationRepository extends EntityRepository +{ + + /** + * Count number of participations per person + * + * @param $person_id + * @return mixed + * @throws \Doctrine\ORM\NonUniqueResultException + */ + public function countByPerson($person_id) + { + return $this->createQueryBuilder('p') + ->select('COUNT (p.id)') + ->where('p.id = :person_id') + ->setParameter(':person_id', $person_id) + ->getQuery() + ->getSingleScalarResult() + ; + } + + + /** + * Return paginated participations for a person and in reachables circles + * + * @param $person_id + * @param $reachablesCircles + * @param $first + * @param $max + * @return mixed + */ + public function findByPersonInCircle($person_id, $reachablesCircles, $first, $max) + { + return $this->createQueryBuilder('p') + ->join('p.event', 'e') + ->where('p.person = :person_id') + ->andWhere('e.circle IN (:reachable_circles)') + ->orderBy('e.date', 'ASC') + ->setParameters(array( + ':person_id' => $person_id, + ':reachable_circles' => $reachablesCircles + )) + ->setFirstResult($first) + ->setMaxResults($max) + ->getQuery() + ->getResult() + ; + } + + + +} diff --git a/Resources/config/doctrine/Participation.orm.yml b/Resources/config/doctrine/Participation.orm.yml index 24858afc4..377dd54fe 100644 --- a/Resources/config/doctrine/Participation.orm.yml +++ b/Resources/config/doctrine/Participation.orm.yml @@ -1,6 +1,7 @@ Chill\EventBundle\Entity\Participation: type: entity table: chill_event_participation + repositoryClass: Chill\EventBundle\Repository\ParticipationRepository id: id: type: integer diff --git a/Resources/config/services/repositories.yml b/Resources/config/services/repositories.yml index ca050ed4b..4d627f625 100644 --- a/Resources/config/services/repositories.yml +++ b/Resources/config/services/repositories.yml @@ -5,7 +5,13 @@ services: factory: ['@doctrine.orm.entity_manager', getRepository] arguments: - 'Chill\EventBundle\Entity\Event' - + + chill_event.repository.participation: + class: Chill\EventBundle\Repository\ParticipationRepository + factory: ['@doctrine.orm.entity_manager', getRepository] + arguments: + - 'Chill\EventBundle\Entity\Participation' + chill_event.repository.role: class: Doctrine\ORM\EntityRepository factory: ['@doctrine.orm.entity_manager', getRepository] diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 2bfc74ac9..53a79c3e1 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -68,4 +68,6 @@ futur: futur Show the event: Voir l'événement Subscribe an event: Ajouter un événement -Pick an event: Choisir un événement \ No newline at end of file +Pick an event: Choisir un événement +Pick a type of event: Choisir un type d'événement +Pick a moderator: Choisir un animateur From bd19110ecd974ccedb5ed18eac7d1abada89c402 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 2 May 2019 15:20:02 +0200 Subject: [PATCH 130/179] rename method --- Controller/EventController.php | 6 +++--- Resources/views/Event/listByPerson.html.twig | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index 3b0d2e93e..08eee5590 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -385,13 +385,13 @@ class EventController extends Controller )); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $privacyEvent); - $addParticipationByEventForm = $this->createAddParticipationByEventForm($person); + $addEventParticipationByPersonForm = $this->createAddEventParticipationByPersonForm($person); return $this->render('ChillEventBundle:Event:listByPerson.html.twig', array( 'participations' => $participations, 'person' => $person, 'paginator' => $paginator, - 'form_add_participation_by_event' => $addParticipationByEventForm->createView() + 'form_add_event_participation_by_person' => $addEventParticipationByPersonForm->createView() )); } @@ -401,7 +401,7 @@ class EventController extends Controller * @param Person $person * @return \Symfony\Component\Form\FormInterface */ - protected function createAddParticipationByEventForm(Person $person) + protected function createAddEventParticipationByPersonForm(Person $person) { /* @var $builder \Symfony\Component\Form\FormBuilderInterface */ $builder = $this diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index b8ae0b326..7277b4c1b 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -104,11 +104,11 @@ {% endif %}
                                                                - {{ form_start(form_add_participation_by_event) }} - {{ form_widget(form_add_participation_by_event.event_id, { 'attr' : { 'style' : 'width: 25em; display:inline-block; ' } } ) }} - {{ form_widget(form_add_participation_by_event.submit, { 'attr' : { 'class' : 'sc-button bt-create' } } ) }} - {{ form_rest(form_add_participation_by_event) }} - {{ form_end(form_add_participation_by_event) }} + {{ form_start(form_add_event_participation_by_person) }} + {{ form_widget(form_add_event_participation_by_person.event_id, { 'attr' : { 'style' : 'width: 25em; display:inline-block; ' } } ) }} + {{ form_widget(form_add_event_participation_by_person.submit, { 'attr' : { 'class' : 'sc-button bt-create' } } ) }} + {{ form_rest(form_add_event_participation_by_person) }} + {{ form_end(form_add_event_participation_by_person) }}
                                                                {% endblock %} \ No newline at end of file From 8c3c9c4a1fb0edea03bd4fe19c4f883d25bbaa19 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 2 May 2019 16:19:28 +0200 Subject: [PATCH 131/179] new participation: add optional return_path to POST request --- Controller/EventController.php | 14 ++++++++++--- Controller/ParticipationController.php | 29 ++++++++++++++++++++------ 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index 08eee5590..5be3717cd 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -171,10 +171,11 @@ class EventController extends Controller $entity = new Event(); $entity->setCenter($center); - $form = $this->createCreateForm($entity); + $form = $this->createCreateForm($entity); $form->handleRequest($request); - if ($form->isValid()) { + if ($form->isSubmitted() && $form->isValid()) + { $em = $this->getDoctrine()->getManager(); $em->persist($entity); $em->flush(); @@ -425,7 +426,14 @@ class EventController extends Controller $builder->add('person_id', HiddenType::class, array( 'data' => $person->getId() )); - + + $builder->add('return_path', HiddenType::class, array( + 'data' => $this->generateUrl('chill_event__list_by_person', array( + 'person_id' => $person->getId() + )) + )); + + $builder->add('submit', SubmitType::class, array( 'label' => 'Subscribe an event' diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index 4c597a818..10c7d6f6f 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -35,6 +35,7 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType; */ class ParticipationController extends Controller { + /** * Show a form to add a participation * @@ -43,9 +44,12 @@ class ParticipationController extends Controller * on this, the appropriate layout and form. * * @param Request $request + * @return Response */ public function newAction(Request $request) { + dump('coucou'); + // test the request is correct try { $this->testRequest($request); @@ -123,12 +127,16 @@ class ParticipationController extends Controller */ protected function newSingle(Request $request) { + + $returnPath = $request->query->get('return_path') ? + $request->query->get('return_path') : null; + $participation = $this->handleRequest($request, new Participation(), false); $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, $participation, 'The user is not allowed to create this participation'); - $form = $this->createCreateForm($participation); + $form = $this->createCreateForm($participation, $returnPath); return $this->render('ChillEventBundle:Participation:new.html.twig', array( 'form' => $form->createView(), @@ -267,9 +275,16 @@ class ParticipationController extends Controller 'The participation was created' )); - return $this->redirectToRoute('chill_event__event_show', array( - 'event_id' => $participation->getEvent()->getId() - )); + if ($request->query->get('return_path')) + { + return $this->redirect($request->query->get('return_path')); + + } else { + return $this->redirectToRoute('chill_event__event_show', array( + 'event_id' => $participation->getEvent()->getId() + )); + } + } return $this->render('ChillEventBundle:Participation:new.html.twig', array( @@ -390,15 +405,17 @@ class ParticipationController extends Controller } /** - * * @param Participation $participation + * @param null $return_path * @return \Symfony\Component\Form\FormInterface */ - public function createCreateForm(Participation $participation) + public function createCreateForm(Participation $participation, $return_path = null) { + $form = $this->createForm(ParticipationType::class, $participation, array( 'event_type' => $participation->getEvent()->getType(), 'action' => $this->generateUrl('chill_event_participation_create', array( + 'return_path' => $return_path, 'event_id' => $participation->getEvent()->getId(), 'person_id' => $participation->getPerson()->getId() )) From ad45e71051820e7f0ebe6d684ff996be514c5a43 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 2 May 2019 19:27:31 +0200 Subject: [PATCH 132/179] minor changes --- Controller/EventController.php | 3 +++ Form/Type/PickEventType.php | 6 ++++-- Resources/views/Event/listByPerson.html.twig | 4 ++-- Search/EventSearch.php | 4 +++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index 5be3717cd..f727afca1 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -442,4 +442,7 @@ class EventController extends Controller return $builder->getForm(); } + // pour aller plus loin + // TODO ?? inclure le type d'événement et la date dans les résultats de recherche (ex: on tape 'vis' --> il affiche les visites ) + // TODO ?? exclure des résultats les événement déjà sélectionnés pour une personne. empêcher d'inscrire 2x une personne ! } diff --git a/Form/Type/PickEventType.php b/Form/Type/PickEventType.php index 9d9d2bc96..9cf8c3f29 100644 --- a/Form/Type/PickEventType.php +++ b/Form/Type/PickEventType.php @@ -120,8 +120,9 @@ class PickEventType extends AbstractType $resolver->setDefaults(array( 'class' => Event::class, 'choice_label' => function(Event $e) { - return $e->getDate()->format('d-m-Y'). ' ' .$e->getName(); - // TODO ajouter si possible le type de l'événement ! + return $e->getDate()->format('d/m/Y, H:i') . ' → ' . + // $e->getType()->getName()['fr'] . ': ' . // display the type of event + $e->getName(); }, 'placeholder' => 'Pick an event', 'attr' => array('class' => 'select2 '), @@ -133,6 +134,7 @@ class PickEventType extends AbstractType return new EventChoiceLoader($this->eventRepository, $centers); } )); + } /** diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index 7277b4c1b..a59d28076 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -27,8 +27,8 @@ - + @@ -38,8 +38,8 @@ {% for participation in participations %} - + diff --git a/Search/EventSearch.php b/Search/EventSearch.php index bd87b5ad5..8833ed702 100644 --- a/Search/EventSearch.php +++ b/Search/EventSearch.php @@ -120,7 +120,9 @@ class EventSearch extends AbstractSearch foreach ($search as $item) { $results[] = [ 'id' => $item->getId(), - 'text' => $item->getDate()->format('d-m-Y, H:i'). ' → ' .$item->getName() + 'text' => $item->getDate()->format('d/m/Y, H:i') . ' → ' . + // $item->getType()->getName()['fr'] . ': ' . // display the type of event + $item->getName() ]; } return [ From c26b4f1ae7eb1858d03874dbbb647629f9d3506d Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 17 Jul 2019 11:53:56 +0200 Subject: [PATCH 133/179] add export button, route and controller method --- Controller/EventController.php | 19 +++++++++++++++++++ Resources/config/routing/event.yml | 7 +++++++ .../Event/exportParticipations.html.twig | 3 +++ Resources/views/Event/show.html.twig | 1 + 4 files changed, 30 insertions(+) create mode 100644 Resources/views/Event/exportParticipations.html.twig diff --git a/Controller/EventController.php b/Controller/EventController.php index f727afca1..18cd6b955 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -25,6 +25,7 @@ namespace Chill\EventBundle\Controller; use Chill\EventBundle\Entity\Participation; use Chill\EventBundle\Form\Type\PickEventType; use Chill\EventBundle\Repository\ParticipationRepository; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Chill\EventBundle\Security\Authorization\EventVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Entity\Person; @@ -442,6 +443,24 @@ class EventController extends Controller return $builder->getForm(); } + + /** + * @paramConverter("event", options={"id" = "event_id"}) + * @param Event $event + * @return \Symfony\Component\HttpFoundation\Response + */ + public function exportParticipationsAction(Event $event) + { + dump($event); + + return $this->render('ChillEventBundle:Event:exportParticipations.html.twig', [ + 'event' => $event, + ]); + } + + + + // pour aller plus loin // TODO ?? inclure le type d'événement et la date dans les résultats de recherche (ex: on tape 'vis' --> il affiche les visites ) // TODO ?? exclure des résultats les événement déjà sélectionnés pour une personne. empêcher d'inscrire 2x une personne ! diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index 4271c6d49..79c3da414 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -40,3 +40,10 @@ chill_event__list_by_person: path: /{person_id}/list defaults: { _controller: "ChillEventBundle:Event:listByPerson" } methods: [ GET ] + +chill_event__event_export_participations: + path: /{event_id}/export/participations + defaults: { _controller: "ChillEventBundle:Event:exportParticipations" } + requirements: + event_id: \d+ + methods: [ GET ] diff --git a/Resources/views/Event/exportParticipations.html.twig b/Resources/views/Event/exportParticipations.html.twig new file mode 100644 index 000000000..20bfed6dc --- /dev/null +++ b/Resources/views/Event/exportParticipations.html.twig @@ -0,0 +1,3 @@ +{% for participation in event.participations %} + {{ dump(participation.person.firstname ~ ' ' ~ participation.person.lastname) }} +{% endfor %} \ No newline at end of file diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index a283add84..3e5ba1d55 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -104,6 +104,7 @@ From 59668f45a2faffdef7ce80a73e84c7c695028693 Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 17 Jul 2019 17:30:46 +0200 Subject: [PATCH 134/179] phpSpreadsheet export participations list for an event --- Controller/EventController.php | 130 +++++++++++++++++- Resources/config/routing/event.yml | 2 +- Resources/translations/messages.fr.yml | 3 + .../Event/exportParticipations.html.twig | 91 +++++++++++- composer.json | 3 +- 5 files changed, 220 insertions(+), 9 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index 18cd6b955..74959cc69 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -24,7 +24,12 @@ namespace Chill\EventBundle\Controller; use Chill\EventBundle\Entity\Participation; use Chill\EventBundle\Form\Type\PickEventType; -use Chill\EventBundle\Repository\ParticipationRepository; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Writer\Csv; +use PhpOffice\PhpSpreadsheet\Writer\Ods; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +use Symfony\Component\HttpFoundation\StreamedResponse; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Chill\EventBundle\Security\Authorization\EventVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; @@ -447,18 +452,135 @@ class EventController extends Controller /** * @paramConverter("event", options={"id" = "event_id"}) * @param Event $event + * @param Request $request * @return \Symfony\Component\HttpFoundation\Response + * @throws \PhpOffice\PhpSpreadsheet\Exception */ - public function exportParticipationsAction(Event $event) + public function exportParticipationsAction(Event $event, Request $request) { - dump($event); + $builder = $this->createFormBuilder() + ->add('format', ChoiceType::class, [ + 'choices' => [ + 'xlsx' => 'xlsx', + 'ods' => 'ods', + 'csv' => 'csv' + ], + 'label' => false, + 'placeholder' => 'Select a format', + 'attr' => [ 'class' => 'custom-select' ] + ]) + ->add('submit', SubmitType::class, [ + 'label' => 'Export', + 'attr' => [ 'class' => 'btn btn-outline-secondary' ] + ]); + + $form = $builder->getForm(); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) + { + $data = $form->getData(); + $format = $data['format']; + $filename = 'export_event_participations.' .$format; + + $spreadsheet = $this->createSpreadsheet($event); + + switch ($format) { + case 'ods': + $contentType = 'application/vnd.oasis.opendocument.spreadsheet'; + $writer = new Ods($spreadsheet); + break; + case 'xlsx': + $contentType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; + $writer = new Xlsx($spreadsheet); + break; + case 'csv': + $contentType = 'text/csv'; + $writer = new Csv($spreadsheet); + break; + default: + return $this->render('ChillEventBundle:Event:exportParticipations.html.twig', [ + 'event' => $event, + 'form' => $form->createView(), + ]); + } + + $response = new StreamedResponse(); + $response->headers->set('Content-Type', $contentType); + $response->headers->set('Content-Disposition', 'attachment;filename="'.$filename.'"'); + $response->setPrivate(); + $response->headers->addCacheControlDirective('no-cache', true); + $response->headers->addCacheControlDirective('must-revalidate', true); + $response->setCallback(function() use ($writer) { + $writer->save('php://output'); + }); + + return $response; + } return $this->render('ChillEventBundle:Event:exportParticipations.html.twig', [ - 'event' => $event, + 'event' => $event, + 'form' => $form->createView(), ]); } + /** + * @param Event $event + * @return Spreadsheet + * @throws \PhpOffice\PhpSpreadsheet\Exception + */ + protected function createSpreadsheet(Event $event) + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $headerValues = [ + 'A1' => 'Event', + 'B1' => $event->getId(), + 'A2' => 'Date', + 'B2' => $event->getDate()->format('d-m-Y H:i'), + 'A3' => 'Name', + 'B3' => $event->getName(), + 'A4' => 'Type', + 'B4' => $event->getType()->getName()['fr'], // TODO + 'A5' => 'Circle', + 'B5' => $event->getCircle()->getName()['fr'], // TODO + 'A6' => 'Moderator', + 'B6' => $event->getModerator(), + ]; + foreach ($headerValues as $k => $value) { + $sheet->setCellValue($k, $value); + } + + $columnNames = [ 'id', 'firstname', 'lastname', 'email' ]; + $columnLetter = 'A'; + foreach ($columnNames as $columnName) { + $sheet->setCellValue($columnLetter.'8', $columnName); + $columnLetter++; + } + + $columnValues = []; + foreach ($event->getParticipations() as $participation) { + $columnValues[] = [ + $participation->getPerson()->getId(), + $participation->getPerson()->getFirstname(), + $participation->getPerson()->getLastname(), + $participation->getPerson()->getEmail() + ]; + } + + $i = 9; + foreach ($columnValues as $columnValue) { + $columnLetter = 'A'; + foreach ($columnValue as $value) { + $sheet->setCellValue($columnLetter.$i, $value); + $columnLetter++; + } + $i++; + } + + return $spreadsheet; + } // pour aller plus loin diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index 79c3da414..f1c52e335 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -46,4 +46,4 @@ chill_event__event_export_participations: defaults: { _controller: "ChillEventBundle:Event:exportParticipations" } requirements: event_id: \d+ - methods: [ GET ] + methods: [ GET, POST ] diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 53a79c3e1..44e77e20d 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -71,3 +71,6 @@ Subscribe an event: Ajouter un événement Pick an event: Choisir un événement Pick a type of event: Choisir un type d'événement Pick a moderator: Choisir un animateur + +Select a format: Choisir un format +Export: Exporter \ No newline at end of file diff --git a/Resources/views/Event/exportParticipations.html.twig b/Resources/views/Event/exportParticipations.html.twig index 20bfed6dc..4623d8baf 100644 --- a/Resources/views/Event/exportParticipations.html.twig +++ b/Resources/views/Event/exportParticipations.html.twig @@ -1,3 +1,88 @@ -{% for participation in event.participations %} - {{ dump(participation.person.firstname ~ ' ' ~ participation.person.lastname) }} -{% endfor %} \ No newline at end of file +{% extends 'ChillEventBundle::layout.html.twig' %} + +{% block title 'Event : %label%'|trans({ '%label%' : event.name } ) %} + +{% block event_content -%} + +
                                                                {{ 'Name'|trans }} {{ 'Date'|trans }}{{ 'Name'|trans }} {{ 'Event type'|trans }} {{ 'Role'|trans }} {{ 'Status'|trans }}
                                                                {{ participation.event.name }} {{ participation.event.date|localizeddate('long', 'short') }}{{ participation.event.name }} {{ participation.event.type.name|localize_translatable_string }} {{ participation.role.name|localize_translatable_string }} {{ participation.status.name|localize_translatable_string }}
                                                                + {% for participation in event.participations %} + + {% endfor %} +
                                                                + {{ participation.person.id }} + + {{ participation.person.firstname }} + + {{ participation.person.lastname }} + + {{ participation.person.email }} +

                                                                + + + + + {{ form_start(form) }} + {{ form_errors(form) }} +
                                                                + {{ form_widget(form.format) }} +
                                                                + {{ form_widget(form.submit) }} +
                                                                +
                                                                + {{ form_end(form) }} + +{% endblock %} diff --git a/composer.json b/composer.json index b98b9fd00..caa75b7ea 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,8 @@ } ], "require": { - "chill-project/person": "~1.5" + "chill-project/person": "~1.5", + "phpoffice/phpspreadsheet": "~1.8.2" }, "require-dev": { }, From be37d9d73ab0434bca8b8738a3a9e18e6f6688eb Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 18 Jul 2019 12:12:59 +0200 Subject: [PATCH 135/179] improve phpspreadsheet participations list export --- Controller/EventController.php | 97 ++++++++++--------- Resources/config/routing/event.yml | 6 -- .../Event/exportParticipations.html.twig | 88 ----------------- Resources/views/Event/show.html.twig | 91 +++++++++++++++-- 4 files changed, 132 insertions(+), 150 deletions(-) delete mode 100644 Resources/views/Event/exportParticipations.html.twig diff --git a/Controller/EventController.php b/Controller/EventController.php index 74959cc69..666fb459e 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -197,31 +197,37 @@ class EventController extends Controller 'form' => $form->createView(), )); } - + /** * Finds and displays a Event entity. * - * @param $event_id + * @paramConverter("event", options={"id" = "event_id"}) + * @param Event $event + * @param Request $request * @return \Symfony\Component\HttpFoundation\Response + * @throws \PhpOffice\PhpSpreadsheet\Exception */ - public function showAction($event_id) + public function showAction(Event $event, Request $request) { - $em = $this->getDoctrine()->getManager(); - - $entity = $em->getRepository('ChillEventBundle:Event')->find($event_id); - - if (!$entity) { + if (!$event) { throw $this->createNotFoundException('Unable to find Event entity.'); } - $this->denyAccessUnlessGranted('CHILL_EVENT_SEE_DETAILS', $entity, + $this->denyAccessUnlessGranted('CHILL_EVENT_SEE_DETAILS', $event, "You are not allowed to see details on this event"); - $addParticipationByPersonForm = $this->createAddParticipationByPersonForm($entity); - + $addParticipationByPersonForm = $this->createAddParticipationByPersonForm($event); + + $exportParticipationsList = $this->exportParticipationsList($event, $request); + + if ($exportParticipationsList['response']) { + return $exportParticipationsList['response']; + } + return $this->render('ChillEventBundle:Event:show.html.twig', array( - 'event' => $entity, - 'form_add_participation_by_person' => $addParticipationByPersonForm->createView() + 'event' => $event, + 'form_add_participation_by_person' => $addParticipationByPersonForm->createView(), + 'form_export' => $exportParticipationsList['form']->createView() )); } @@ -450,40 +456,23 @@ class EventController extends Controller /** - * @paramConverter("event", options={"id" = "event_id"}) * @param Event $event * @param Request $request - * @return \Symfony\Component\HttpFoundation\Response + * @return array * @throws \PhpOffice\PhpSpreadsheet\Exception */ - public function exportParticipationsAction(Event $event, Request $request) + protected function exportParticipationsList(Event $event, Request $request) { - $builder = $this->createFormBuilder() - ->add('format', ChoiceType::class, [ - 'choices' => [ - 'xlsx' => 'xlsx', - 'ods' => 'ods', - 'csv' => 'csv' - ], - 'label' => false, - 'placeholder' => 'Select a format', - 'attr' => [ 'class' => 'custom-select' ] - ]) - ->add('submit', SubmitType::class, [ - 'label' => 'Export', - 'attr' => [ 'class' => 'btn btn-outline-secondary' ] - ]); - - $form = $builder->getForm(); + $form = $this->createExportByFormatForm(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $data = $form->getData(); $format = $data['format']; - $filename = 'export_event_participations.' .$format; + $filename = 'export_event'. $event->getId() .'_participations.' .$format; - $spreadsheet = $this->createSpreadsheet($event); + $spreadsheet = $this->createExportSpreadsheet($event); switch ($format) { case 'ods': @@ -499,10 +488,7 @@ class EventController extends Controller $writer = new Csv($spreadsheet); break; default: - return $this->render('ChillEventBundle:Event:exportParticipations.html.twig', [ - 'event' => $event, - 'form' => $form->createView(), - ]); + return [ 'form' => $form, 'response' => null ]; } $response = new StreamedResponse(); @@ -515,13 +501,32 @@ class EventController extends Controller $writer->save('php://output'); }); - return $response; + return [ 'form' => $form, 'response' => $response ]; } - return $this->render('ChillEventBundle:Event:exportParticipations.html.twig', [ - 'event' => $event, - 'form' => $form->createView(), - ]); + return [ 'form' => $form, 'response' => null ]; + } + + /** + * @return \Symfony\Component\Form\FormInterface + */ + protected function createExportByFormatForm() + { + $builder = $this->createFormBuilder() + ->add('format', ChoiceType::class, [ + 'choices' => [ + 'xlsx' => 'xlsx', + 'ods' => 'ods', + 'csv' => 'csv' + ], + 'label' => false, + 'placeholder' => 'Select a format' + ]) + ->add('submit', SubmitType::class, [ + 'label' => 'Export' + ]); + + return $builder->getForm(); } /** @@ -529,7 +534,7 @@ class EventController extends Controller * @return Spreadsheet * @throws \PhpOffice\PhpSpreadsheet\Exception */ - protected function createSpreadsheet(Event $event) + protected function createExportSpreadsheet(Event $event) { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -544,7 +549,7 @@ class EventController extends Controller 'A4' => 'Type', 'B4' => $event->getType()->getName()['fr'], // TODO 'A5' => 'Circle', - 'B5' => $event->getCircle()->getName()['fr'], // TODO + 'B5' => $event->getCircle()->getName()['fr'], // TODO 'A6' => 'Moderator', 'B6' => $event->getModerator(), ]; diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index f1c52e335..840a7cda8 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -41,9 +41,3 @@ chill_event__list_by_person: defaults: { _controller: "ChillEventBundle:Event:listByPerson" } methods: [ GET ] -chill_event__event_export_participations: - path: /{event_id}/export/participations - defaults: { _controller: "ChillEventBundle:Event:exportParticipations" } - requirements: - event_id: \d+ - methods: [ GET, POST ] diff --git a/Resources/views/Event/exportParticipations.html.twig b/Resources/views/Event/exportParticipations.html.twig deleted file mode 100644 index 4623d8baf..000000000 --- a/Resources/views/Event/exportParticipations.html.twig +++ /dev/null @@ -1,88 +0,0 @@ -{% extends 'ChillEventBundle::layout.html.twig' %} - -{% block title 'Event : %label%'|trans({ '%label%' : event.name } ) %} - -{% block event_content -%} - - - {% for participation in event.participations %} - - {% endfor %} -
                                                                - {{ participation.person.id }} - - {{ participation.person.firstname }} - - {{ participation.person.lastname }} - - {{ participation.person.email }} -

                                                                - - - - - {{ form_start(form) }} - {{ form_errors(form) }} -
                                                                - {{ form_widget(form.format) }} -
                                                                - {{ form_widget(form.submit) }} -
                                                                -
                                                                - {{ form_end(form) }} - -{% endblock %} diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 3e5ba1d55..af881fbcc 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -104,21 +104,92 @@ - -
                                                                - {{ form_start(form_add_participation_by_person) }} - {{ form_widget(form_add_participation_by_person.person_id, { 'attr' : { 'style' : 'width: 25em; display:inline-block; ' } } ) }} - {{ form_widget(form_add_participation_by_person.submit, { 'attr' : { 'class' : 'sc-button bt-create' } } ) }} - {{ form_rest(form_add_participation_by_person) }} - {{ form_end(form_add_participation_by_person) }} +
                                                              + + + +
                                                              +
                                                              + {{ form_start(form_add_participation_by_person) }} +
                                                              + {{ form_widget(form_add_participation_by_person.person_id, { 'attr' : { + 'class' : 'custom-select', + 'style': 'min-width: 15em; max-width: 20em; display: inline-block;' + }} ) }} +
                                                              + {{ form_widget(form_add_participation_by_person.submit, { 'attr' : { 'class' : 'sc-button bt-create' } } ) }} +
                                                              +
                                                              + {{ form_rest(form_add_participation_by_person) }} + {{ form_end(form_add_participation_by_person) }} +
                                                              + +
                                                              + {{ form_start(form_export) }} +
                                                              + {{ form_widget(form_export.format, { 'attr' : { 'class': 'custom-select' } }) }} +
                                                              + {{ form_widget(form_export.submit, { 'attr' : { 'class': 'sc-button bt-save' } }) }} +
                                                              + +
                                                              + {{ form_rest(form_export) }} + {{ form_end(form_export) }} +
                                                              {{ chill_delegated_block('block_footer_show', { 'event': event }) }}
                                                              - + {% endblock %} From 81f3b1acae220af92e28521ffa7a39729cf288bf Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 18 Jul 2019 15:38:29 +0200 Subject: [PATCH 136/179] minor changes --- Resources/views/Event/show.html.twig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index af881fbcc..1891fc0c1 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -127,6 +127,7 @@ padding: .375rem 1.75rem .375rem .75rem; background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3e%3cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e") no-repeat right .75rem center/8px 10px; + background-color: white; border-radius: .25rem; -webkit-appearance: none; -moz-appearance: none; appearance: none; } @@ -164,7 +165,7 @@
                                                              {{ form_widget(form_add_participation_by_person.person_id, { 'attr' : { 'class' : 'custom-select', - 'style': 'min-width: 15em; max-width: 20em; display: inline-block;' + 'style': 'min-width: 15em; max-width: 18em; display: inline-block;' }} ) }}
                                                              {{ form_widget(form_add_participation_by_person.submit, { 'attr' : { 'class' : 'sc-button bt-create' } } ) }} From 073a8cc5ea98c9243e97b1e3062ae879acf82eb7 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 18 Jul 2019 16:05:24 +0200 Subject: [PATCH 137/179] minor changes --- Resources/views/Event/show.html.twig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 1891fc0c1..a37c2308b 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -109,12 +109,13 @@
                                                            -
                                                            {{ form_start(form_add_participation_by_person) }} @@ -176,7 +125,7 @@
                                                            - {{ form_start(form_export) }} + {{ form_start(form_export, {'attr': {'id': 'export_tableur'}}) }}
                                                            {{ form_widget(form_export.format, { 'attr' : { 'class': 'custom-select' } }) }}
                                                            From 8618efc35a9a3af7857a93b5291ddfd3be163489 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 28 Nov 2019 16:38:03 +0100 Subject: [PATCH 144/179] adding remove participation method --- Controller/ParticipationController.php | 70 ++++++++++++++++++- Resources/config/routing/participation.yml | 8 +++ Resources/translations/messages.fr.yml | 4 ++ .../views/Event/confirm_delete.html.twig | 20 ++++++ Resources/views/Event/show.html.twig | 4 ++ 5 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 Resources/views/Event/confirm_delete.html.twig diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index 10c7d6f6f..dd99e6fed 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -19,6 +19,8 @@ namespace Chill\EventBundle\Controller; +use Chill\EventBundle\Entity\Event; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -551,8 +553,9 @@ class ParticipationController extends Controller /** * show a form to edit multiple participation for the same event. - * + * * @param int $event_id + * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response */ public function editMultipleAction($event_id) { @@ -637,8 +640,8 @@ class ParticipationController extends Controller } /** - * - * @param \Doctrine\Common\Collections\Collectionn $participations contains object of Participation type + * + * @param \Doctrine\Common\Collections\Collection $participations contains object of Participation type * @param \Chill\EventBundle\Entity\Event $event * @return \Symfony\Component\Form\FormInterface */ @@ -669,4 +672,65 @@ class ParticipationController extends Controller return $form; } + /** + * @param integer $participation_id + * @param Request $request + * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response + */ + public function deleteAction($participation_id, Request $request) + { + $em = $this->getDoctrine()->getManager(); + $participation = $em->getRepository('ChillEventBundle:Participation')->findOneBy([ + 'id' => $participation_id + ]); + + if (! $participation) { + throw $this->createNotFoundException('Unable to find participation.'); + } + + /** @var Event $event */ + $event = $participation->getEvent(); + + $form = $this->createDeleteForm($participation_id); + + if ($request->getMethod() === Request::METHOD_DELETE) { + $form->handleRequest($request); + + if ($form->isValid()) { + + $em->remove($participation); + $em->flush(); + + $this->addFlash('success', $this->get('translator') + ->trans("The participation has been sucessfully removed") + ); + + return $this->redirectToRoute('chill_event__event_show', [ + 'event_id' => $event->getId() + ]); + } + } + return $this->render('ChillEventBundle:Event:confirm_delete.html.twig', [ + 'event_id' => $event->getId(), + 'delete_form' => $form->createView() + ]); + + } + + /** + * @param $participation_id + * @return \Symfony\Component\Form\FormInterface + */ + private function createDeleteForm($participation_id) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('chill_event_participation_delete', [ + 'participation_id' => $participation_id + ])) + ->setMethod('DELETE') + ->add('submit', SubmitType::class, ['label' => 'Delete']) + ->getForm() + ; + } + } diff --git a/Resources/config/routing/participation.yml b/Resources/config/routing/participation.yml index bbb727382..7d4efc90a 100644 --- a/Resources/config/routing/participation.yml +++ b/Resources/config/routing/participation.yml @@ -23,3 +23,11 @@ chill_event_participation_update_multiple: path: /{event_id}/update_multiple defaults: { _controller: ChillEventBundle:Participation:updateMultiple } methods: [POST] + +chill_event_participation_delete: + path: /{participation_id}/delete + requirements: + participation_id: \d+ + defaults: { _controller: ChillEventBundle:Participation:delete } + methods: [ GET, DELETE ] + diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index b02bf7627..b2ab63f01 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -43,9 +43,13 @@ The participation was updated: La participation a été mise à jour 'The following people have been ignored because they are already participating on the event': '{1} La personne suivante a été ignorée parce qu''elle participe déjà à l''événement | ]1,Inf] Les personnes suivantes ont été ignorées parce qu''elles participent déjà à l''événement' There are no participation to edit for this event: Il n'y a pas de participation pour cet événement The participations have been successfully updated.: Les participations ont été mises à jour. +The participation has been sucessfully removed: La participation a été correctement supprimée. The participations were created: Les participations ont été créées Events participation: Participation aux événements +Remove participation: Supprimer la participation +Are you sure you want to remove that participation ?: Êtes-vous certain de vouloir supprimer cette participation ? + #search Event search: Recherche d'événements '%total% events match the search %pattern%' : '{0} Aucun événement ne correspond aux termes de recherche "%pattern%" | {1} Un événement a été trouvé par la recherche "%pattern%" | ]1,Inf] %total% événements correspondent aux termes de recherche "%pattern%".' diff --git a/Resources/views/Event/confirm_delete.html.twig b/Resources/views/Event/confirm_delete.html.twig new file mode 100644 index 000000000..f235ebb00 --- /dev/null +++ b/Resources/views/Event/confirm_delete.html.twig @@ -0,0 +1,20 @@ +{% extends 'ChillEventBundle::layout.html.twig' %} + +{% set activeRouteKey = 'chill_event__event_show' %} + +{% block title 'Remove participation'|trans %} + +{% block event_content %} + + {{ include('ChillMainBundle:Util:confirmation_template.html.twig', + { + 'title' : 'Remove participation'|trans, + 'confirm_question' : 'Are you sure you want to remove that participation ?'|trans, + 'cancel_route' : activeRouteKey, + 'cancel_parameters' : { 'event_id' : event_id }, + 'form' : delete_form + } + ) }} + +{% endblock %} + diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index e79137f03..e818cab46 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -91,6 +91,10 @@ {{ 'Edit'|trans }}
                                                          • +
                                                          • + +
                                                          • {% endif %}
                                                          From 30e0c663dc7c5a4866c95550efed899d49e752cd Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 28 Nov 2019 17:37:24 +0100 Subject: [PATCH 145/179] adding remove event feature --- Controller/EventController.php | 69 ++++++++++++++++++- Controller/ParticipationController.php | 46 ++++++++----- Resources/config/routing/event.yml | 6 ++ Resources/translations/messages.fr.yml | 4 +- .../views/Event/confirm_delete.html.twig | 6 +- Resources/views/Event/show.html.twig | 10 +-- .../Participation/confirm_delete.html.twig | 20 ++++++ 7 files changed, 135 insertions(+), 26 deletions(-) create mode 100644 Resources/views/Participation/confirm_delete.html.twig diff --git a/Controller/EventController.php b/Controller/EventController.php index d4b336b04..e9e0b10d6 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -30,7 +30,6 @@ use PhpOffice\PhpSpreadsheet\Writer\Ods; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\HttpFoundation\StreamedResponse; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Chill\EventBundle\Security\Authorization\EventVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Entity\Person; @@ -49,6 +48,7 @@ use Chill\MainBundle\Entity\Center; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Translation\TranslatorInterface; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; /** @@ -210,7 +210,7 @@ class EventController extends Controller /** * Finds and displays a Event entity. * - * @paramConverter("event", options={"id" = "event_id"}) + * @ParamConverter("event", options={"id" = "event_id"}) * @param Event $event * @param Request $request * @return \Symfony\Component\HttpFoundation\Response @@ -604,4 +604,69 @@ class EventController extends Controller return $spreadsheet; } + /** + * @param $event_id + * @param Request $request + * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response + */ + public function deleteAction($event_id, Request $request) + { + $em = $this->getDoctrine()->getManager(); + $event = $em->getRepository('ChillEventBundle:Event')->findOneBy([ + 'id' => $event_id + ]); + + if (! $event) { + throw $this->createNotFoundException('Unable to find this event.'); + } + + /** @var array $participations */ + $participations = $event->getParticipations(); + + $form = $this->createDeleteForm($event_id); + + if ($request->getMethod() === Request::METHOD_DELETE) { + $form->handleRequest($request); + + if ($form->isValid()) { + + foreach ($participations as $participation) { + $em->remove($participation); + } + + $em->remove($event); + $em->flush(); + + $this->addFlash('success', $this->get('translator') + ->trans("The event has been sucessfully removed") + ); + + return $this->redirectToRoute('chill_main_search', [ + 'name' => 'event_regular', + 'q' => '@event' + ]); + } + } + return $this->render('ChillEventBundle:Event:confirm_delete.html.twig', [ + 'event_id' => $event->getId(), + 'delete_form' => $form->createView() + ]); + } + + /** + * @param $event_id + * @return \Symfony\Component\Form\FormInterface + */ + private function createDeleteForm($event_id) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('chill_event__event_delete', [ + 'event_id' => $event_id + ])) + ->setMethod('DELETE') + ->add('submit', SubmitType::class, ['label' => 'Delete']) + ->getForm() + ; + } + } diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index dd99e6fed..bb5c03213 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -19,8 +19,8 @@ namespace Chill\EventBundle\Controller; +use ArrayIterator; use Chill\EventBundle\Entity\Event; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -31,8 +31,9 @@ use Chill\EventBundle\Security\Authorization\ParticipationVoter; use Symfony\Component\Form\Extension\Core\Type\CollectionType; /** - * + * Class ParticipationController * + * @package Chill\EventBundle\Controller * @author Julien Fastré */ class ParticipationController extends Controller @@ -44,9 +45,9 @@ class ParticipationController extends Controller * This function parse the person_id / persons_ids query argument * and decide if it should process a single or multiple participation. Depending * on this, the appropriate layout and form. - * + * * @param Request $request - * @return Response + * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response */ public function newAction(Request $request) { @@ -158,9 +159,9 @@ class ParticipationController extends Controller * * If all participations must be ignored, an error is shown and the method redirects * to the event 'show' view with an appropriate flash message. - * + * * @param Request $request - * @return Response + * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response */ protected function newMultiple(Request $request) { @@ -224,6 +225,10 @@ class ParticipationController extends Controller } } + /** + * @param Request $request + * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response + */ public function createAction(Request $request) { // test the request is correct @@ -257,6 +262,10 @@ class ParticipationController extends Controller . "'persons_ids' argument in query"); } + /** + * @param Request $request + * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response + */ public function createSingle(Request $request) { $participation = $this->handleRequest($request, new Participation(), false); @@ -295,6 +304,10 @@ class ParticipationController extends Controller )); } + /** + * @param Request $request + * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response + */ public function createMultiple(Request $request) { $participations = $this->handleRequest($request, new Participation(), true); @@ -431,9 +444,8 @@ class ParticipationController extends Controller } /** - * * @param array $participations - * @return type + * @return \Symfony\Component\Form\FormInterface */ public function createCreateFormMultiple(array $participations) { @@ -491,6 +503,11 @@ class ParticipationController extends Controller )); } + /** + * @param $participation_id + * @param Request $request + * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response + */ public function updateAction($participation_id, Request $request) { /* @var $participation Participation */ @@ -640,15 +657,12 @@ class ParticipationController extends Controller } /** - * - * @param \Doctrine\Common\Collections\Collection $participations contains object of Participation type - * @param \Chill\EventBundle\Entity\Event $event + * @param ArrayIterator $participations + * @param Event $event * @return \Symfony\Component\Form\FormInterface */ - protected function createEditFormMultiple( - \Doctrine\Common\Collections\Collection $participations, - \Chill\EventBundle\Entity\Event $event - ) { + protected function createEditFormMultiple(ArrayIterator $participations, Event $event) + { $form = $this->createForm(\Symfony\Component\Form\Extension\Core\Type\FormType::class, array('participations' => $participations), array( 'method' => 'POST', @@ -710,7 +724,7 @@ class ParticipationController extends Controller ]); } } - return $this->render('ChillEventBundle:Event:confirm_delete.html.twig', [ + return $this->render('ChillEventBundle:Participation:confirm_delete.html.twig', [ 'event_id' => $event->getId(), 'delete_form' => $form->createView() ]); diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index 840a7cda8..83bedcd9e 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -41,3 +41,9 @@ chill_event__list_by_person: defaults: { _controller: "ChillEventBundle:Event:listByPerson" } methods: [ GET ] +chill_event__event_delete: + path: /{event_id}/delete + requirements: + event_id: \d+ + defaults: { _controller: "ChillEventBundle:Event:delete" } + methods: [ GET, DELETE ] \ No newline at end of file diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index b2ab63f01..27c77d456 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -44,11 +44,13 @@ The participation was updated: La participation a été mise à jour There are no participation to edit for this event: Il n'y a pas de participation pour cet événement The participations have been successfully updated.: Les participations ont été mises à jour. The participation has been sucessfully removed: La participation a été correctement supprimée. +The event has been sucessfully removed: L'événement et toutes les participations associées ont été correctement supprimées. The participations were created: Les participations ont été créées Events participation: Participation aux événements - Remove participation: Supprimer la participation +Delete event: Supprimer l'événement Are you sure you want to remove that participation ?: Êtes-vous certain de vouloir supprimer cette participation ? +Are you sure you want to remove that event ?: Êtes-vous certain de vouloir supprimer cet événement, ainsi que toutes les participations associées ? #search Event search: Recherche d'événements diff --git a/Resources/views/Event/confirm_delete.html.twig b/Resources/views/Event/confirm_delete.html.twig index f235ebb00..86b38101f 100644 --- a/Resources/views/Event/confirm_delete.html.twig +++ b/Resources/views/Event/confirm_delete.html.twig @@ -2,14 +2,14 @@ {% set activeRouteKey = 'chill_event__event_show' %} -{% block title 'Remove participation'|trans %} +{% block title 'Delete event'|trans %} {% block event_content %} {{ include('ChillMainBundle:Util:confirmation_template.html.twig', { - 'title' : 'Remove participation'|trans, - 'confirm_question' : 'Are you sure you want to remove that participation ?'|trans, + 'title' : 'Delete event'|trans, + 'confirm_question' : 'Are you sure you want to remove that event ?'|trans, 'cancel_route' : activeRouteKey, 'cancel_parameters' : { 'event_id' : event_id }, 'form' : delete_form diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index e818cab46..7ca6917a7 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -57,6 +57,10 @@
                                                        • {% endif %} +
                                                        • + {{ 'Delete event'|trans }} +
                                                        @@ -87,13 +91,11 @@ {% if is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %}
                                                      • - {{ 'Edit'|trans }} - + class="sc-button bt-edit" title="{{ 'Edit'|trans }}">
                                                      • + class="sc-button bt-delete" title="{{ 'Delete'|trans }}">
                                                      • {% endif %}
                                                      diff --git a/Resources/views/Participation/confirm_delete.html.twig b/Resources/views/Participation/confirm_delete.html.twig new file mode 100644 index 000000000..f235ebb00 --- /dev/null +++ b/Resources/views/Participation/confirm_delete.html.twig @@ -0,0 +1,20 @@ +{% extends 'ChillEventBundle::layout.html.twig' %} + +{% set activeRouteKey = 'chill_event__event_show' %} + +{% block title 'Remove participation'|trans %} + +{% block event_content %} + + {{ include('ChillMainBundle:Util:confirmation_template.html.twig', + { + 'title' : 'Remove participation'|trans, + 'confirm_question' : 'Are you sure you want to remove that participation ?'|trans, + 'cancel_route' : activeRouteKey, + 'cancel_parameters' : { 'event_id' : event_id }, + 'form' : delete_form + } + ) }} + +{% endblock %} + From c3012b7f8a504823d19192a36bc88f5fdddac25a Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 8 Jan 2020 11:44:41 +0100 Subject: [PATCH 146/179] remove dump() --- Controller/ParticipationController.php | 3 +-- .../views/Timeline/event_person_context.html.twig | 11 ----------- Timeline/TimelineEventProvider.php | 1 - 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index bb5c03213..5882e0773 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -51,8 +51,7 @@ class ParticipationController extends Controller */ public function newAction(Request $request) { - dump('coucou'); - + // test the request is correct try { $this->testRequest($request); diff --git a/Resources/views/Timeline/event_person_context.html.twig b/Resources/views/Timeline/event_person_context.html.twig index f105f87be..7548027b1 100644 --- a/Resources/views/Timeline/event_person_context.html.twig +++ b/Resources/views/Timeline/event_person_context.html.twig @@ -1,16 +1,5 @@ {% import 'ChillEventBundle:EventReason:macro.html.twig' as m %} -{# - {{ dump() }} -
                                                      -        event :
                                                      -    | #{{ event.id }} | {{ event.date|localizeddate('short', 'short') }} | {{ event.name }} | center {{ event.center.id }} | circle {{ event.circle.id }} | type {{ event.type.id }} | {{ event.moderator }} |
                                                      -        participations :
                                                      -    {% for participation in event.participations %}
                                                      -    | #{{ participation.id }} | {{ participation.person }} | {{ participation.role.name|localize_translatable_string }} | {{ participation.status.name|localize_translatable_string }} | lastupdate {{ participation.lastupdate|localizeddate('short', 'short') }} |
                                                      -    {% endfor %}
                                                      -    
                                                      -#} {% if "now"|date('U') > event.date|date('U') %} {% set boolDate = 'past' %} {% else %} diff --git a/Timeline/TimelineEventProvider.php b/Timeline/TimelineEventProvider.php index 07b0f6829..b31365b1f 100644 --- a/Timeline/TimelineEventProvider.php +++ b/Timeline/TimelineEventProvider.php @@ -96,7 +96,6 @@ class TimelineEventProvider implements TimelineProviderInterface 'WHERE' => $this->getWhereClause($metadataEvent, $metadataParticipation, $metadataPerson, $args['person']) ); - //dump($query); return $query; } From f2a7c49fe4787a8bf7e8e5108562b0abccefbf45 Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 18 Mar 2020 12:17:32 +0100 Subject: [PATCH 147/179] fix cire-devs/issues/29 create new event --- Resources/views/Event/list.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig index b6c051a3d..cdd2a821d 100644 --- a/Resources/views/Event/list.html.twig +++ b/Resources/views/Event/list.html.twig @@ -46,7 +46,7 @@
                                                      • - + {{ 'New event'|trans }}
                                                      • From 2422fb2ead2f05d3f86b4153d7fcb657288f8379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 22 Apr 2020 22:56:25 +0200 Subject: [PATCH 148/179] remove deps to phpspreadsheet --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index caa75b7ea..b98b9fd00 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,7 @@ } ], "require": { - "chill-project/person": "~1.5", - "phpoffice/phpspreadsheet": "~1.8.2" + "chill-project/person": "~1.5" }, "require-dev": { }, From 9ccb5292ee0ec6998fde05a1397eba94d6219508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 23 Apr 2020 00:10:27 +0200 Subject: [PATCH 149/179] update the way the bundle load assets We use now the standard way to load assets. See [CHANGELOG.md](CHANGELOG.md) for details. --- CHANGELOG.md | 10 ++++++++++ Resources/public/index.js | 1 + chill.webpack.config.js | 8 ++++---- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 Resources/public/index.js diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..9dd73d13f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ + +Branch sf3 +========== + +- fix the way the bundle compile assets ; + + This modification will require to update Chill-Standard to the latest version. + At least, the file `webpack.config.js` should be upgrade [to the last + version](https://framagit.org/Chill-project/Chill-Standard/-/blob/c7a7de68ec49d97c9e1481b72c1f848f9b5cb2d7/webpack.config.js) + diff --git a/Resources/public/index.js b/Resources/public/index.js new file mode 100644 index 000000000..697693c59 --- /dev/null +++ b/Resources/public/index.js @@ -0,0 +1 @@ +require('./css/chillevent.css'); \ No newline at end of file diff --git a/chill.webpack.config.js b/chill.webpack.config.js index b7cd46970..a194522ad 100644 --- a/chill.webpack.config.js +++ b/chill.webpack.config.js @@ -1,4 +1,4 @@ -// this file loads all assets from the Chill event bundle - -// css -require('./Resources/public/css/chillevent.css'); +// this file loads all assets from the Chill Event Bundle +module.exports = function(encore, entries) { + entries.push(__dirname + '/Resources/public/index.js'); +}; \ No newline at end of file From e785b367093eaf6bb398d43924751776871f87d5 Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 10 Jun 2020 11:58:08 +0200 Subject: [PATCH 150/179] fix redirection when only one participation edit --- Controller/ParticipationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index 5882e0773..b39f8387d 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -604,7 +604,7 @@ class ParticipationController extends Controller case 1: // redirect to the form for a single participation return $this->redirectToRoute('chill_event_participation_edit', array( - 'participation_id' => $event->getParticipations()->first()->getId() + 'participation_id' => $event->getParticipations()->current()->getId() )); } From b082b36276f143eb1c3bc4b02762cd387d4f622a Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 10 Jun 2020 12:37:53 +0200 Subject: [PATCH 151/179] list improvements in current sf3 branch --- CHANGELOG.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dd73d13f..171e7664e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,24 @@ Branch sf3 ========== +- fix symfony3 php depreciations ; +- add time to event dates ; +- add new moderator field on events ; +- misc improvements form styles ; +- adapt webpack config for styles sheets ; +- add a new page 'events participation' in menu person, that list all events participation for a person ; +- subscribe a person to an event from person context (issue #19) ; +- improve message translation ; +- add a first step to pick center in new event form ; +- add events in history timeline ; +- export participations list for an event ; +- add event administration pages ; +- add remove participation and remove event feature ; - fix the way the bundle compile assets ; - This modification will require to update Chill-Standard to the latest version. At least, the file `webpack.config.js` should be upgrade [to the last version](https://framagit.org/Chill-project/Chill-Standard/-/blob/c7a7de68ec49d97c9e1481b72c1f848f9b5cb2d7/webpack.config.js) +- fix redirection when only one participation edit ; + + From 88fc2deb685303e98e0e3547760218e4232eaa45 Mon Sep 17 00:00:00 2001 From: Mathieu Date: Wed, 10 Jun 2020 12:39:22 +0200 Subject: [PATCH 152/179] =?UTF-8?q?Mettre=20=C3=A0=20jour=20CHANGELOG.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 171e7664e..66a6d4c33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Branch sf3 - misc improvements form styles ; - adapt webpack config for styles sheets ; - add a new page 'events participation' in menu person, that list all events participation for a person ; -- subscribe a person to an event from person context (issue #19) ; +- subscribe a person to an event from person context ; - improve message translation ; - add a first step to pick center in new event form ; - add events in history timeline ; From da682c22bc85aa8570e2a1e5ae349c12f88b875a Mon Sep 17 00:00:00 2001 From: Tchama Date: Wed, 22 Jul 2020 10:45:22 +0200 Subject: [PATCH 153/179] fix sf4 deprecated: exclude entities from autowired services --- DependencyInjection/ChillEventExtension.php | 12 ++---------- Resources/config/services.yml | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 Resources/config/services.yml diff --git a/DependencyInjection/ChillEventExtension.php b/DependencyInjection/ChillEventExtension.php index 462b17dd6..29c4d6349 100644 --- a/DependencyInjection/ChillEventExtension.php +++ b/DependencyInjection/ChillEventExtension.php @@ -24,16 +24,8 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - $loader = new Loader\YamlFileLoader($container, - new FileLocator(__DIR__.'/../Resources/config/services')); - $loader->load('repositories.yml'); - $loader->load('search.yml'); - $loader->load('authorization.yml'); - $loader->load('forms.yml'); - $loader->load('fixtures.yml'); - $loader->load('menu.yml'); - $loader->load('controller.yml'); - $loader->load('timeline.yml'); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.yml'); } /* (non-PHPdoc) diff --git a/Resources/config/services.yml b/Resources/config/services.yml new file mode 100644 index 000000000..9658882d7 --- /dev/null +++ b/Resources/config/services.yml @@ -0,0 +1,14 @@ +services: + Chill\EventBundle\: + resource: '../..' + exclude: '../../{Entity,Resources/migrations,Resources/test}' + +imports: + - { resource: './services/authorization.yml' } + - { resource: './services/controller.yml' } + - { resource: './services/fixtures.yml' } + - { resource: './services/forms.yml' } + - { resource: './services/menu.yml' } + - { resource: './services/repositories.yml' } + - { resource: './services/search.yml' } + - { resource: './services/timeline.yml' } From c8c76e5a8d8ba2475a4f7a8cd47a4b44ed377bf3 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 23 Jul 2020 12:34:53 +0200 Subject: [PATCH 154/179] sf4 deprecations: new supports and voteOnAttribute methods implemented in ParticipationVoter --- Resources/config/services/authorization.yml | 2 + Security/Authorization/EventVoter.php | 3 +- Security/Authorization/ParticipationVoter.php | 124 +++++++++++++----- 3 files changed, 96 insertions(+), 33 deletions(-) diff --git a/Resources/config/services/authorization.yml b/Resources/config/services/authorization.yml index 131469f65..ca1eb789b 100644 --- a/Resources/config/services/authorization.yml +++ b/Resources/config/services/authorization.yml @@ -12,7 +12,9 @@ services: chill_event.event_participation: class: Chill\EventBundle\Security\Authorization\ParticipationVoter arguments: + - "@security.access.decision_manager" - "@chill.main.security.authorization.helper" + - "@logger" tags: - { name: chill.role } - { name: security.voter } diff --git a/Security/Authorization/EventVoter.php b/Security/Authorization/EventVoter.php index ead7917a7..c62767fa9 100644 --- a/Security/Authorization/EventVoter.php +++ b/Security/Authorization/EventVoter.php @@ -1,6 +1,6 @@ + * Copyright (C) 2020 Champs Libres Cooperative * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -27,6 +27,7 @@ use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; +use Symfony\Component\Security\Core\Role\Role; use Psr\Log\LoggerInterface; /** diff --git a/Security/Authorization/ParticipationVoter.php b/Security/Authorization/ParticipationVoter.php index 385796a71..50e05e279 100644 --- a/Security/Authorization/ParticipationVoter.php +++ b/Security/Authorization/ParticipationVoter.php @@ -1,7 +1,6 @@ + * Copyright (C) 2020 Champs-Libres * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -24,6 +23,12 @@ use Chill\MainBundle\Security\Authorization\AbstractChillVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\EventBundle\Entity\Participation; use Chill\MainBundle\Entity\User; +use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Security\Authorization\PersonVoter; +use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Role\Role; +use Psr\Log\LoggerInterface; /** * @@ -32,56 +37,111 @@ use Chill\MainBundle\Entity\User; */ class ParticipationVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { + const SEE = 'CHILL_EVENT_PARTICIPATION_SEE'; + const SEE_DETAILS = 'CHILL_EVENT_PARTICIPATION_SEE_DETAILS'; + const CREATE = 'CHILL_EVENT_PARTICIPATION_CREATE'; + const UPDATE = 'CHILL_EVENT_PARTICIPATION_UPDATE'; + + const ROLES = [ + self::SEE, + self::SEE_DETAILS, + self::CREATE, + self::UPDATE + ]; + /** - * * @var AuthorizationHelper */ protected $authorizationHelper; - - const CREATE = 'CHILL_EVENT_PARTICIPATION_CREATE'; - const UPDATE = 'CHILL_EVENT_PARTICIPATION_UPDATE'; - - public function __construct(AuthorizationHelper $helper) + + /** + * @var AccessDecisionManagerInterface + */ + protected $accessDecisionManager; + + /** + * @var LoggerInterface + */ + protected $logger; + + public function __construct( + AccessDecisionManagerInterface $accessDecisionManager, + AuthorizationHelper $authorizationHelper, + LoggerInterface $logger + ) { - $this->authorizationHelper = $helper; - } - - protected function getSupportedAttributes() - { - return array( - self::CREATE, self::UPDATE - ); + $this->accessDecisionManager = $accessDecisionManager; + $this->authorizationHelper = $authorizationHelper; + $this->logger = $logger; } - protected function getSupportedClasses() + public function supports($attribute, $subject) { - return array( - Participation::class - ); + return ($subject instanceof Participation && in_array($attribute, self::ROLES)) + || + ($subject instanceof Person && \in_array($attribute, [ self::CREATE, self::SEE ])) + || + (NULL === $subject && $attribute === self::SEE ) + ; } - protected function isGranted($attribute, $participation, $user = null) + /** + * + * @param string $attribute + * @param Participation $subject + * @param TokenInterface $token + * @return boolean + */ + protected function voteOnAttribute($attribute, $subject, TokenInterface $token) { - if (!$user instanceof User) { + $this->logger->debug(sprintf("Voting from %s class", self::class)); + + if (!$token->getUser() instanceof User) { return false; - } - - return $this->authorizationHelper->userHasAccess($user, $participation, $attribute); + } + + if ($subject instanceof Participation) { + return $this->authorizationHelper->userHasAccess($token->getUser(), $subject, $attribute); + + } elseif ($subject instanceof Person) { + return $this->authorizationHelper->userHasAccess($token->getUser(), $subject, $attribute); + + } else { + + // subject is null. We check that at least one center is reachable + $centers = $this->authorizationHelper + ->getReachableCenters($token->getUser(), new Role($attribute)); + + return count($centers) > 0; + } + + if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $person)) { + return false; + } + + return $this->authorizationHelper->userHasAccess( + $token->getUser(), + $subject, + $attribute + ); + } public function getRoles() { - return $this->getSupportedAttributes(); + return self::ROLES; + } + + public function getRolesWithHierarchy() + { + return [ + 'Event' => self::ROLES + ]; } public function getRolesWithoutScope() { - return null; - } - - public function getRolesWithHierarchy() - { - return [ 'Event' => $this->getRoles() ]; + return []; } } From ad8c1bbe9fe26594e0b06c49c45a1ca8f27ee25a Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 24 Jul 2020 18:57:58 +0200 Subject: [PATCH 155/179] sf4 deprecated: migrate Doctrine ORM mapping to annotation --- Entity/Event.php | 103 +++++++++++----- Entity/EventType.php | 74 +++++++++--- Entity/Participation.php | 113 +++++++++++++----- Entity/Role.php | 46 +++++-- Entity/Status.php | 52 ++++++-- Resources/config/doctrine/Event.orm.yml | 31 ----- Resources/config/doctrine/EventType.orm.yml | 22 ---- .../config/doctrine/Participation.orm.yml | 24 ---- Resources/config/doctrine/Role.orm.yml | 19 --- Resources/config/doctrine/Status.orm.yml | 19 --- 10 files changed, 291 insertions(+), 212 deletions(-) delete mode 100644 Resources/config/doctrine/Event.orm.yml delete mode 100644 Resources/config/doctrine/EventType.orm.yml delete mode 100644 Resources/config/doctrine/Participation.orm.yml delete mode 100644 Resources/config/doctrine/Role.orm.yml delete mode 100644 Resources/config/doctrine/Status.orm.yml diff --git a/Entity/Event.php b/Entity/Event.php index acafc5ae3..a92bf8b26 100644 --- a/Entity/Event.php +++ b/Entity/Event.php @@ -1,67 +1,111 @@ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + namespace Chill\EventBundle\Entity; +use Doctrine\ORM\Mapping as ORM; +use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Entity\Center; +use Chill\MainBundle\Entity\Scope; +use Doctrine\Common\Collections\Collection; +use Doctrine\Common\Collections\ArrayCollection; use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\HasScopeInterface; /** - * Event + * Class Event + * + * @package Chill\EventBundle\Entity + * @ORM\Entity(repositoryClass="Chill\EventBundle\Repository\EventRepository") + * @ORM\Table(name="chill_event_event") + * @ORM\HasLifecycleCallbacks() */ class Event implements HasCenterInterface, HasScopeInterface { /** * @var integer + * + * @ORM\Id + * @ORM\Column(name="id", type="integer") + * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string + * @ORM\Column(type="string", length=150) */ private $name; /** * @var \DateTime + * @ORM\Column(type="datetime") */ private $date; /** * - * @var \Chill\MainBundle\Entity\Center + * @var Center + * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Center") */ private $center; /** * * @var EventType + * @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\EventType") */ private $type; /** * - * @var \Chill\MainBundle\Entity\Scope + * @var Scope + * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope") */ private $circle; /** - * @var \Doctrine\Common\Collections\Collection + * @var Participation + * @ORM\OneToMany( + * targetEntity="Chill\EventBundle\Entity\Participation", + * mappedBy="event") */ private $participations; /** - * @var integer + * + * @var User + * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") */ private $moderator; + /** - * Constructor + * Event constructor. */ public function __construct() { - $this->participations = new \Doctrine\Common\Collections\ArrayCollection(); + $this->participations = new ArrayCollection(); } - /** * Get id * @@ -76,7 +120,6 @@ class Event implements HasCenterInterface, HasScopeInterface * Set label * * @param string $label - * * @return Event */ public function setName($label) @@ -100,7 +143,6 @@ class Event implements HasCenterInterface, HasScopeInterface * Set date * * @param \DateTime $date - * * @return Event */ public function setDate(\DateTime $date) @@ -120,7 +162,11 @@ class Event implements HasCenterInterface, HasScopeInterface return $this->date; } - public function setCenter(\Chill\MainBundle\Entity\Center $center) + /** + * @param Center $center + * @return $this + */ + public function setCenter(Center $center) { $this->center = $center; @@ -128,7 +174,6 @@ class Event implements HasCenterInterface, HasScopeInterface } /** - * * @return EventType */ public function getType() @@ -137,9 +182,8 @@ class Event implements HasCenterInterface, HasScopeInterface } /** - * - * @param \Chill\EventBundle\Entity\EventType $type - * @return \Chill\EventBundle\Entity\Event + * @param EventType $type + * @return $this */ public function setType(EventType $type) { @@ -148,8 +192,7 @@ class Event implements HasCenterInterface, HasScopeInterface } /** - * - * @return \Chill\MainBundle\Entity\Center + * @return Center */ public function getCenter() { @@ -157,8 +200,7 @@ class Event implements HasCenterInterface, HasScopeInterface } /** - * - * @return \Chill\MainBundle\Entity\Scope + * @return Scope */ public function getCircle() { @@ -166,9 +208,8 @@ class Event implements HasCenterInterface, HasScopeInterface } /** - * - * @param \Chill\MainBundle\Entity\Scope $circle - * @return \Chill\EventBundle\Entity\Event + * @param Scope $circle + * @return $this */ public function setCircle(\Chill\MainBundle\Entity\Scope $circle) { @@ -177,9 +218,8 @@ class Event implements HasCenterInterface, HasScopeInterface } /** - * * @deprecated - * @return \Chill\MainBundle\Entity\Scope + * @return Scope */ public function getScope() { @@ -190,11 +230,10 @@ class Event implements HasCenterInterface, HasScopeInterface /** * Add participation * - * @param \Chill\EventBundle\Entity\Participation $participation - * + * @param Participation $participation * @return Event */ - public function addParticipation(\Chill\EventBundle\Entity\Participation $participation) + public function addParticipation(Participation $participation) { $this->participations[] = $participation; @@ -204,17 +243,15 @@ class Event implements HasCenterInterface, HasScopeInterface /** * Remove participation * - * @param \Chill\EventBundle\Entity\Participation $participation + * @param Participation $participation */ - public function removeParticipation(\Chill\EventBundle\Entity\Participation $participation) + public function removeParticipation(Participation $participation) { $this->participations->removeElement($participation); } - + /** - * Get participations - * - * @return \ArrayIterator|\Doctrine\Common\Collections\Collection|\Traversable + * @return \ArrayIterator|\Traversable|Collection */ public function getParticipations() { diff --git a/Entity/EventType.php b/Entity/EventType.php index 8f0d2bba4..8c67d8c81 100644 --- a/Entity/EventType.php +++ b/Entity/EventType.php @@ -1,34 +1,74 @@ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + namespace Chill\EventBundle\Entity; +use Doctrine\ORM\Mapping as ORM; +use Doctrine\Common\Collections\Collection; +use Doctrine\Common\Collections\ArrayCollection; + /** - * EventType + * Class EventType + * + * @package Chill\EventBundle\Entity + * @ORM\Entity() + * @ORM\Table(name="chill_event_event_type") + * @ORM\HasLifecycleCallbacks() */ class EventType { /** * @var integer + * + * @ORM\Id + * @ORM\Column(name="id", type="integer") + * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var array + * @ORM\Column(type="json_array") */ private $name; /** * @var boolean + * @ORM\Column(type="boolean") */ private $active; /** - * @var \Doctrine\Common\Collections\Collection + * @var Collection + * @ORM\OneToMany( + * targetEntity="Chill\EventBundle\Entity\Role", + * mappedBy="type") */ private $roles; /** - * @var \Doctrine\Common\Collections\Collection + * @var Collection + * @ORM\OneToMany( + * targetEntity="Chill\EventBundle\Entity\Status", + * mappedBy="type") */ private $statuses; @@ -37,8 +77,8 @@ class EventType */ public function __construct() { - $this->roles = new \Doctrine\Common\Collections\ArrayCollection(); - $this->statuses = new \Doctrine\Common\Collections\ArrayCollection(); + $this->roles = new ArrayCollection(); + $this->statuses = new ArrayCollection(); } /** @@ -55,7 +95,6 @@ class EventType * Set label * * @param array $label - * * @return EventType */ public function setName($label) @@ -79,7 +118,6 @@ class EventType * Set active * * @param boolean $active - * * @return EventType */ public function setActive($active) @@ -102,11 +140,10 @@ class EventType /** * Add role * - * @param \Chill\EventBundle\Entity\Role $role - * + * @param Role $role * @return EventType */ - public function addRole(\Chill\EventBundle\Entity\Role $role) + public function addRole(Role $role) { $this->roles[] = $role; @@ -116,9 +153,9 @@ class EventType /** * Remove role * - * @param \Chill\EventBundle\Entity\Role $role + * @param Role $role */ - public function removeRole(\Chill\EventBundle\Entity\Role $role) + public function removeRole(Role $role) { $this->roles->removeElement($role); } @@ -126,7 +163,7 @@ class EventType /** * Get roles * - * @return \Doctrine\Common\Collections\Collection + * @return Collection */ public function getRoles() { @@ -136,11 +173,10 @@ class EventType /** * Add status * - * @param \Chill\EventBundle\Entity\Status $status - * + * @param Status $status * @return EventType */ - public function addStatus(\Chill\EventBundle\Entity\Status $status) + public function addStatus(Status $status) { $this->statuses[] = $status; @@ -150,9 +186,9 @@ class EventType /** * Remove status * - * @param \Chill\EventBundle\Entity\Status $status + * @param Status $status */ - public function removeStatus(\Chill\EventBundle\Entity\Status $status) + public function removeStatus(Status $status) { $this->statuses->removeElement($status); } @@ -160,7 +196,7 @@ class EventType /** * Get statuses * - * @return \Doctrine\Common\Collections\Collection + * @return Collection */ public function getStatuses() { diff --git a/Entity/Participation.php b/Entity/Participation.php index 07967edca..d578db863 100644 --- a/Entity/Participation.php +++ b/Entity/Participation.php @@ -1,43 +1,83 @@ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + namespace Chill\EventBundle\Entity; +use Doctrine\ORM\Mapping as ORM; +use Chill\MainBundle\Entity\Center; +use Chill\MainBundle\Entity\Scope; +use Chill\PersonBundle\Entity\Person; use Chill\MainBundle\Entity\HasScopeInterface; use Chill\MainBundle\Entity\HasCenterInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; /** - * Participation + * Class Participation + * + * @package Chill\EventBundle\Entity + * @ORM\Entity( + * repositoryClass="Chill\EventBundle\Repository\ParticipationRepository") + * @ORM\Table(name="chill_event_participation") + * @ORM\HasLifecycleCallbacks() */ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAccess { /** * @var integer + * + * @ORM\Id + * @ORM\Column(name="id", type="integer") + * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var \DateTime + * @ORM\Column(type="datetime") */ private $lastUpdate; /** - * @var \Chill\EventBundle\Entity\Event + * @var Event + * @ORM\ManyToOne( + * targetEntity="Chill\EventBundle\Entity\Event", + * inversedBy="participations") */ private $event; /** - * @var \Chill\PersonBundle\Entity\Person + * @var Person + * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person") */ private $person; /** - * @var \Chill\EventBundle\Entity\Role + * @var Role + * @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\Role") */ private $role; /** - * @var \Chill\EventBundle\Entity\Status + * @var Status + * @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\Status") */ private $status; @@ -56,7 +96,6 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce * Set lastUpdate * * @param \DateTime $lastUpdate - * * @return Participation */ protected function update() @@ -80,11 +119,10 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce /** * Set event * - * @param \Chill\EventBundle\Entity\Event $event - * + * @param Event $event * @return Participation */ - public function setEvent(\Chill\EventBundle\Entity\Event $event = null) + public function setEvent(Event $event = null) { if ($this->event !== $event) { $this->update(); @@ -98,7 +136,7 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce /** * Get event * - * @return \Chill\EventBundle\Entity\Event + * @return Event */ public function getEvent() { @@ -108,11 +146,10 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce /** * Set person * - * @param \Chill\PersonBundle\Entity\Person $person - * + * @param Person $person * @return Participation */ - public function setPerson(\Chill\PersonBundle\Entity\Person $person = null) + public function setPerson(Person $person = null) { if ($person !== $this->person) { $this->update(); @@ -126,7 +163,7 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce /** * Get person * - * @return \Chill\PersonBundle\Entity\Person + * @return Person */ public function getPerson() { @@ -136,11 +173,10 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce /** * Set role * - * @param \Chill\EventBundle\Entity\Role $role - * + * @param Role $role * @return Participation */ - public function setRole(\Chill\EventBundle\Entity\Role $role = null) + public function setRole(Role $role = null) { if ($role !== $this->role) { $this->update(); @@ -153,7 +189,7 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce /** * Get role * - * @return \Chill\EventBundle\Entity\Role + * @return Role */ public function getRole() { @@ -163,11 +199,10 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce /** * Set status * - * @param \Chill\EventBundle\Entity\Status $status - * + * @param Status $status * @return Participation */ - public function setStatus(\Chill\EventBundle\Entity\Status $status = null) + public function setStatus(Status $status = null) { if ($this->status !== $status) { $this->update(); @@ -181,13 +216,16 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce /** * Get status * - * @return \Chill\EventBundle\Entity\Status + * @return Status */ public function getStatus() { return $this->status; } - + + /** + * @return Center + */ public function getCenter() { if ($this->getEvent() === NULL) { @@ -197,7 +235,10 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce return $this->getEvent()->getCenter(); } - + + /** + * @return Scope + */ public function getScope() { if ($this->getEvent() === NULL) { @@ -237,14 +278,22 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce ->addViolation(); } } - + + /** + * @param mixed $offset + * @return bool + */ public function offsetExists($offset) { return in_array($offset, array( 'person', 'role', 'status', 'event' )); } - + + /** + * @param mixed $offset + * @return Event|Role|Status|Person|mixed + */ public function offsetGet($offset) { switch ($offset) { @@ -262,7 +311,12 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce break; } } - + + /** + * @param mixed $offset + * @param mixed $value + * @return Participation|void + */ public function offsetSet($offset, $value) { switch($offset) { @@ -280,7 +334,10 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce break; } } - + + /** + * @param mixed $offset + */ public function offsetUnset($offset) { $this->offsetSet($offset, null); diff --git a/Entity/Role.php b/Entity/Role.php index c917dffda..cf7d3a243 100644 --- a/Entity/Role.php +++ b/Entity/Role.php @@ -1,29 +1,64 @@ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + namespace Chill\EventBundle\Entity; +use Doctrine\ORM\Mapping as ORM; + /** - * Role + * Class Role + * + * @package Chill\EventBundle\Entity + * @ORM\Entity() + * @ORM\Table(name="chill_event_role") + * @ORM\HasLifecycleCallbacks() */ class Role { /** * @var integer + * + * @ORM\Id + * @ORM\Column(name="id", type="integer") + * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var array + * @ORM\Column(type="json_array") */ private $name; /** * @var boolean + * @ORM\Column(type="boolean") */ private $active; /** - * @var \Chill\EventBundle\Entity\EventType + * @var EventType + * @ORM\ManyToOne( + * targetEntity="Chill\EventBundle\Entity\EventType", + * inversedBy="roles") */ private $type; @@ -42,7 +77,6 @@ class Role * Set label * * @param array $label - * * @return Role */ public function setName($label) @@ -66,7 +100,6 @@ class Role * Set active * * @param boolean $active - * * @return Role */ public function setActive($active) @@ -90,8 +123,7 @@ class Role /** * Set type * - * @param \Chill\EventBundle\Entity\EventType $type - * + * @param EventType $type * @return Role */ public function setType(EventType $type = null) @@ -104,7 +136,7 @@ class Role /** * Get type * - * @return \Chill\EventBundle\Entity\EventType + * @return EventType */ public function getType() { diff --git a/Entity/Status.php b/Entity/Status.php index 6a4ee29ad..a88bff5c4 100644 --- a/Entity/Status.php +++ b/Entity/Status.php @@ -1,29 +1,64 @@ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + namespace Chill\EventBundle\Entity; +use Doctrine\ORM\Mapping as ORM; + /** - * Status + * Class Status + * + * @package Chill\EventBundle\Entity + * @ORM\Entity() + * @ORM\Table(name="chill_event_status") + * @ORM\HasLifecycleCallbacks() */ class Status { /** * @var integer + * + * @ORM\Id + * @ORM\Column(name="id", type="integer") + * @ORM\GeneratedValue(strategy="AUTO") */ private $id; - + /** * @var array + * @ORM\Column(type="json_array") */ private $name; - + /** * @var boolean + * @ORM\Column(type="boolean") */ private $active; /** - * @var \Chill\EventBundle\Entity\EventType + * @var EventType + * @ORM\ManyToOne( + * targetEntity="Chill\EventBundle\Entity\EventType", + * inversedBy="statuses") */ private $type; @@ -42,7 +77,6 @@ class Status * Set label * * @param array $name - * * @return Status */ public function setName($name) @@ -67,7 +101,6 @@ class Status * Set active * * @param boolean $active - * * @return Status */ public function setActive($active) @@ -91,11 +124,10 @@ class Status /** * Set type * - * @param \Chill\EventBundle\Entity\EventType $type - * + * @param EventType $type * @return Status */ - public function setType(\Chill\EventBundle\Entity\EventType $type = null) + public function setType(EventType $type = null) { $this->type = $type; @@ -105,7 +137,7 @@ class Status /** * Get type * - * @return \Chill\EventBundle\Entity\EventType + * @return EventType */ public function getType() { diff --git a/Resources/config/doctrine/Event.orm.yml b/Resources/config/doctrine/Event.orm.yml deleted file mode 100644 index bb0237c3f..000000000 --- a/Resources/config/doctrine/Event.orm.yml +++ /dev/null @@ -1,31 +0,0 @@ -Chill\EventBundle\Entity\Event: - type: entity - table: chill_event_event - repositoryClass: Chill\EventBundle\Repository\EventRepository - id: - id: - type: integer - id: true - generator: - strategy: AUTO - fields: - name: - type: string - length: '150' - date: - type: datetime - oneToMany: - participations: - targetEntity: Chill\EventBundle\Entity\Participation - mappedBy: event - manyToOne: - center: - targetEntity: Chill\MainBundle\Entity\Center - type: - targetEntity: Chill\EventBundle\Entity\EventType - circle: - targetEntity: Chill\MainBundle\Entity\Scope - moderator: - targetEntity: Chill\MainBundle\Entity\User - - lifecycleCallbacks: { } diff --git a/Resources/config/doctrine/EventType.orm.yml b/Resources/config/doctrine/EventType.orm.yml deleted file mode 100644 index dcfab3ba6..000000000 --- a/Resources/config/doctrine/EventType.orm.yml +++ /dev/null @@ -1,22 +0,0 @@ -Chill\EventBundle\Entity\EventType: - type: entity - table: chill_event_event_type - id: - id: - type: integer - id: true - generator: - strategy: AUTO - fields: - name: - type: json_array - active: - type: boolean - oneToMany: - roles: - targetEntity: Chill\EventBundle\Entity\Role - mappedBy: type - statuses: - targetEntity: Chill\EventBundle\Entity\Status - mappedBy: type - lifecycleCallbacks: { } diff --git a/Resources/config/doctrine/Participation.orm.yml b/Resources/config/doctrine/Participation.orm.yml deleted file mode 100644 index 377dd54fe..000000000 --- a/Resources/config/doctrine/Participation.orm.yml +++ /dev/null @@ -1,24 +0,0 @@ -Chill\EventBundle\Entity\Participation: - type: entity - table: chill_event_participation - repositoryClass: Chill\EventBundle\Repository\ParticipationRepository - id: - id: - type: integer - id: true - generator: - strategy: AUTO - fields: - lastUpdate: - type: datetime - manyToOne: - event: - targetEntity: Chill\EventBundle\Entity\Event - inversedBy: participations - person: - targetEntity: Chill\PersonBundle\Entity\Person - role: - targetEntity: Chill\EventBundle\Entity\Role - status: - targetEntity: Chill\EventBundle\Entity\Status - lifecycleCallbacks: { } diff --git a/Resources/config/doctrine/Role.orm.yml b/Resources/config/doctrine/Role.orm.yml deleted file mode 100644 index b6a1ae677..000000000 --- a/Resources/config/doctrine/Role.orm.yml +++ /dev/null @@ -1,19 +0,0 @@ -Chill\EventBundle\Entity\Role: - type: entity - table: chill_event_role - id: - id: - type: integer - id: true - generator: - strategy: AUTO - fields: - name: - type: json_array - active: - type: boolean - manyToOne: - type: - targetEntity: Chill\EventBundle\Entity\EventType - inversedBy: roles - lifecycleCallbacks: { } diff --git a/Resources/config/doctrine/Status.orm.yml b/Resources/config/doctrine/Status.orm.yml deleted file mode 100644 index f1567f8f0..000000000 --- a/Resources/config/doctrine/Status.orm.yml +++ /dev/null @@ -1,19 +0,0 @@ -Chill\EventBundle\Entity\Status: - type: entity - table: chill_event_status - id: - id: - type: integer - id: true - generator: - strategy: AUTO - fields: - name: - type: json_array - active: - type: boolean - manyToOne: - type: - targetEntity: Chill\EventBundle\Entity\EventType - inversedBy: statuses - lifecycleCallbacks: { } From efee2dc2a9c7aa309fa9b305fe14553606f98515 Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 27 Jul 2020 12:29:23 +0200 Subject: [PATCH 156/179] fix sf4 error with controller service dependencyInjection --- DependencyInjection/ChillEventExtension.php | 8 ++++++++ Resources/config/services.yml | 12 +----------- Resources/config/services/controller.yml | 4 +++- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/DependencyInjection/ChillEventExtension.php b/DependencyInjection/ChillEventExtension.php index 29c4d6349..977a9d9dd 100644 --- a/DependencyInjection/ChillEventExtension.php +++ b/DependencyInjection/ChillEventExtension.php @@ -26,6 +26,14 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); + $loader->load('services/authorization.yml'); + $loader->load('services/controller.yml'); + $loader->load('services/fixtures.yml'); + $loader->load('services/forms.yml'); + $loader->load('services/menu.yml'); + $loader->load('services/repositories.yml'); + $loader->load('services/search.yml'); + $loader->load('services/timeline.yml'); } /* (non-PHPdoc) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 9658882d7..0282f881a 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -1,14 +1,4 @@ services: Chill\EventBundle\: - resource: '../..' + resource: '../../*' exclude: '../../{Entity,Resources/migrations,Resources/test}' - -imports: - - { resource: './services/authorization.yml' } - - { resource: './services/controller.yml' } - - { resource: './services/fixtures.yml' } - - { resource: './services/forms.yml' } - - { resource: './services/menu.yml' } - - { resource: './services/repositories.yml' } - - { resource: './services/search.yml' } - - { resource: './services/timeline.yml' } diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml index 3ad4136c5..a2e5e7a65 100644 --- a/Resources/config/services/controller.yml +++ b/Resources/config/services/controller.yml @@ -1,8 +1,10 @@ services: + Chill\EventBundle\Controller\EventController: arguments: $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' $formFactoryInterface: '@Symfony\Component\Form\FormFactoryInterface' $translator: '@Symfony\Component\Translation\TranslatorInterface' - tags: ['controller.service_arguments'] + public: true + From a70f91d12fa2feb39ae47b60625716aa8b47dfcc Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 27 Jul 2020 13:50:23 +0200 Subject: [PATCH 157/179] sf4 deprecated: timeline builder was private service --- Resources/config/services/timeline.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/config/services/timeline.yml b/Resources/config/services/timeline.yml index 44efe2205..7a8eb366d 100644 --- a/Resources/config/services/timeline.yml +++ b/Resources/config/services/timeline.yml @@ -5,5 +5,6 @@ services: - '@doctrine.orm.entity_manager' - '@chill.main.security.authorization.helper' - '@security.token_storage' + public: true tags: - { name: chill.timeline, context: 'person' } From c2c946221a0b353f85cd594bde9259a6ea515c9e Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 27 Jul 2020 19:43:43 +0200 Subject: [PATCH 158/179] sf4, fix section menu translations and add missing translations --- Resources/translations/messages.fr.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 27c77d456..002ffb250 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -99,3 +99,8 @@ Role list: Liste des rôles Role: Rôles Role creation: Nouveau rôle Role edit: Modifier un rôle + +'': '' +xlsx: xlsx +ods: ods +csv: csv \ No newline at end of file From e774f04d67849d20f2f6d01e11371e0ee4586dd2 Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 28 Jul 2020 16:44:36 +0200 Subject: [PATCH 159/179] upgrade to symfony4, reset all requires into modules --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index b98b9fd00..0a10b88f5 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,6 @@ } ], "require": { - "chill-project/person": "~1.5" }, "require-dev": { }, From a17d3968341e3d767fd302dcfa8ba4513d7f04d8 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 30 Jul 2020 14:25:28 +0200 Subject: [PATCH 160/179] rename syntax for ChillMain twig template calls --- Resources/views/Admin/layout.html.twig | 2 +- Resources/views/Admin/menu.html.twig | 2 +- Resources/views/layout.html.twig | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Resources/views/Admin/layout.html.twig b/Resources/views/Admin/layout.html.twig index b69a5a449..b0e954170 100644 --- a/Resources/views/Admin/layout.html.twig +++ b/Resources/views/Admin/layout.html.twig @@ -16,7 +16,7 @@ * along with this program. If not, see . #} -{% extends "ChillMainBundle::Admin/layoutWithVerticalMenu.html.twig" %} +{% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %} {% block vertical_menu_content %} {{ chill_menu('admin_events', { diff --git a/Resources/views/Admin/menu.html.twig b/Resources/views/Admin/menu.html.twig index db697c172..ca54bbc02 100644 --- a/Resources/views/Admin/menu.html.twig +++ b/Resources/views/Admin/menu.html.twig @@ -16,7 +16,7 @@ * along with this program. If not, see . #} -{% extends "ChillMainBundle::Menu/verticalMenu.html.twig" %} +{% extends "@ChillMain/Menu/verticalMenu.html.twig" %} {% block v_menu_title %} {{ 'Events configuration menu'|trans }} {% endblock %} diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index 3b1a4d092..45eb6e481 100644 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -16,7 +16,7 @@ * along with this program. If not, see . #} -{% extends "ChillMainBundle::layoutWithVerticalMenu.html.twig" %} +{% extends "@ChillMain/layoutWithVerticalMenu.html.twig" %} {% block layout_wvm_content %} {% block event_content %} From e7c6e65c33f4c8ee8ca68c840be876384b8c6f4b Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 30 Jul 2020 17:34:45 +0200 Subject: [PATCH 161/179] sf4, repair errors and make basic and admin chill pages works --- Resources/views/Event/confirm_delete.html.twig | 2 +- Resources/views/Participation/confirm_delete.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/views/Event/confirm_delete.html.twig b/Resources/views/Event/confirm_delete.html.twig index 86b38101f..a9f472f79 100644 --- a/Resources/views/Event/confirm_delete.html.twig +++ b/Resources/views/Event/confirm_delete.html.twig @@ -6,7 +6,7 @@ {% block event_content %} - {{ include('ChillMainBundle:Util:confirmation_template.html.twig', + {{ include('@ChillMain/Util/confirmation_template.html.twig', { 'title' : 'Delete event'|trans, 'confirm_question' : 'Are you sure you want to remove that event ?'|trans, diff --git a/Resources/views/Participation/confirm_delete.html.twig b/Resources/views/Participation/confirm_delete.html.twig index f235ebb00..20bed0940 100644 --- a/Resources/views/Participation/confirm_delete.html.twig +++ b/Resources/views/Participation/confirm_delete.html.twig @@ -6,7 +6,7 @@ {% block event_content %} - {{ include('ChillMainBundle:Util:confirmation_template.html.twig', + {{ include('@ChillMain/Util/confirmation_template.html.twig', { 'title' : 'Remove participation'|trans, 'confirm_question' : 'Are you sure you want to remove that participation ?'|trans, From 0092557d8407971fa67d8ed81e1bc039ee1d194c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 31 Jul 2020 15:52:06 +0200 Subject: [PATCH 162/179] adapt migrations files to flex --- .../migrations => migrations}/Version20160318111334.php | 6 +++--- .../migrations => migrations}/Version20190110140538.php | 4 ++-- .../migrations => migrations}/Version20190115140042.php | 4 ++-- .../migrations => migrations}/Version20190201143121.php | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) rename {Resources/migrations => migrations}/Version20160318111334.php (98%) rename {Resources/migrations => migrations}/Version20190110140538.php (90%) rename {Resources/migrations => migrations}/Version20190115140042.php (93%) rename {Resources/migrations => migrations}/Version20190201143121.php (93%) diff --git a/Resources/migrations/Version20160318111334.php b/migrations/Version20160318111334.php similarity index 98% rename from Resources/migrations/Version20160318111334.php rename to migrations/Version20160318111334.php index df23eaab1..6dd031a66 100644 --- a/Resources/migrations/Version20160318111334.php +++ b/migrations/Version20160318111334.php @@ -2,7 +2,7 @@ namespace Application\Migrations; -use Doctrine\DBAL\Migrations\AbstractMigration; +use Doctrine\Migrations\AbstractMigration; use Doctrine\DBAL\Schema\Schema; /** @@ -13,7 +13,7 @@ class Version20160318111334 extends AbstractMigration /** * @param Schema $schema */ - public function up(Schema $schema) + public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); @@ -109,7 +109,7 @@ class Version20160318111334 extends AbstractMigration /** * @param Schema $schema */ - public function down(Schema $schema) + public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); diff --git a/Resources/migrations/Version20190110140538.php b/migrations/Version20190110140538.php similarity index 90% rename from Resources/migrations/Version20190110140538.php rename to migrations/Version20190110140538.php index 545f58f58..5df97878a 100644 --- a/Resources/migrations/Version20190110140538.php +++ b/migrations/Version20190110140538.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; */ final class Version20190110140538 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); @@ -19,7 +19,7 @@ final class Version20190110140538 extends AbstractMigration } - public function down(Schema $schema) : void + public function down(Schema $schema): void { $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); diff --git a/Resources/migrations/Version20190115140042.php b/migrations/Version20190115140042.php similarity index 93% rename from Resources/migrations/Version20190115140042.php rename to migrations/Version20190115140042.php index 275fabd21..1d7b1dde4 100644 --- a/Resources/migrations/Version20190115140042.php +++ b/migrations/Version20190115140042.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; */ final class Version20190115140042 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); @@ -20,7 +20,7 @@ final class Version20190115140042 extends AbstractMigration $this->addSql('CREATE INDEX IDX_FA320FC8D0AFA354 ON chill_event_event (moderator_id)'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); diff --git a/Resources/migrations/Version20190201143121.php b/migrations/Version20190201143121.php similarity index 93% rename from Resources/migrations/Version20190201143121.php rename to migrations/Version20190201143121.php index 3687e4c2d..c4e4a3780 100644 --- a/Resources/migrations/Version20190201143121.php +++ b/migrations/Version20190201143121.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; */ final class Version20190201143121 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); @@ -19,7 +19,7 @@ final class Version20190201143121 extends AbstractMigration $this->addSql('ALTER TABLE chill_event_event ADD CONSTRAINT FK_FA320FC8D0AFA354 FOREIGN KEY (moderator_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); From 8944d21652650381ff7f374eff8bf8a846176c71 Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 3 Aug 2020 11:10:39 +0200 Subject: [PATCH 163/179] install twig intl-extra, replace localizeddate filter by format_date --- Resources/views/Event/list.html.twig | 2 +- Resources/views/Event/listByPerson.html.twig | 2 +- Resources/views/Event/show.html.twig | 4 ++-- Resources/views/Participation/edit-multiple.html.twig | 4 ++-- Resources/views/Participation/edit.html.twig | 2 +- Resources/views/Timeline/event_person_context.html.twig | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig index cdd2a821d..aaa9bbaba 100644 --- a/Resources/views/Event/list.html.twig +++ b/Resources/views/Event/list.html.twig @@ -19,7 +19,7 @@ {% for event in events %} {{ event.name }} - {{ event.date|localizeddate('long', 'short') }} + {{ event.date|format_date('long', 'short') }} {{ event.type.name|localize_translatable_string }}
                                                          diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index a59d28076..4635946d9 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -38,7 +38,7 @@ {% for participation in participations %} - {{ participation.event.date|localizeddate('long', 'short') }} + {{ participation.event.date|format_date('long', 'short') }} {{ participation.event.name }} {{ participation.event.type.name|localize_translatable_string }} {{ participation.role.name|localize_translatable_string }} diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 7ca6917a7..4690854cc 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -15,7 +15,7 @@ {{ 'Date'|trans }} - {{ event.date|localizeddate('long', 'short') }} + {{ event.date|format_date('long', 'short') }} {{ 'Event type'|trans }} @@ -85,7 +85,7 @@ {{ person_macro.render(participation.person) }} {{ participation.role.name|localize_translatable_string }} {{ participation.status.name|localize_translatable_string }} - {{ participation.lastUpdate|time_diff }} + {{ participation.lastUpdate|time_diff }}
                                                            {% if is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %} diff --git a/Resources/views/Participation/edit-multiple.html.twig b/Resources/views/Participation/edit-multiple.html.twig index 1d6a8c5c7..5031544b5 100644 --- a/Resources/views/Participation/edit-multiple.html.twig +++ b/Resources/views/Participation/edit-multiple.html.twig @@ -13,7 +13,7 @@ {{ 'Date'|trans }} - {{ event.date|localizeddate('long', 'short') }} + {{ event.date|format_date('long', 'short') }} @@ -38,7 +38,7 @@ {{ person_macro.render(participation.vars.value.person) }} {{ form_widget(participation.role) }} {{ form_widget(participation.status) }} - {{ participation.vars.value.lastUpdate|time_diff }} + {{ participation.vars.value.lastUpdate|time_diff }} {% endfor %} diff --git a/Resources/views/Participation/edit.html.twig b/Resources/views/Participation/edit.html.twig index 86b9422a2..2aa336b44 100644 --- a/Resources/views/Participation/edit.html.twig +++ b/Resources/views/Participation/edit.html.twig @@ -17,7 +17,7 @@ {{ 'Date'|trans }} - {{ participation.event.date|localizeddate('long', 'short') }} + {{ participation.event.date|format_date('long', 'short') }} diff --git a/Resources/views/Timeline/event_person_context.html.twig b/Resources/views/Timeline/event_person_context.html.twig index 7548027b1..0f16da380 100644 --- a/Resources/views/Timeline/event_person_context.html.twig +++ b/Resources/views/Timeline/event_person_context.html.twig @@ -7,7 +7,7 @@ {% endif %}
                                                            -

                                                            {{ event.date|localizeddate('long', 'short') }} +

                                                            {{ event.date|format_date('long', 'short') }} / {% if boolDate|trans == 'futur' %} Prochain événement From f94fb0efc15cc6007a96547c87edaf9d32c06b7a Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 4 Aug 2020 11:33:56 +0200 Subject: [PATCH 164/179] enable and fix errors for event bundle + adding knp-time-bundle --- DependencyInjection/Configuration.php | 4 ++-- Resources/translations/messages.fr.yml | 1 - Resources/views/Event/show.html.twig | 5 ++++- Resources/views/Participation/edit-multiple.html.twig | 5 ++++- Timeline/TimelineEventProvider.php | 6 +++--- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 26441ce71..14cbddafe 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -17,8 +17,8 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('chill_event'); + $treeBuilder = new TreeBuilder('chill_event'); + $rootNode = $treeBuilder->getRootNode('chill_event'); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 002ffb250..395f25eae 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -92,7 +92,6 @@ EventType: Types d'événements EventType creation: Nouveau type d'événement EventType edit: Modifier le type d'événement Status list: Liste des statuts -Status: Statuts Status creation: Nouveau statut Status edit: Modifier un statut Role list: Liste des rôles diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 4690854cc..881cda742 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -85,7 +85,10 @@ {{ person_macro.render(participation.person) }} {{ participation.role.name|localize_translatable_string }} {{ participation.status.name|localize_translatable_string }} - {{ participation.lastUpdate|time_diff }} + {{ participation.lastUpdate|ago }} {# sf4 check: filter 'time_diff' is abandoned, + alternative: knplabs/knp-time-bundle provide filter 'ago' #} + +
                                                              {% if is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %} diff --git a/Resources/views/Participation/edit-multiple.html.twig b/Resources/views/Participation/edit-multiple.html.twig index 5031544b5..a9acabe47 100644 --- a/Resources/views/Participation/edit-multiple.html.twig +++ b/Resources/views/Participation/edit-multiple.html.twig @@ -38,7 +38,10 @@ {{ person_macro.render(participation.vars.value.person) }} {{ form_widget(participation.role) }} {{ form_widget(participation.status) }} - {{ participation.vars.value.lastUpdate|time_diff }} + {{ participation.vars.value.lastUpdate|ago }} {# sf4 check: filter 'time_diff' is abandoned, + alternative: knplabs/knp-time-bundle provide filter 'ago' #} + + {% endfor %} diff --git a/Timeline/TimelineEventProvider.php b/Timeline/TimelineEventProvider.php index b31365b1f..3e7c67562 100644 --- a/Timeline/TimelineEventProvider.php +++ b/Timeline/TimelineEventProvider.php @@ -25,7 +25,7 @@ use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Timeline\TimelineProviderInterface; use Doctrine\ORM\EntityManager; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Role\Role; use Doctrine\ORM\Mapping\ClassMetadata; use Chill\PersonBundle\Entity\Person; @@ -59,12 +59,12 @@ class TimelineEventProvider implements TimelineProviderInterface * * @param EntityManager $em * @param AuthorizationHelper $helper - * @param TokenStorage $storage + * @param TokenStorageInterface $storage */ public function __construct( EntityManager $em, AuthorizationHelper $helper, - TokenStorage $storage + TokenStorageInterface $storage ) { $this->em = $em; $this->helper = $helper; From d4948b176fd01f6cafb585781d71a41de8979f77 Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 4 Aug 2020 12:20:16 +0200 Subject: [PATCH 165/179] sf4, setting new path for all config yaml files, and replace 'controller' path syntax in routes definitions --- DependencyInjection/ChillEventExtension.php | 22 +++++++++---------- .../config/routing.yml => config/routes.yaml | 12 +++++----- .../event.yml => config/routes/event.yaml | 16 +++++++------- .../routes/eventtype.yaml | 14 ++++++------ .../routes/participation.yaml | 14 ++++++------ .../role.yml => config/routes/role.yaml | 14 ++++++------ .../status.yml => config/routes/status.yaml | 14 ++++++------ .../services.yml => config/services.yaml | 0 .../services/authorization.yaml | 0 .../services/controller.yaml | 0 .../services/fixtures.yaml | 2 +- .../forms.yml => config/services/forms.yaml | 0 .../menu.yml => config/services/menu.yaml | 0 .../services/repositories.yaml | 0 .../search.yml => config/services/search.yaml | 0 .../services/timeline.yaml | 0 .../validation.yml => config/validation.yaml | 0 17 files changed, 54 insertions(+), 54 deletions(-) rename Resources/config/routing.yml => config/routes.yaml (58%) rename Resources/config/routing/event.yml => config/routes/event.yaml (59%) rename Resources/config/routing/eventtype.yml => config/routes/eventtype.yaml (50%) rename Resources/config/routing/participation.yml => config/routes/participation.yaml (50%) rename Resources/config/routing/role.yml => config/routes/role.yaml (52%) rename Resources/config/routing/status.yml => config/routes/status.yaml (52%) rename Resources/config/services.yml => config/services.yaml (100%) rename Resources/config/services/authorization.yml => config/services/authorization.yaml (100%) rename Resources/config/services/controller.yml => config/services/controller.yaml (100%) rename Resources/config/services/fixtures.yml => config/services/fixtures.yaml (67%) rename Resources/config/services/forms.yml => config/services/forms.yaml (100%) rename Resources/config/services/menu.yml => config/services/menu.yaml (100%) rename Resources/config/services/repositories.yml => config/services/repositories.yaml (100%) rename Resources/config/services/search.yml => config/services/search.yaml (100%) rename Resources/config/services/timeline.yml => config/services/timeline.yaml (100%) rename Resources/config/validation.yml => config/validation.yaml (100%) diff --git a/DependencyInjection/ChillEventExtension.php b/DependencyInjection/ChillEventExtension.php index 977a9d9dd..639d3068d 100644 --- a/DependencyInjection/ChillEventExtension.php +++ b/DependencyInjection/ChillEventExtension.php @@ -24,16 +24,16 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.yml'); - $loader->load('services/authorization.yml'); - $loader->load('services/controller.yml'); - $loader->load('services/fixtures.yml'); - $loader->load('services/forms.yml'); - $loader->load('services/menu.yml'); - $loader->load('services/repositories.yml'); - $loader->load('services/search.yml'); - $loader->load('services/timeline.yml'); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); + $loader->load('services.yaml'); + $loader->load('services/authorization.yaml'); + $loader->load('services/controller.yaml'); + $loader->load('services/fixtures.yaml'); + $loader->load('services/forms.yaml'); + $loader->load('services/menu.yaml'); + $loader->load('services/repositories.yaml'); + $loader->load('services/search.yaml'); + $loader->load('services/timeline.yaml'); } /* (non-PHPdoc) @@ -56,7 +56,7 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface $container->prependExtensionConfig('chill_main', array( 'routing' => array( 'resources' => array( - '@ChillEventBundle/Resources/config/routing.yml' + '@ChillEventBundle/config/routes.yaml' ) ) )); diff --git a/Resources/config/routing.yml b/config/routes.yaml similarity index 58% rename from Resources/config/routing.yml rename to config/routes.yaml index e4e36b796..65ae15ed0 100644 --- a/Resources/config/routing.yml +++ b/config/routes.yaml @@ -1,9 +1,9 @@ chill_event_event: - resource: "@ChillEventBundle/Resources/config/routing/event.yml" + resource: "@ChillEventBundle/config/routes/event.yaml" prefix: /{_locale}/event/event chill_event_participation: - resource: "@ChillEventBundle/Resources/config/routing/participation.yml" + resource: "@ChillEventBundle/config/routes/participation.yaml" prefix: /{_locale}/event/participation @@ -11,7 +11,7 @@ chill_event_participation: chill_event_admin: path: /{_locale}/admin/event - defaults: { _controller: "ChillEventBundle:Admin:index" } + controller: Chill\EventBundle\Controller\AdminController::indexAction options: menus: admin_section: @@ -20,14 +20,14 @@ chill_event_admin: icons: ['calendar'] chill_event_admin_status: - resource: "@ChillEventBundle/Resources/config/routing/status.yml" + resource: "@ChillEventBundle/config/routes/status.yaml" prefix: /{_locale}/admin/event/status chill_event_admin_role: - resource: "@ChillEventBundle/Resources/config/routing/role.yml" + resource: "@ChillEventBundle/config/routes/role.yaml" prefix: /{_locale}/admin/event/role chill_event_admin_event_type: - resource: "@ChillEventBundle/Resources/config/routing/eventtype.yml" + resource: "@ChillEventBundle/config/routes/eventtype.yaml" prefix: /{_locale}/admin/event/event_type diff --git a/Resources/config/routing/event.yml b/config/routes/event.yaml similarity index 59% rename from Resources/config/routing/event.yml rename to config/routes/event.yaml index 83bedcd9e..99dd6447c 100644 --- a/Resources/config/routing/event.yml +++ b/config/routes/event.yaml @@ -1,6 +1,6 @@ chill_event_list_most_recent: path: most_recent - defaults: { _controller: "ChillEventBundle:Event:mostRecentIndex" } + controller: Chill\EventBundle\Controller\EventController::mostRecentIndexAction options: menus: section: @@ -10,11 +10,11 @@ chill_event_list_most_recent: chill_event__event_show: path: /{event_id}/show - defaults: { _controller: "ChillEventBundle:Event:show" } + controller: Chill\EventBundle\Controller\EventController::showAction chill_event__event_new_pickcenter: path: /new/pick-center - defaults: { _controller: "ChillEventBundle:Event:newPickCenter" } + controller: Chill\EventBundle\Controller\EventController::newPickCenterAction options: menus: section: @@ -24,26 +24,26 @@ chill_event__event_new_pickcenter: chill_event__event_new: path: /new - defaults: { _controller: "ChillEventBundle:Event:new" } + controller: Chill\EventBundle\Controller\EventController::newAction methods: [ GET, POST ] chill_event__event_edit: path: /{event_id}/edit - defaults: { _controller: "ChillEventBundle:Event:edit" } + controller: Chill\EventBundle\Controller\EventController::editAction chill_event__event_update: path: /{event_id}/update - defaults: { _controller: "ChillEventBundle:Event:update" } + controller: Chill\EventBundle\Controller\EventController::updateAction methods: [POST, PUT] chill_event__list_by_person: path: /{person_id}/list - defaults: { _controller: "ChillEventBundle:Event:listByPerson" } + controller: Chill\EventBundle\Controller\EventController::listByPersonAction methods: [ GET ] chill_event__event_delete: path: /{event_id}/delete requirements: event_id: \d+ - defaults: { _controller: "ChillEventBundle:Event:delete" } + controller: Chill\EventBundle\Controller\EventController::deleteAction methods: [ GET, DELETE ] \ No newline at end of file diff --git a/Resources/config/routing/eventtype.yml b/config/routes/eventtype.yaml similarity index 50% rename from Resources/config/routing/eventtype.yml rename to config/routes/eventtype.yaml index 198a17ebc..cbde13ce6 100644 --- a/Resources/config/routing/eventtype.yml +++ b/config/routes/eventtype.yaml @@ -1,6 +1,6 @@ chill_eventtype_admin: path: / - defaults: { _controller: "ChillEventBundle:EventType:index" } + controller: Chill\EventBundle\Controller\EventTypeController::indexAction options: menus: admin_events: @@ -9,27 +9,27 @@ chill_eventtype_admin: chill_eventtype_admin_show: path: /{id}/show - defaults: { _controller: "ChillEventBundle:EventType:show" } + controller: Chill\EventBundle\Controller\EventTypeController::showAction chill_eventtype_admin_new: path: /new - defaults: { _controller: "ChillEventBundle:EventType:new" } + controller: Chill\EventBundle\Controller\EventTypeController::newAction chill_eventtype_admin_create: path: /create - defaults: { _controller: "ChillEventBundle:EventType:create" } + controller: Chill\EventBundle\Controller\EventTypeController::createAction methods: POST chill_eventtype_admin_edit: path: /{id}/edit - defaults: { _controller: "ChillEventBundle:EventType:edit" } + controller: Chill\EventBundle\Controller\EventTypeController::editAction chill_eventtype_admin_update: path: /{id}/update - defaults: { _controller: "ChillEventBundle:EventType:update" } + controller: Chill\EventBundle\Controller\EventTypeController::updateAction methods: [POST, PUT] chill_eventtype_admin_delete: path: /{id}/delete - defaults: { _controller: "ChillEventBundle:EventType:delete" } + controller: Chill\EventBundle\Controller\EventTypeController::deleteAction methods: [POST, DELETE] diff --git a/Resources/config/routing/participation.yml b/config/routes/participation.yaml similarity index 50% rename from Resources/config/routing/participation.yml rename to config/routes/participation.yaml index 7d4efc90a..eb11c72a9 100644 --- a/Resources/config/routing/participation.yml +++ b/config/routes/participation.yaml @@ -1,33 +1,33 @@ chill_event_participation_new: path: /new - defaults: { _controller: ChillEventBundle:Participation:new } + controller: Chill\EventBundle\Controller\ParticipationController::newAction chill_event_participation_create: path: /create - defaults: { _controller: ChillEventBundle:Participation:create } + controller: Chill\EventBundle\Controller\ParticipationController::createAction chill_event_participation_edit: path: /{participation_id}/edit - defaults: { _controller: ChillEventBundle:Participation:edit } + controller: Chill\EventBundle\Controller\ParticipationController::editAction chill_event_participation_update: path: /{participation_id}/update - defaults: { _controller: ChillEventBundle:Participation:update } + controller: Chill\EventBundle\Controller\ParticipationController::updateAction methods: [POST] chill_event_participation_edit_multiple: path: /{event_id}/edit_multiple - defaults: { _controller: ChillEventBundle:Participation:editMultiple } + controller: Chill\EventBundle\Controller\ParticipationController::editMultipleAction chill_event_participation_update_multiple: path: /{event_id}/update_multiple - defaults: { _controller: ChillEventBundle:Participation:updateMultiple } + controller: Chill\EventBundle\Controller\ParticipationController::updateMultipleAction methods: [POST] chill_event_participation_delete: path: /{participation_id}/delete requirements: participation_id: \d+ - defaults: { _controller: ChillEventBundle:Participation:delete } + controller: Chill\EventBundle\Controller\ParticipationController::deleteAction methods: [ GET, DELETE ] diff --git a/Resources/config/routing/role.yml b/config/routes/role.yaml similarity index 52% rename from Resources/config/routing/role.yml rename to config/routes/role.yaml index 52746b104..5da3c9f98 100644 --- a/Resources/config/routing/role.yml +++ b/config/routes/role.yaml @@ -1,6 +1,6 @@ chill_event_admin_role: path: / - defaults: { _controller: "ChillEventBundle:Role:index" } + controller: Chill\EventBundle\Controller\RoleController::indexAction options: menus: admin_events: @@ -9,27 +9,27 @@ chill_event_admin_role: chill_event_admin_role_show: path: /{id}/show - defaults: { _controller: "ChillEventBundle:Role:show" } + controller: Chill\EventBundle\Controller\RoleController::showAction chill_event_admin_role_new: path: /new - defaults: { _controller: "ChillEventBundle:Role:new" } + controller: Chill\EventBundle\Controller\RoleController::newAction chill_event_admin_role_create: path: /create - defaults: { _controller: "ChillEventBundle:Role:create" } + controller: Chill\EventBundle\Controller\RoleController::createAction methods: POST chill_event_admin_role_edit: path: /{id}/edit - defaults: { _controller: "ChillEventBundle:Role:edit" } + controller: Chill\EventBundle\Controller\RoleController::editAction chill_event_admin_role_update: path: /{id}/update - defaults: { _controller: "ChillEventBundle:Role:update" } + controller: Chill\EventBundle\Controller\RoleController::updateAction methods: [POST, PUT] chill_event_admin_role_delete: path: /{id}/delete - defaults: { _controller: "ChillEventBundle:Role:delete" } + controller: Chill\EventBundle\Controller\RoleController::deleteAction methods: [POST, DELETE] diff --git a/Resources/config/routing/status.yml b/config/routes/status.yaml similarity index 52% rename from Resources/config/routing/status.yml rename to config/routes/status.yaml index de6c3dbe0..200d79733 100644 --- a/Resources/config/routing/status.yml +++ b/config/routes/status.yaml @@ -1,6 +1,6 @@ chill_event_admin_status: path: / - defaults: { _controller: "ChillEventBundle:Status:index" } + controller: Chill\EventBundle\Controller\StatusController::indexAction options: menus: admin_events: @@ -9,27 +9,27 @@ chill_event_admin_status: chill_event_admin_status_show: path: /{id}/show - defaults: { _controller: "ChillEventBundle:Status:show" } + controller: Chill\EventBundle\Controller\StatusController::showAction chill_event_admin_status_new: path: /new - defaults: { _controller: "ChillEventBundle:Status:new" } + controller: Chill\EventBundle\Controller\StatusController::newAction chill_event_admin_status_create: path: /create - defaults: { _controller: "ChillEventBundle:Status:create" } + controller: Chill\EventBundle\Controller\StatusController::createAction methods: POST chill_event_admin_status_edit: path: /{id}/edit - defaults: { _controller: "ChillEventBundle:Status:edit" } + controller: Chill\EventBundle\Controller\StatusController::editAction chill_event_admin_status_update: path: /{id}/update - defaults: { _controller: "ChillEventBundle:Status:update" } + controller: Chill\EventBundle\Controller\StatusController::updateAction methods: [POST, PUT] chill_event_admin_status_delete: path: /{id}/delete - defaults: { _controller: "ChillEventBundle:Status:delete" } + controller: Chill\EventBundle\Controller\StatusController::deleteAction methods: [POST, DELETE] diff --git a/Resources/config/services.yml b/config/services.yaml similarity index 100% rename from Resources/config/services.yml rename to config/services.yaml diff --git a/Resources/config/services/authorization.yml b/config/services/authorization.yaml similarity index 100% rename from Resources/config/services/authorization.yml rename to config/services/authorization.yaml diff --git a/Resources/config/services/controller.yml b/config/services/controller.yaml similarity index 100% rename from Resources/config/services/controller.yml rename to config/services/controller.yaml diff --git a/Resources/config/services/fixtures.yml b/config/services/fixtures.yaml similarity index 67% rename from Resources/config/services/fixtures.yml rename to config/services/fixtures.yaml index a51618f43..c39947899 100644 --- a/Resources/config/services/fixtures.yml +++ b/config/services/fixtures.yaml @@ -1,4 +1,4 @@ services: Chill\EventBundle\DataFixtures\ORM\: - resource: ../../../DataFixtures/ORM + resource: ../../DataFixtures/ORM tags: [ 'doctrine.fixture.orm' ] diff --git a/Resources/config/services/forms.yml b/config/services/forms.yaml similarity index 100% rename from Resources/config/services/forms.yml rename to config/services/forms.yaml diff --git a/Resources/config/services/menu.yml b/config/services/menu.yaml similarity index 100% rename from Resources/config/services/menu.yml rename to config/services/menu.yaml diff --git a/Resources/config/services/repositories.yml b/config/services/repositories.yaml similarity index 100% rename from Resources/config/services/repositories.yml rename to config/services/repositories.yaml diff --git a/Resources/config/services/search.yml b/config/services/search.yaml similarity index 100% rename from Resources/config/services/search.yml rename to config/services/search.yaml diff --git a/Resources/config/services/timeline.yml b/config/services/timeline.yaml similarity index 100% rename from Resources/config/services/timeline.yml rename to config/services/timeline.yaml diff --git a/Resources/config/validation.yml b/config/validation.yaml similarity index 100% rename from Resources/config/validation.yml rename to config/validation.yaml From 7730f732edaeee30b51f1c008a07c23da1afc5b2 Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 4 Aug 2020 12:23:10 +0200 Subject: [PATCH 166/179] fix error with getInt() and inject PaginatorFactory service in EventController --- Controller/EventController.php | 17 +++++++++++------ Controller/ParticipationController.php | 9 +++++---- config/services.yaml | 4 +--- config/services/controller.yaml | 1 + 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index e9e0b10d6..fa0797ce9 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -24,6 +24,7 @@ namespace Chill\EventBundle\Controller; use Chill\EventBundle\Entity\Participation; use Chill\EventBundle\Form\Type\PickEventType; +use Chill\MainBundle\Pagination\PaginatorFactory; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Csv; use PhpOffice\PhpSpreadsheet\Writer\Ods; @@ -77,6 +78,11 @@ class EventController extends Controller */ protected $translator; + /** + * @var PaginatorFactory + */ + protected $paginator; + /** * EventController constructor. * @@ -84,18 +90,21 @@ class EventController extends Controller * @param AuthorizationHelper $authorizationHelper * @param FormFactoryInterface $formFactoryInterface * @param TranslatorInterface $translator + * @param PaginatorFactory $paginator */ public function __construct( EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper, FormFactoryInterface $formFactoryInterface, - TranslatorInterface $translator + TranslatorInterface $translator, + PaginatorFactory $paginator ) { $this->eventDispatcher = $eventDispatcher; $this->authorizationHelper = $authorizationHelper; $this->formFactoryInterface = $formFactoryInterface; $this->translator = $translator; + $this->paginator = $paginator; } @@ -388,11 +397,7 @@ class EventController extends Controller $total = $em->getRepository('ChillEventBundle:Participation')->countByPerson($person_id); - /** - * @var $paginatorFactory \Chill\MainBundle\Pagination\PaginatorFactory - */ - $paginatorFactory = $this->get('chill_main.paginator_factory'); - $paginator = $paginatorFactory->create($total); + $paginator = $this->paginator->create($total); $participations = $em->getRepository('ChillEventBundle:Participation')->findByPersonInCircle( $person_id, diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index b39f8387d..dda987c0a 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -369,7 +369,8 @@ class ParticipationController extends Controller . "the object manager using the method ".__METHOD__); } - $event_id = $request->query->getInt('event_id', null); + $event_id = $request->query->getInt('event_id', 0); // sf4 check: + // prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given` if ($event_id !== NULL) { $event = $em->getRepository('ChillEventBundle:Event') @@ -388,9 +389,9 @@ class ParticipationController extends Controller // this script should be able to handle multiple, so we translate // single person_id in an array $persons_ids = $request->query->has('person_id') ? - array($request->query->getInt('person_id', null)): - explode(',', $request->query->get('persons_ids')) - ; + [$request->query->getInt('person_id', 0)] // sf4 check: + // prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given` + : explode(',', $request->query->get('persons_ids')); $participations = array(); foreach($persons_ids as $person_id) { diff --git a/config/services.yaml b/config/services.yaml index 0282f881a..8287f32b5 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -1,4 +1,2 @@ services: - Chill\EventBundle\: - resource: '../../*' - exclude: '../../{Entity,Resources/migrations,Resources/test}' + diff --git a/config/services/controller.yaml b/config/services/controller.yaml index a2e5e7a65..0c79dbe1c 100644 --- a/config/services/controller.yaml +++ b/config/services/controller.yaml @@ -6,5 +6,6 @@ services: $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' $formFactoryInterface: '@Symfony\Component\Form\FormFactoryInterface' $translator: '@Symfony\Component\Translation\TranslatorInterface' + $paginator: '@chill_main.paginator_factory' public: true From 5c298c641e2cd8549e3d70c86dca211ae55326e3 Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 4 Aug 2020 16:28:07 +0200 Subject: [PATCH 167/179] move files from Resources/translations/ to translations/ --- {Resources/translations => translations}/messages.fr.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {Resources/translations => translations}/messages.fr.yml (100%) diff --git a/Resources/translations/messages.fr.yml b/translations/messages.fr.yml similarity index 100% rename from Resources/translations/messages.fr.yml rename to translations/messages.fr.yml From 2aa59d1cf357befca4f5db0ca48ec53112f95c50 Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 4 Sep 2020 20:35:32 +0200 Subject: [PATCH 168/179] fix deprecated ObjectManager path in data fixtures scripts --- DataFixtures/ORM/LoadEventTypes.php | 2 +- DataFixtures/ORM/LoadParticipation.php | 2 +- DataFixtures/ORM/LoadRolesACL.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DataFixtures/ORM/LoadEventTypes.php b/DataFixtures/ORM/LoadEventTypes.php index 7fc384035..148582ca3 100644 --- a/DataFixtures/ORM/LoadEventTypes.php +++ b/DataFixtures/ORM/LoadEventTypes.php @@ -5,7 +5,7 @@ namespace Chill\EventBundle\DataFixtures\ORM; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use Chill\EventBundle\Entity\EventType; use Chill\EventBundle\Entity\Role; use Chill\EventBundle\Entity\Status; diff --git a/DataFixtures/ORM/LoadParticipation.php b/DataFixtures/ORM/LoadParticipation.php index 5f18d06b2..b89937abe 100644 --- a/DataFixtures/ORM/LoadParticipation.php +++ b/DataFixtures/ORM/LoadParticipation.php @@ -3,7 +3,7 @@ namespace Chill\EventBundle\DataFixtures\ORM; use Doctrine\Common\DataFixtures\AbstractFixture; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Chill\EventBundle\Entity\Participation; use Chill\MainBundle\Entity\Center; diff --git a/DataFixtures/ORM/LoadRolesACL.php b/DataFixtures/ORM/LoadRolesACL.php index c2c698819..7ef753e52 100644 --- a/DataFixtures/ORM/LoadRolesACL.php +++ b/DataFixtures/ORM/LoadRolesACL.php @@ -25,7 +25,7 @@ use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\DataFixtures\ORM\LoadScopes; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; /** * Add roles to existing groups From 61be9ca943c05eee54846ac75320b5c97dfdab39 Mon Sep 17 00:00:00 2001 From: Tchama Date: Sun, 6 Sep 2020 20:32:46 +0200 Subject: [PATCH 169/179] use '@foo/bar.html.twig' syntax in twig templates --- Resources/views/Admin/layout.html.twig | 2 +- Resources/views/Event/confirm_delete.html.twig | 2 +- Resources/views/Event/edit.html.twig | 2 +- Resources/views/Event/listByPerson.html.twig | 2 +- Resources/views/Event/new.html.twig | 2 +- Resources/views/Event/newPickCenter.html.twig | 2 +- Resources/views/Event/show.html.twig | 2 +- Resources/views/Participation/confirm_delete.html.twig | 2 +- Resources/views/Participation/edit-multiple.html.twig | 2 +- Resources/views/Participation/edit.html.twig | 2 +- Resources/views/Participation/new-multiple.html.twig | 2 +- Resources/views/Participation/new.html.twig | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Resources/views/Admin/layout.html.twig b/Resources/views/Admin/layout.html.twig index b0e954170..160b488eb 100644 --- a/Resources/views/Admin/layout.html.twig +++ b/Resources/views/Admin/layout.html.twig @@ -20,7 +20,7 @@ {% block vertical_menu_content %} {{ chill_menu('admin_events', { - 'layout': 'ChillEventBundle::Admin/menu.html.twig', + 'layout': '@ChillEvent/Admin/menu.html.twig', }) }} {% endblock %} diff --git a/Resources/views/Event/confirm_delete.html.twig b/Resources/views/Event/confirm_delete.html.twig index a9f472f79..86b7c6fd2 100644 --- a/Resources/views/Event/confirm_delete.html.twig +++ b/Resources/views/Event/confirm_delete.html.twig @@ -1,4 +1,4 @@ -{% extends 'ChillEventBundle::layout.html.twig' %} +{% extends '@ChillEvent/layout.html.twig' %} {% set activeRouteKey = 'chill_event__event_show' %} diff --git a/Resources/views/Event/edit.html.twig b/Resources/views/Event/edit.html.twig index a5b69a420..97b32b328 100644 --- a/Resources/views/Event/edit.html.twig +++ b/Resources/views/Event/edit.html.twig @@ -1,4 +1,4 @@ -{% extends 'ChillEventBundle::layout.html.twig' %} +{% extends '@ChillEvent/layout.html.twig' %} {% block title 'Event edit'|trans %} diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index 4635946d9..4a9a9f6c5 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . #} -{% extends "ChillPersonBundle::layout.html.twig" %} +{% extends "@ChillPerson/layout.html.twig" %} {% set activeRouteKey = 'chill_event__list_by_person' %} {% set currentPerson = person.firstName ~ ' ' ~ person.lastName %} diff --git a/Resources/views/Event/new.html.twig b/Resources/views/Event/new.html.twig index 2da0a6bac..33a826f85 100644 --- a/Resources/views/Event/new.html.twig +++ b/Resources/views/Event/new.html.twig @@ -1,4 +1,4 @@ -{% extends 'ChillEventBundle::layout.html.twig' %} +{% extends '@ChillEvent/layout.html.twig' %} {% block title 'Event creation'|trans %} diff --git a/Resources/views/Event/newPickCenter.html.twig b/Resources/views/Event/newPickCenter.html.twig index 753610009..06c29a924 100644 --- a/Resources/views/Event/newPickCenter.html.twig +++ b/Resources/views/Event/newPickCenter.html.twig @@ -1,4 +1,4 @@ -{% extends 'ChillEventBundle::layout.html.twig' %} +{% extends '@ChillEvent/layout.html.twig' %} {% block title 'Event creation'|trans %} diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index 881cda742..f699102f8 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -1,4 +1,4 @@ -{% extends 'ChillEventBundle::layout.html.twig' %} +{% extends '@ChillEvent/layout.html.twig' %} {% block title 'Event : %label%'|trans({ '%label%' : event.name } ) %} diff --git a/Resources/views/Participation/confirm_delete.html.twig b/Resources/views/Participation/confirm_delete.html.twig index 20bed0940..9b023a915 100644 --- a/Resources/views/Participation/confirm_delete.html.twig +++ b/Resources/views/Participation/confirm_delete.html.twig @@ -1,4 +1,4 @@ -{% extends 'ChillEventBundle::layout.html.twig' %} +{% extends '@ChillEvent/layout.html.twig' %} {% set activeRouteKey = 'chill_event__event_show' %} diff --git a/Resources/views/Participation/edit-multiple.html.twig b/Resources/views/Participation/edit-multiple.html.twig index a9acabe47..6db322b69 100644 --- a/Resources/views/Participation/edit-multiple.html.twig +++ b/Resources/views/Participation/edit-multiple.html.twig @@ -1,4 +1,4 @@ -{% extends 'ChillEventBundle::layout.html.twig' %} +{% extends '@ChillEvent/layout.html.twig' %} {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} diff --git a/Resources/views/Participation/edit.html.twig b/Resources/views/Participation/edit.html.twig index 2aa336b44..0f24ae1f6 100644 --- a/Resources/views/Participation/edit.html.twig +++ b/Resources/views/Participation/edit.html.twig @@ -1,4 +1,4 @@ -{% extends 'ChillEventBundle::layout.html.twig' %} +{% extends '@ChillEvent/layout.html.twig' %} {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} diff --git a/Resources/views/Participation/new-multiple.html.twig b/Resources/views/Participation/new-multiple.html.twig index 8cdfed800..f73744a59 100644 --- a/Resources/views/Participation/new-multiple.html.twig +++ b/Resources/views/Participation/new-multiple.html.twig @@ -1,4 +1,4 @@ -{% extends 'ChillEventBundle::layout.html.twig' %} +{% extends '@ChillEvent/layout.html.twig' %} {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} diff --git a/Resources/views/Participation/new.html.twig b/Resources/views/Participation/new.html.twig index ba90e3eda..514161c35 100644 --- a/Resources/views/Participation/new.html.twig +++ b/Resources/views/Participation/new.html.twig @@ -1,4 +1,4 @@ -{% extends 'ChillEventBundle::layout.html.twig' %} +{% extends '@ChillEvent/layout.html.twig' %} {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} From ce28ad18b16db96fb55c28d3798a593593b21f85 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 10 Sep 2020 16:00:32 +0200 Subject: [PATCH 170/179] twig filter format_date need only one argument --- Resources/views/Event/list.html.twig | 2 +- Resources/views/Event/listByPerson.html.twig | 2 +- Resources/views/Event/show.html.twig | 4 ++-- Resources/views/Participation/edit-multiple.html.twig | 4 ++-- Resources/views/Participation/edit.html.twig | 2 +- Resources/views/Timeline/event_person_context.html.twig | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Resources/views/Event/list.html.twig b/Resources/views/Event/list.html.twig index aaa9bbaba..366d0c588 100644 --- a/Resources/views/Event/list.html.twig +++ b/Resources/views/Event/list.html.twig @@ -19,7 +19,7 @@ {% for event in events %} {{ event.name }} - {{ event.date|format_date('long', 'short') }} + {{ event.date|format_date('long') }} {{ event.type.name|localize_translatable_string }}
                                                                diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index 4a9a9f6c5..2cd19d08a 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -38,7 +38,7 @@ {% for participation in participations %} - {{ participation.event.date|format_date('long', 'short') }} + {{ participation.event.date|format_date('short') }} {{ participation.event.name }} {{ participation.event.type.name|localize_translatable_string }} {{ participation.role.name|localize_translatable_string }} diff --git a/Resources/views/Event/show.html.twig b/Resources/views/Event/show.html.twig index f699102f8..9e03f7fe6 100644 --- a/Resources/views/Event/show.html.twig +++ b/Resources/views/Event/show.html.twig @@ -15,7 +15,7 @@ {{ 'Date'|trans }} - {{ event.date|format_date('long', 'short') }} + {{ event.date|format_date('long') }} {{ 'Event type'|trans }} @@ -87,7 +87,7 @@ {{ participation.status.name|localize_translatable_string }} {{ participation.lastUpdate|ago }} {# sf4 check: filter 'time_diff' is abandoned, alternative: knplabs/knp-time-bundle provide filter 'ago' #} - +
                                                                  diff --git a/Resources/views/Participation/edit-multiple.html.twig b/Resources/views/Participation/edit-multiple.html.twig index 6db322b69..18465d241 100644 --- a/Resources/views/Participation/edit-multiple.html.twig +++ b/Resources/views/Participation/edit-multiple.html.twig @@ -13,7 +13,7 @@ {{ 'Date'|trans }} - {{ event.date|format_date('long', 'short') }} + {{ event.date|format_date('long') }} @@ -40,7 +40,7 @@ {{ form_widget(participation.status) }} {{ participation.vars.value.lastUpdate|ago }} {# sf4 check: filter 'time_diff' is abandoned, alternative: knplabs/knp-time-bundle provide filter 'ago' #} - + {% endfor %} diff --git a/Resources/views/Participation/edit.html.twig b/Resources/views/Participation/edit.html.twig index 0f24ae1f6..93956c5f0 100644 --- a/Resources/views/Participation/edit.html.twig +++ b/Resources/views/Participation/edit.html.twig @@ -17,7 +17,7 @@ {{ 'Date'|trans }} - {{ participation.event.date|format_date('long', 'short') }} + {{ participation.event.date|format_date('long') }} diff --git a/Resources/views/Timeline/event_person_context.html.twig b/Resources/views/Timeline/event_person_context.html.twig index 0f16da380..09c2390c2 100644 --- a/Resources/views/Timeline/event_person_context.html.twig +++ b/Resources/views/Timeline/event_person_context.html.twig @@ -7,7 +7,7 @@ {% endif %}
                                                                  -

                                                                  {{ event.date|format_date('long', 'short') }} +

                                                                  {{ event.date|format_date('long') }} / {% if boolDate|trans == 'futur' %} Prochain événement From 20af1b180d1d262dafab96707f44f1e8b5c875e2 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Tue, 19 Jan 2021 17:52:28 +0100 Subject: [PATCH 171/179] Use ScopePickerType in EventType for circle field --- Form/EventType.php | 65 +++----------------------------------- config/services/forms.yaml | 11 +------ 2 files changed, 6 insertions(+), 70 deletions(-) diff --git a/Form/EventType.php b/Form/EventType.php index fcf35eaea..ed1265620 100644 --- a/Form/EventType.php +++ b/Form/EventType.php @@ -23,6 +23,7 @@ namespace Chill\EventBundle\Form; use Chill\EventBundle\Form\Type\PickEventTypeType; +use Chill\MainBundle\Form\Type\ScopePickerType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\Center; @@ -39,77 +40,21 @@ use Symfony\Component\Security\Core\Role\Role; class EventType extends AbstractType { - - /** @var User */ - protected $user; - - /** @var AuthorizationHelper */ - protected $authorizationHelper; - - /** @var TranslatableStringHelper */ - protected $translatableStringHelper; - - public function __construct( - TokenStorageInterface $tokenStorage, - AuthorizationHelper $authorizationHelper, - TranslatableStringHelper $translatableStringHelper - ) { - if (!$tokenStorage->getToken()->getUser() instanceof User) { - throw new \RuntimeException("you should have a valid user"); - } - $this->user = $tokenStorage->getToken()->getUser(); - $this->authorizationHelper = $authorizationHelper; - $this->translatableStringHelper = $translatableStringHelper; - } - /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { - $userReachableCenters = $this->authorizationHelper - ->getReachableCenters($this->user, new Role('CHILL_EVENT_CREATE')); - - $userReachableCirclesByCircleId = array(); - $userReachableCentersByCircleId = array(); - - foreach ($userReachableCenters as $center) { - foreach ($this->authorizationHelper - ->getReachableCircles($this->user, new Role('CHILL_EVENT_CREATE'), $center) as $circle) { - if (array_key_exists($circle->getId(), $userReachableCirclesByCircleId)) { - array_push($userReachableCentersByCircleId[$circle->getId()], $center); - } else { - $userReachableCirclesByCircleId[$circle->getId()] = $circle; - $userReachableCentersByCircleId[$circle->getId()] = array($center); - } - } - } - $builder ->add('name') ->add('date', ChillDateTimeType::class, array( 'required' => true )) - ->add('circle', EntityType::class, array( - 'class' => Scope::class, - 'choices' => array_values($userReachableCirclesByCircleId), - 'choice_label' => function ($circle) { - $helper = $this->translatableStringHelper; - return $helper->localize($circle->getName()); - }, - 'choice_attr' => function ($circle) use ($userReachableCentersByCircleId) { - $centersId = ""; - foreach ($userReachableCentersByCircleId[$circle->getId()] as $center) { - $centersId = $centersId.($center->getId()).','; - } - $centersId = trim($centersId, ','); - return array( - 'data-link-categories' => $centersId, - - ); - }, - )) + ->add('circle', ScopePickerType::class, [ + 'center' => $options['center'], + 'role' => $options['role'] + ]) ->add('type', PickEventTypeType::class, array( 'placeholder' => 'Pick a type of event', 'attr' => array( diff --git a/config/services/forms.yaml b/config/services/forms.yaml index 1c9d819ec..a1c0d925a 100644 --- a/config/services/forms.yaml +++ b/config/services/forms.yaml @@ -5,16 +5,7 @@ services: - "@chill.main.helper.translatable_string" tags: - { name: form.type } - - chill.event.form.event_type_test: - class: Chill\EventBundle\Form\EventType - arguments: - - "@security.token_storage" - - "@chill.main.security.authorization.helper" - - "@chill.main.helper.translatable_string" - tags: - - { name: form.type } - + chill.event.form.participation_type: class: Chill\EventBundle\Form\ParticipationType arguments: From 99e2712cbc1048888a9360516ab8f5c013333b2f Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 26 Jan 2021 15:21:22 +0100 Subject: [PATCH 172/179] translating all roles in admin interface --- translations/messages.fr.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/translations/messages.fr.yml b/translations/messages.fr.yml index 395f25eae..cd37f0163 100644 --- a/translations/messages.fr.yml +++ b/translations/messages.fr.yml @@ -58,10 +58,12 @@ Event search: Recherche d'événements CHILL_EVENT_UPDATE: Modifier un événement CHILL_EVENT_CREATE: Créer un événement -CHILL_EVENT_PARTICIPATION_CREATE: Créer une participation à un événement -CHILL_EVENT_PARTICIPATION_UPDATE: Modifier une participation à un événement CHILL_EVENT_SEE: Voir un événement CHILL_EVENT_SEE_DETAILS: Voir les détails d'un événement +CHILL_EVENT_PARTICIPATION_CREATE: Créer une participation +CHILL_EVENT_PARTICIPATION_UPDATE: Modifier une participation +CHILL_EVENT_PARTICIPATION_SEE: Voir une participation +CHILL_EVENT_PARTICIPATION_SEE_DETAILS: Voir le détail d'une participation # TODO check place to put this Next step: Étape suivante From 8029b9b8ffe3e5ae3e278c7775788d4b4312d69a Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 1 Feb 2021 18:17:33 +0100 Subject: [PATCH 173/179] Replace deprecated extends Controller by AbstractController --- Controller/AdminController.php | 10 +++++----- Controller/EventController.php | 7 ++++--- Controller/EventTypeController.php | 7 ++++--- Controller/ParticipationController.php | 4 ++-- Controller/RoleController.php | 8 ++++---- Controller/StatusController.php | 7 ++++--- 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Controller/AdminController.php b/Controller/AdminController.php index c3a419bf2..182588398 100644 --- a/Controller/AdminController.php +++ b/Controller/AdminController.php @@ -20,15 +20,15 @@ namespace Chill\EventBundle\Controller; - -use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; /** - * Controller for the event configuration section (in - * the admin) + * Class AdminController + * Controller for the event configuration section (in admin section) * + * @package Chill\EventBundle\Controller */ -class AdminController extends Controller +class AdminController extends AbstractController { public function indexAction() { diff --git a/Controller/EventController.php b/Controller/EventController.php index fa0797ce9..9f4d242d1 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -29,6 +29,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Csv; use PhpOffice\PhpSpreadsheet\Writer\Ods; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\HttpFoundation\StreamedResponse; use Chill\EventBundle\Security\Authorization\EventVoter; @@ -37,7 +38,6 @@ use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Privacy\PrivacyEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Chill\PersonBundle\Form\Type\PickPersonType; use Chill\EventBundle\Entity\Event; use Chill\EventBundle\Form\EventType; @@ -53,10 +53,11 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; /** - * Event controller. + * Class EventController * + * @package Chill\EventBundle\Controller */ -class EventController extends Controller +class EventController extends AbstractController { /** * @var EventDispatcherInterface diff --git a/Controller/EventTypeController.php b/Controller/EventTypeController.php index c30c656bf..d1f98f45a 100644 --- a/Controller/EventTypeController.php +++ b/Controller/EventTypeController.php @@ -2,18 +2,19 @@ namespace Chill\EventBundle\Controller; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Chill\EventBundle\Entity\EventType; use Chill\EventBundle\Form\EventTypeType; /** - * EventType controller. + * Class EventTypeController * + * @package Chill\EventBundle\Controller */ -class EventTypeController extends Controller +class EventTypeController extends AbstractController { /** diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index dda987c0a..cc8062afb 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -21,7 +21,7 @@ namespace Chill\EventBundle\Controller; use ArrayIterator; use Chill\EventBundle\Entity\Event; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Chill\EventBundle\Entity\Participation; @@ -36,7 +36,7 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType; * @package Chill\EventBundle\Controller * @author Julien Fastré */ -class ParticipationController extends Controller +class ParticipationController extends AbstractController { /** diff --git a/Controller/RoleController.php b/Controller/RoleController.php index 5f0fe0499..468df32f2 100644 --- a/Controller/RoleController.php +++ b/Controller/RoleController.php @@ -2,18 +2,18 @@ namespace Chill\EventBundle\Controller; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; - use Chill\EventBundle\Entity\Role; use Chill\EventBundle\Form\RoleType; /** - * Role controller. + * Class RoleController * + * @package Chill\EventBundle\Controller */ -class RoleController extends Controller +class RoleController extends AbstractController { /** diff --git a/Controller/StatusController.php b/Controller/StatusController.php index 9147a89b8..be20fbf49 100644 --- a/Controller/StatusController.php +++ b/Controller/StatusController.php @@ -2,18 +2,19 @@ namespace Chill\EventBundle\Controller; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Chill\EventBundle\Entity\Status; use Chill\EventBundle\Form\StatusType; /** - * Status controller. + * Class StatusController * + * @package Chill\EventBundle\Controller */ -class StatusController extends Controller +class StatusController extends AbstractController { /** From 31176f8bc8dbb3e72c39bd8c1d528f9fb03daa90 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 5 Feb 2021 22:30:23 +0100 Subject: [PATCH 174/179] improve ux for admin configuration crud interface --- Controller/EventTypeController.php | 4 +-- Controller/RoleController.php | 4 +-- Controller/StatusController.php | 4 +-- Resources/views/Admin/menu.html.twig | 4 +-- Resources/views/EventType/edit.html.twig | 22 ++++++++------ Resources/views/EventType/index.html.twig | 20 ++++++------- Resources/views/EventType/new.html.twig | 21 ++++++++----- Resources/views/EventType/show.html.twig | 32 ++++++++++---------- Resources/views/Role/edit.html.twig | 24 ++++++++------- Resources/views/Role/index.html.twig | 32 ++++++++++---------- Resources/views/Role/new.html.twig | 22 +++++++++----- Resources/views/Role/show.html.twig | 36 +++++++++++++---------- Resources/views/Status/edit.html.twig | 23 +++++++++------ Resources/views/Status/index.html.twig | 22 +++++++------- Resources/views/Status/new.html.twig | 22 +++++++++----- Resources/views/Status/show.html.twig | 36 +++++++++++++---------- translations/messages.fr.yml | 6 +++- 17 files changed, 184 insertions(+), 150 deletions(-) diff --git a/Controller/EventTypeController.php b/Controller/EventTypeController.php index d1f98f45a..e151f04cb 100644 --- a/Controller/EventTypeController.php +++ b/Controller/EventTypeController.php @@ -46,7 +46,7 @@ class EventTypeController extends AbstractController $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('chill_eventtype_admin_show', + return $this->redirect($this->generateUrl('chill_eventtype_admin', array('id' => $entity->getId()))); } @@ -176,7 +176,7 @@ class EventTypeController extends AbstractController if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('chill_eventtype_admin_edit', + return $this->redirect($this->generateUrl('chill_eventtype_admin', array('id' => $id))); } diff --git a/Controller/RoleController.php b/Controller/RoleController.php index 468df32f2..103729934 100644 --- a/Controller/RoleController.php +++ b/Controller/RoleController.php @@ -45,7 +45,7 @@ class RoleController extends AbstractController $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('chill_event_admin_role_show', + return $this->redirect($this->generateUrl('chill_event_admin_role', array('id' => $entity->getId()))); } @@ -175,7 +175,7 @@ class RoleController extends AbstractController if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('chill_event_admin_role_edit', + return $this->redirect($this->generateUrl('chill_event_admin_role', array('id' => $id))); } diff --git a/Controller/StatusController.php b/Controller/StatusController.php index be20fbf49..e5861aa80 100644 --- a/Controller/StatusController.php +++ b/Controller/StatusController.php @@ -46,7 +46,7 @@ class StatusController extends AbstractController $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('chill_event_admin_status_show', array('id' => $entity->getId()))); + return $this->redirect($this->generateUrl('chill_event_admin_status', array('id' => $entity->getId()))); } return $this->render('ChillEventBundle:Status:new.html.twig', array( @@ -174,7 +174,7 @@ class StatusController extends AbstractController if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('chill_event_admin_status_edit', array('id' => $id))); + return $this->redirect($this->generateUrl('chill_event_admin_status', array('id' => $id))); } return $this->render('ChillEventBundle:Status:edit.html.twig', array( diff --git a/Resources/views/Admin/menu.html.twig b/Resources/views/Admin/menu.html.twig index ca54bbc02..2e804277d 100644 --- a/Resources/views/Admin/menu.html.twig +++ b/Resources/views/Admin/menu.html.twig @@ -17,7 +17,5 @@ #} {% extends "@ChillMain/Menu/verticalMenu.html.twig" %} -{% block v_menu_title %} - {{ 'Events configuration menu'|trans }} -{% endblock %} +{% block v_menu_title %}{{ 'Events configuration menu'|trans }}{% endblock %} diff --git a/Resources/views/EventType/edit.html.twig b/Resources/views/EventType/edit.html.twig index c6c24b052..2142998f5 100644 --- a/Resources/views/EventType/edit.html.twig +++ b/Resources/views/EventType/edit.html.twig @@ -4,14 +4,18 @@

                                                                  {{ 'EventType edit'|trans }}

                                                                  - {{ form(edit_form) }} + {{ form_start(edit_form) }} + {{ form_row(edit_form.name) }} + {{ form_row(edit_form.active) }} - + + + {{ form_end(edit_form) }} {% endblock %} diff --git a/Resources/views/EventType/index.html.twig b/Resources/views/EventType/index.html.twig index 959355878..40fed7220 100644 --- a/Resources/views/EventType/index.html.twig +++ b/Resources/views/EventType/index.html.twig @@ -7,10 +7,10 @@ - - - - + + + + @@ -20,12 +20,12 @@ @@ -34,11 +34,9 @@
                                                                  IdLabelActiveActions{{ 'Id'|trans }}{{ 'Label'|trans }}{{ 'Active'|trans }}{{ 'Actions'|trans }}
                                                                  {{ entity.name|localize_translatable_string }} {{ entity.active }} -
                                                                  -
                                                                    + {% endblock %} diff --git a/Resources/views/EventType/new.html.twig b/Resources/views/EventType/new.html.twig index 7bf1e07a5..b4aa07626 100644 --- a/Resources/views/EventType/new.html.twig +++ b/Resources/views/EventType/new.html.twig @@ -4,13 +4,18 @@

                                                                    {{ 'EventType creation'|trans }}

                                                                    - {{ form(form) }} + {{ form_start(form) }} + {{ form_row(form.name) }} + {{ form_row(form.active) }} - + + + {{ form_end(form) }} {% endblock %} diff --git a/Resources/views/EventType/show.html.twig b/Resources/views/EventType/show.html.twig index cd73d4833..56edf0a19 100644 --- a/Resources/views/EventType/show.html.twig +++ b/Resources/views/EventType/show.html.twig @@ -7,31 +7,31 @@ - + - + - +
                                                                    Id{{ 'Id'|trans }} {{ entity.id }}
                                                                    Name{{ 'Name'|trans }} {{ entity.name|localize_translatable_string }}
                                                                    Active{{ 'Active'|trans }} {{ entity.active }}
                                                                    - + {% endblock %} diff --git a/Resources/views/Role/edit.html.twig b/Resources/views/Role/edit.html.twig index d34538c89..0df6e12de 100644 --- a/Resources/views/Role/edit.html.twig +++ b/Resources/views/Role/edit.html.twig @@ -1,17 +1,21 @@ {% extends "ChillEventBundle:Admin:layout.html.twig" %} {% block admin_content -%} -

                                                                    {{ 'Role edit'|trans }}

                                                                    - {{ form(edit_form) }} + {{ form_start(edit_form) }} + {{ form_row(edit_form.name) }} + {{ form_row(edit_form.type) }} + {{ form_row(edit_form.active) }} - + + + {{ form_end(edit_form) }} {% endblock %} diff --git a/Resources/views/Role/index.html.twig b/Resources/views/Role/index.html.twig index 3cc10167b..f6b071924 100644 --- a/Resources/views/Role/index.html.twig +++ b/Resources/views/Role/index.html.twig @@ -7,11 +7,11 @@ - - - - - + + + + + @@ -22,25 +22,23 @@ {% endfor %}
                                                                    IdNameTypeActiveActions{{ 'Id'|trans }}{{ 'Role'|trans }}{{ 'Type'|trans }}{{ 'Active'|trans }}{{ 'Actions'|trans }}
                                                                    {{ entity.type.name|localize_translatable_string }} {{ entity.active }} - +
                                                                      +
                                                                    • + +
                                                                    • +
                                                                    • + +
                                                                    • +
                                                                    -
                                                                      + {% endblock %} diff --git a/Resources/views/Role/new.html.twig b/Resources/views/Role/new.html.twig index 7b58f7c85..1bc923f09 100644 --- a/Resources/views/Role/new.html.twig +++ b/Resources/views/Role/new.html.twig @@ -4,13 +4,19 @@

                                                                      {{ 'Role creation'|trans }}

                                                                      - {{ form(form) }} + {{ form_start(form) }} + {{ form_row(form.name) }} + {{ form_row(form.type) }} + {{ form_row(form.active) }} - + + + {{ form_end(form) }} {% endblock %} diff --git a/Resources/views/Role/show.html.twig b/Resources/views/Role/show.html.twig index bb149bc29..5d24ef14f 100644 --- a/Resources/views/Role/show.html.twig +++ b/Resources/views/Role/show.html.twig @@ -7,31 +7,35 @@ - + - + - + + + + +
                                                                      Id{{ 'Id'|trans }} {{ entity.id }}
                                                                      Name{{ 'Name'|trans }} {{ entity.name|localize_translatable_string }}
                                                                      Active{{ 'Type'|trans }}{{ entity.type.name|localize_translatable_string }}
                                                                      {{ 'Active'|trans }} {{ entity.active }}
                                                                      - + {% endblock %} diff --git a/Resources/views/Status/edit.html.twig b/Resources/views/Status/edit.html.twig index 1e80e1115..449ddcb1f 100644 --- a/Resources/views/Status/edit.html.twig +++ b/Resources/views/Status/edit.html.twig @@ -4,14 +4,19 @@

                                                                      {{ 'Status edit'|trans }}

                                                                      - {{ form(edit_form) }} + {{ form_start(edit_form) }} + {{ form_row(edit_form.name) }} + {{ form_row(edit_form.type) }} + {{ form_row(edit_form.active) }} - + + + {{ form_end(edit_form) }} {% endblock %} diff --git a/Resources/views/Status/index.html.twig b/Resources/views/Status/index.html.twig index e506a7dd2..8dec02493 100644 --- a/Resources/views/Status/index.html.twig +++ b/Resources/views/Status/index.html.twig @@ -7,11 +7,11 @@ - - - - - + + + + + @@ -22,12 +22,12 @@ @@ -36,11 +36,9 @@
                                                                      IdNameTypeActiveActions{{ 'Id'|trans }}{{ 'Statut'|trans }}{{ 'Type'|trans }}{{ 'Active'|trans }}{{ 'Actions'|trans }}
                                                                      {{ entity.type.name|localize_translatable_string }} {{ entity.active }} -
                                                                      -
                                                                        + {% endblock %} diff --git a/Resources/views/Status/new.html.twig b/Resources/views/Status/new.html.twig index 307963b9e..f88738d23 100644 --- a/Resources/views/Status/new.html.twig +++ b/Resources/views/Status/new.html.twig @@ -4,13 +4,19 @@

                                                                        {{ 'Status creation'|trans }}

                                                                        - {{ form(form) }} + {{ form_start(form) }} + {{ form_row(form.name) }} + {{ form_row(form.type) }} + {{ form_row(form.active) }} - + + + {{ form_end(form) }} {% endblock %} diff --git a/Resources/views/Status/show.html.twig b/Resources/views/Status/show.html.twig index 52931bdd8..e79de3b1c 100644 --- a/Resources/views/Status/show.html.twig +++ b/Resources/views/Status/show.html.twig @@ -7,31 +7,35 @@ - + - + - + + + + +
                                                                        Id{{ 'Id'|trans }} {{ entity.id }}
                                                                        Name{{ 'Status'|trans }} {{ entity.name|localize_translatable_string }}
                                                                        Active{{ 'Type'|trans }}{{ entity.type.name|localize_translatable_string }}
                                                                        {{ 'Active'|trans }} {{ entity.active }}
                                                                        - + {% endblock %} diff --git a/translations/messages.fr.yml b/translations/messages.fr.yml index cd37f0163..45248c4df 100644 --- a/translations/messages.fr.yml +++ b/translations/messages.fr.yml @@ -104,4 +104,8 @@ Role edit: Modifier un rôle '': '' xlsx: xlsx ods: ods -csv: csv \ No newline at end of file +csv: csv + +Create a new role: Créer un nouveau rôle +Create a new type: Créer un nouveau type +Create a new status: Créer un nouveau statut \ No newline at end of file From 41444f415772b471afc24da9cc0d0656192564f4 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 5 Feb 2021 22:49:00 +0100 Subject: [PATCH 175/179] admin area, configuration menu --- Controller/AdminController.php | 11 +++++++++++ Resources/views/EventType/index.html.twig | 2 +- config/routes.yaml | 11 ++++++++++- translations/messages.fr.yml | 6 +++--- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Controller/AdminController.php b/Controller/AdminController.php index 182588398..c55fd172d 100644 --- a/Controller/AdminController.php +++ b/Controller/AdminController.php @@ -30,8 +30,19 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; */ class AdminController extends AbstractController { + /** + * @return \Symfony\Component\HttpFoundation\Response + */ public function indexAction() { return $this->render('ChillEventBundle:Admin:layout.html.twig'); } + + /** + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + public function redirectToAdminIndexAction() + { + return $this->redirectToRoute('chill_main_admin_central'); + } } \ No newline at end of file diff --git a/Resources/views/EventType/index.html.twig b/Resources/views/EventType/index.html.twig index 40fed7220..f1b2f9acd 100644 --- a/Resources/views/EventType/index.html.twig +++ b/Resources/views/EventType/index.html.twig @@ -8,7 +8,7 @@ {{ 'Id'|trans }} - {{ 'Label'|trans }} + {{ 'Type'|trans }} {{ 'Active'|trans }} {{ 'Actions'|trans }} diff --git a/config/routes.yaml b/config/routes.yaml index 65ae15ed0..623f34d28 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -15,10 +15,19 @@ chill_event_admin: options: menus: admin_section: - order: 1000 + order: 2100 label: "Events configuration" icons: ['calendar'] +chill_event_admin_redirect_to_admin_index: + path: /{_locale}/admin/event_redirect_to_main + controller: Chill\EventBundle\Controller\AdminController::redirectToAdminIndexAction + options: + menus: + admin_events: + order: 0 + label: Main admin menu + chill_event_admin_status: resource: "@ChillEventBundle/config/routes/status.yaml" prefix: /{_locale}/admin/event/status diff --git a/translations/messages.fr.yml b/translations/messages.fr.yml index 45248c4df..d684f2c5b 100644 --- a/translations/messages.fr.yml +++ b/translations/messages.fr.yml @@ -84,10 +84,10 @@ Select a format: Choisir un format Export: Exporter -Events configuration: Événements +Events configuration: Config des événements Events configuration menu: Menu des événements -Event status: Statuts -Event roles: Rôles +Event status: Statuts par type d'événement +Event roles: Rôles par type d'événement Event types: Types d'événements EventType list: Liste des types d'événements EventType: Types d'événements From 82dbda8b5ecaff95dd4d9ca534786fdde979a545 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Sat, 6 Feb 2021 13:51:47 +0100 Subject: [PATCH 176/179] improve ux in admin configuration interface --- config/routes.yaml | 2 +- translations/messages.fr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/routes.yaml b/config/routes.yaml index 623f34d28..2abb338bd 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -16,7 +16,7 @@ chill_event_admin: menus: admin_section: order: 2100 - label: "Events configuration" + label: "Events" icons: ['calendar'] chill_event_admin_redirect_to_admin_index: diff --git a/translations/messages.fr.yml b/translations/messages.fr.yml index d684f2c5b..3ca0da260 100644 --- a/translations/messages.fr.yml +++ b/translations/messages.fr.yml @@ -84,7 +84,7 @@ Select a format: Choisir un format Export: Exporter -Events configuration: Config des événements +Events configuration: Configuration des événements Events configuration menu: Menu des événements Event status: Statuts par type d'événement Event roles: Rôles par type d'événement From 84347ec982d30183f77801e716c750315598c7c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 2 Mar 2021 17:15:44 +0100 Subject: [PATCH 177/179] change migration namespace --- migrations/Version20160318111334.php | 2 +- migrations/Version20190110140538.php | 2 +- migrations/Version20190115140042.php | 2 +- migrations/Version20190201143121.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/migrations/Version20160318111334.php b/migrations/Version20160318111334.php index 6dd031a66..50671534e 100644 --- a/migrations/Version20160318111334.php +++ b/migrations/Version20160318111334.php @@ -1,6 +1,6 @@ Date: Thu, 4 Mar 2021 16:13:34 +0100 Subject: [PATCH 178/179] fix logger service dependency injection --- Controller/ParticipationController.php | 20 ++++++++++++++++++-- config/services/controller.yaml | 5 +++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index cc8062afb..4242eb784 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -21,6 +21,7 @@ namespace Chill\EventBundle\Controller; use ArrayIterator; use Chill\EventBundle\Entity\Event; +use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -39,6 +40,21 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType; class ParticipationController extends AbstractController { + /** + * @var \Psr\Log\LoggerInterface + */ + private $logger; + + /** + * ParticipationController constructor. + * + * @param LoggerInterface $logger + */ + public function __construct(LoggerInterface $logger) + { + $this->logger = $logger; + } + /** * Show a form to add a participation * @@ -56,7 +72,7 @@ class ParticipationController extends AbstractController try { $this->testRequest($request); } catch (\RuntimeException $ex) { - $this->get('logger')->warning($ex->getMessage()); + $this->logger->warning($ex->getMessage()); return (new Response()) ->setStatusCode(Response::HTTP_BAD_REQUEST) @@ -234,7 +250,7 @@ class ParticipationController extends AbstractController try { $this->testRequest($request); } catch (\RuntimeException $ex) { - $this->get('logger')->warning($ex->getMessage()); + $this->logger->warning($ex->getMessage()); return (new Response()) ->setStatusCode(Response::HTTP_BAD_REQUEST) diff --git a/config/services/controller.yaml b/config/services/controller.yaml index 0c79dbe1c..b74764e34 100644 --- a/config/services/controller.yaml +++ b/config/services/controller.yaml @@ -8,4 +8,9 @@ services: $translator: '@Symfony\Component\Translation\TranslatorInterface' $paginator: '@chill_main.paginator_factory' public: true + tags: ['controller.service_arguments'] + Chill\EventBundle\Controller\ParticipationController: + arguments: + $logger: '@Psr\Log\LoggerInterface' + tags: ['controller.service_arguments'] From 772ce28859c5c54623b6ee5026275ef501bc6145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 18 Mar 2021 12:46:40 +0100 Subject: [PATCH 179/179] Prepare for moving into monorepo --- .gitignore => src/Bundle/ChillEvent/.gitignore | 0 .gitlab-ci.yml => src/Bundle/ChillEvent/.gitlab-ci.yml | 0 CHANGELOG.md => src/Bundle/ChillEvent/CHANGELOG.md | 0 .../Bundle/ChillEvent/ChillEventBundle.php | 0 .../Bundle/ChillEvent/Controller}/AdminController.php | 0 .../Bundle/ChillEvent/Controller}/EventController.php | 0 .../Bundle/ChillEvent/Controller}/EventTypeController.php | 0 .../Bundle/ChillEvent/Controller}/ParticipationController.php | 0 .../Bundle/ChillEvent/Controller}/RoleController.php | 0 .../Bundle/ChillEvent/Controller}/StatusController.php | 0 .../Bundle/ChillEvent/DataFixtures}/ORM/LoadEventTypes.php | 0 .../Bundle/ChillEvent/DataFixtures}/ORM/LoadParticipation.php | 0 .../Bundle/ChillEvent/DataFixtures}/ORM/LoadRolesACL.php | 0 .../ChillEvent/DependencyInjection}/ChillEventExtension.php | 0 .../Bundle/ChillEvent/DependencyInjection}/Configuration.php | 0 {Entity => src/Bundle/ChillEvent/Entity}/Event.php | 0 {Entity => src/Bundle/ChillEvent/Entity}/EventType.php | 0 {Entity => src/Bundle/ChillEvent/Entity}/Participation.php | 0 {Entity => src/Bundle/ChillEvent/Entity}/Role.php | 0 {Entity => src/Bundle/ChillEvent/Entity}/Status.php | 0 .../Bundle/ChillEvent/Form}/ChoiceLoader/EventChoiceLoader.php | 0 {Form => src/Bundle/ChillEvent/Form}/EventType.php | 0 {Form => src/Bundle/ChillEvent/Form}/EventTypeType.php | 0 {Form => src/Bundle/ChillEvent/Form}/ParticipationType.php | 0 {Form => src/Bundle/ChillEvent/Form}/RoleType.php | 0 {Form => src/Bundle/ChillEvent/Form}/StatusType.php | 0 {Form => src/Bundle/ChillEvent/Form}/Type/PickEventType.php | 0 {Form => src/Bundle/ChillEvent/Form}/Type/PickEventTypeType.php | 0 {Form => src/Bundle/ChillEvent/Form}/Type/PickRoleType.php | 0 {Form => src/Bundle/ChillEvent/Form}/Type/PickStatusType.php | 0 LICENSE.txt => src/Bundle/ChillEvent/LICENSE.txt | 0 {Menu => src/Bundle/ChillEvent/Menu}/PersonMenuBuilder.php | 0 README.md => src/Bundle/ChillEvent/README.md | 0 .../Bundle/ChillEvent/Repository}/EventRepository.php | 0 .../Bundle/ChillEvent/Repository}/ParticipationRepository.php | 0 .../Bundle/ChillEvent/Resources}/public/css/chillevent.css | 0 {Resources => src/Bundle/ChillEvent/Resources}/public/index.js | 0 .../Bundle/ChillEvent/Resources}/test/Fixtures/App/AppKernel.php | 0 .../ChillEvent/Resources}/test/Fixtures/App/config/config.yml | 0 .../Resources}/test/Fixtures/App/config/config_test.yml | 0 .../Resources}/test/Fixtures/App/config/parameters.gitlab-ci.yml | 0 .../ChillEvent/Resources}/test/Fixtures/App/config/parameters.yml | 0 .../Resources}/test/Fixtures/App/config/parameters.yml.dist | 0 .../ChillEvent/Resources}/test/Fixtures/App/config/routing.yml | 0 .../Bundle/ChillEvent/Resources}/test/Fixtures/App/console | 0 {Resources => src/Bundle/ChillEvent/Resources}/test/bootstrap.php | 0 .../Bundle/ChillEvent/Resources}/views/Admin/layout.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Admin/menu.html.twig | 0 .../ChillEvent/Resources}/views/Event/confirm_delete.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Event/edit.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Event/index.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Event/list.html.twig | 0 .../ChillEvent/Resources}/views/Event/listByPerson.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Event/new.html.twig | 0 .../ChillEvent/Resources}/views/Event/newPickCenter.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Event/show.html.twig | 0 .../ChillEvent/Resources}/views/EventReason/macro.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/EventType/edit.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/EventType/index.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/EventType/new.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/EventType/show.html.twig | 0 .../views/Participation/_ignored_participations.html.twig | 0 .../Resources}/views/Participation/confirm_delete.html.twig | 0 .../Resources}/views/Participation/edit-multiple.html.twig | 0 .../ChillEvent/Resources}/views/Participation/edit.html.twig | 0 .../Resources}/views/Participation/new-multiple.html.twig | 0 .../ChillEvent/Resources}/views/Participation/new.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Role/edit.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Role/index.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Role/new.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Role/show.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Status/edit.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Status/index.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Status/new.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/Status/show.html.twig | 0 .../Resources}/views/Timeline/event_person_context.html.twig | 0 .../Bundle/ChillEvent/Resources}/views/layout.html.twig | 0 {Search => src/Bundle/ChillEvent/Search}/EventSearch.php | 0 .../Bundle/ChillEvent/Security}/Authorization/EventVoter.php | 0 .../ChillEvent/Security}/Authorization/ParticipationVoter.php | 0 .../Bundle/ChillEvent/Tests}/Controller/EventControllerTest.php | 0 .../ChillEvent/Tests}/Controller/EventTypeControllerTest.php | 0 .../ChillEvent/Tests}/Controller/ParticipationControllerTest.php | 0 .../Bundle/ChillEvent/Tests}/Controller/RoleControllerTest.php | 0 .../Bundle/ChillEvent/Tests}/Controller/StatusControllerTest.php | 0 {Tests => src/Bundle/ChillEvent/Tests}/Search/EventSearchTest.php | 0 .../Bundle/ChillEvent/Timeline}/TimelineEventProvider.php | 0 apigen.neon => src/Bundle/ChillEvent/apigen.neon | 0 .../Bundle/ChillEvent/chill.webpack.config.js | 0 composer.json => src/Bundle/ChillEvent/composer.json | 0 {config => src/Bundle/ChillEvent/config}/routes.yaml | 0 {config => src/Bundle/ChillEvent/config}/routes/event.yaml | 0 {config => src/Bundle/ChillEvent/config}/routes/eventtype.yaml | 0 .../Bundle/ChillEvent/config}/routes/participation.yaml | 0 {config => src/Bundle/ChillEvent/config}/routes/role.yaml | 0 {config => src/Bundle/ChillEvent/config}/routes/status.yaml | 0 {config => src/Bundle/ChillEvent/config}/services.yaml | 0 .../Bundle/ChillEvent/config}/services/authorization.yaml | 0 {config => src/Bundle/ChillEvent/config}/services/controller.yaml | 0 {config => src/Bundle/ChillEvent/config}/services/fixtures.yaml | 0 {config => src/Bundle/ChillEvent/config}/services/forms.yaml | 0 {config => src/Bundle/ChillEvent/config}/services/menu.yaml | 0 .../Bundle/ChillEvent/config}/services/repositories.yaml | 0 {config => src/Bundle/ChillEvent/config}/services/search.yaml | 0 {config => src/Bundle/ChillEvent/config}/services/timeline.yaml | 0 {config => src/Bundle/ChillEvent/config}/validation.yaml | 0 .../Bundle/ChillEvent/migrations}/Version20160318111334.php | 0 .../Bundle/ChillEvent/migrations}/Version20190110140538.php | 0 .../Bundle/ChillEvent/migrations}/Version20190115140042.php | 0 .../Bundle/ChillEvent/migrations}/Version20190201143121.php | 0 phpunit.xml.dist => src/Bundle/ChillEvent/phpunit.xml.dist | 0 .../Bundle/ChillEvent/translations}/messages.fr.yml | 0 112 files changed, 0 insertions(+), 0 deletions(-) rename .gitignore => src/Bundle/ChillEvent/.gitignore (100%) rename .gitlab-ci.yml => src/Bundle/ChillEvent/.gitlab-ci.yml (100%) rename CHANGELOG.md => src/Bundle/ChillEvent/CHANGELOG.md (100%) rename ChillEventBundle.php => src/Bundle/ChillEvent/ChillEventBundle.php (100%) rename {Controller => src/Bundle/ChillEvent/Controller}/AdminController.php (100%) rename {Controller => src/Bundle/ChillEvent/Controller}/EventController.php (100%) rename {Controller => src/Bundle/ChillEvent/Controller}/EventTypeController.php (100%) rename {Controller => src/Bundle/ChillEvent/Controller}/ParticipationController.php (100%) rename {Controller => src/Bundle/ChillEvent/Controller}/RoleController.php (100%) rename {Controller => src/Bundle/ChillEvent/Controller}/StatusController.php (100%) rename {DataFixtures => src/Bundle/ChillEvent/DataFixtures}/ORM/LoadEventTypes.php (100%) rename {DataFixtures => src/Bundle/ChillEvent/DataFixtures}/ORM/LoadParticipation.php (100%) rename {DataFixtures => src/Bundle/ChillEvent/DataFixtures}/ORM/LoadRolesACL.php (100%) rename {DependencyInjection => src/Bundle/ChillEvent/DependencyInjection}/ChillEventExtension.php (100%) rename {DependencyInjection => src/Bundle/ChillEvent/DependencyInjection}/Configuration.php (100%) rename {Entity => src/Bundle/ChillEvent/Entity}/Event.php (100%) rename {Entity => src/Bundle/ChillEvent/Entity}/EventType.php (100%) rename {Entity => src/Bundle/ChillEvent/Entity}/Participation.php (100%) rename {Entity => src/Bundle/ChillEvent/Entity}/Role.php (100%) rename {Entity => src/Bundle/ChillEvent/Entity}/Status.php (100%) rename {Form => src/Bundle/ChillEvent/Form}/ChoiceLoader/EventChoiceLoader.php (100%) rename {Form => src/Bundle/ChillEvent/Form}/EventType.php (100%) rename {Form => src/Bundle/ChillEvent/Form}/EventTypeType.php (100%) rename {Form => src/Bundle/ChillEvent/Form}/ParticipationType.php (100%) rename {Form => src/Bundle/ChillEvent/Form}/RoleType.php (100%) rename {Form => src/Bundle/ChillEvent/Form}/StatusType.php (100%) rename {Form => src/Bundle/ChillEvent/Form}/Type/PickEventType.php (100%) rename {Form => src/Bundle/ChillEvent/Form}/Type/PickEventTypeType.php (100%) rename {Form => src/Bundle/ChillEvent/Form}/Type/PickRoleType.php (100%) rename {Form => src/Bundle/ChillEvent/Form}/Type/PickStatusType.php (100%) rename LICENSE.txt => src/Bundle/ChillEvent/LICENSE.txt (100%) rename {Menu => src/Bundle/ChillEvent/Menu}/PersonMenuBuilder.php (100%) rename README.md => src/Bundle/ChillEvent/README.md (100%) rename {Repository => src/Bundle/ChillEvent/Repository}/EventRepository.php (100%) rename {Repository => src/Bundle/ChillEvent/Repository}/ParticipationRepository.php (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/public/css/chillevent.css (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/public/index.js (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/test/Fixtures/App/AppKernel.php (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/test/Fixtures/App/config/config.yml (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/test/Fixtures/App/config/config_test.yml (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/test/Fixtures/App/config/parameters.gitlab-ci.yml (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/test/Fixtures/App/config/parameters.yml (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/test/Fixtures/App/config/parameters.yml.dist (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/test/Fixtures/App/config/routing.yml (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/test/Fixtures/App/console (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/test/bootstrap.php (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Admin/layout.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Admin/menu.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Event/confirm_delete.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Event/edit.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Event/index.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Event/list.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Event/listByPerson.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Event/new.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Event/newPickCenter.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Event/show.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/EventReason/macro.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/EventType/edit.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/EventType/index.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/EventType/new.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/EventType/show.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Participation/_ignored_participations.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Participation/confirm_delete.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Participation/edit-multiple.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Participation/edit.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Participation/new-multiple.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Participation/new.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Role/edit.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Role/index.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Role/new.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Role/show.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Status/edit.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Status/index.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Status/new.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Status/show.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/Timeline/event_person_context.html.twig (100%) rename {Resources => src/Bundle/ChillEvent/Resources}/views/layout.html.twig (100%) rename {Search => src/Bundle/ChillEvent/Search}/EventSearch.php (100%) rename {Security => src/Bundle/ChillEvent/Security}/Authorization/EventVoter.php (100%) rename {Security => src/Bundle/ChillEvent/Security}/Authorization/ParticipationVoter.php (100%) rename {Tests => src/Bundle/ChillEvent/Tests}/Controller/EventControllerTest.php (100%) rename {Tests => src/Bundle/ChillEvent/Tests}/Controller/EventTypeControllerTest.php (100%) rename {Tests => src/Bundle/ChillEvent/Tests}/Controller/ParticipationControllerTest.php (100%) rename {Tests => src/Bundle/ChillEvent/Tests}/Controller/RoleControllerTest.php (100%) rename {Tests => src/Bundle/ChillEvent/Tests}/Controller/StatusControllerTest.php (100%) rename {Tests => src/Bundle/ChillEvent/Tests}/Search/EventSearchTest.php (100%) rename {Timeline => src/Bundle/ChillEvent/Timeline}/TimelineEventProvider.php (100%) rename apigen.neon => src/Bundle/ChillEvent/apigen.neon (100%) rename chill.webpack.config.js => src/Bundle/ChillEvent/chill.webpack.config.js (100%) rename composer.json => src/Bundle/ChillEvent/composer.json (100%) rename {config => src/Bundle/ChillEvent/config}/routes.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/routes/event.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/routes/eventtype.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/routes/participation.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/routes/role.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/routes/status.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/services.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/services/authorization.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/services/controller.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/services/fixtures.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/services/forms.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/services/menu.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/services/repositories.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/services/search.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/services/timeline.yaml (100%) rename {config => src/Bundle/ChillEvent/config}/validation.yaml (100%) rename {migrations => src/Bundle/ChillEvent/migrations}/Version20160318111334.php (100%) rename {migrations => src/Bundle/ChillEvent/migrations}/Version20190110140538.php (100%) rename {migrations => src/Bundle/ChillEvent/migrations}/Version20190115140042.php (100%) rename {migrations => src/Bundle/ChillEvent/migrations}/Version20190201143121.php (100%) rename phpunit.xml.dist => src/Bundle/ChillEvent/phpunit.xml.dist (100%) rename {translations => src/Bundle/ChillEvent/translations}/messages.fr.yml (100%) diff --git a/.gitignore b/src/Bundle/ChillEvent/.gitignore similarity index 100% rename from .gitignore rename to src/Bundle/ChillEvent/.gitignore diff --git a/.gitlab-ci.yml b/src/Bundle/ChillEvent/.gitlab-ci.yml similarity index 100% rename from .gitlab-ci.yml rename to src/Bundle/ChillEvent/.gitlab-ci.yml diff --git a/CHANGELOG.md b/src/Bundle/ChillEvent/CHANGELOG.md similarity index 100% rename from CHANGELOG.md rename to src/Bundle/ChillEvent/CHANGELOG.md diff --git a/ChillEventBundle.php b/src/Bundle/ChillEvent/ChillEventBundle.php similarity index 100% rename from ChillEventBundle.php rename to src/Bundle/ChillEvent/ChillEventBundle.php diff --git a/Controller/AdminController.php b/src/Bundle/ChillEvent/Controller/AdminController.php similarity index 100% rename from Controller/AdminController.php rename to src/Bundle/ChillEvent/Controller/AdminController.php diff --git a/Controller/EventController.php b/src/Bundle/ChillEvent/Controller/EventController.php similarity index 100% rename from Controller/EventController.php rename to src/Bundle/ChillEvent/Controller/EventController.php diff --git a/Controller/EventTypeController.php b/src/Bundle/ChillEvent/Controller/EventTypeController.php similarity index 100% rename from Controller/EventTypeController.php rename to src/Bundle/ChillEvent/Controller/EventTypeController.php diff --git a/Controller/ParticipationController.php b/src/Bundle/ChillEvent/Controller/ParticipationController.php similarity index 100% rename from Controller/ParticipationController.php rename to src/Bundle/ChillEvent/Controller/ParticipationController.php diff --git a/Controller/RoleController.php b/src/Bundle/ChillEvent/Controller/RoleController.php similarity index 100% rename from Controller/RoleController.php rename to src/Bundle/ChillEvent/Controller/RoleController.php diff --git a/Controller/StatusController.php b/src/Bundle/ChillEvent/Controller/StatusController.php similarity index 100% rename from Controller/StatusController.php rename to src/Bundle/ChillEvent/Controller/StatusController.php diff --git a/DataFixtures/ORM/LoadEventTypes.php b/src/Bundle/ChillEvent/DataFixtures/ORM/LoadEventTypes.php similarity index 100% rename from DataFixtures/ORM/LoadEventTypes.php rename to src/Bundle/ChillEvent/DataFixtures/ORM/LoadEventTypes.php diff --git a/DataFixtures/ORM/LoadParticipation.php b/src/Bundle/ChillEvent/DataFixtures/ORM/LoadParticipation.php similarity index 100% rename from DataFixtures/ORM/LoadParticipation.php rename to src/Bundle/ChillEvent/DataFixtures/ORM/LoadParticipation.php diff --git a/DataFixtures/ORM/LoadRolesACL.php b/src/Bundle/ChillEvent/DataFixtures/ORM/LoadRolesACL.php similarity index 100% rename from DataFixtures/ORM/LoadRolesACL.php rename to src/Bundle/ChillEvent/DataFixtures/ORM/LoadRolesACL.php diff --git a/DependencyInjection/ChillEventExtension.php b/src/Bundle/ChillEvent/DependencyInjection/ChillEventExtension.php similarity index 100% rename from DependencyInjection/ChillEventExtension.php rename to src/Bundle/ChillEvent/DependencyInjection/ChillEventExtension.php diff --git a/DependencyInjection/Configuration.php b/src/Bundle/ChillEvent/DependencyInjection/Configuration.php similarity index 100% rename from DependencyInjection/Configuration.php rename to src/Bundle/ChillEvent/DependencyInjection/Configuration.php diff --git a/Entity/Event.php b/src/Bundle/ChillEvent/Entity/Event.php similarity index 100% rename from Entity/Event.php rename to src/Bundle/ChillEvent/Entity/Event.php diff --git a/Entity/EventType.php b/src/Bundle/ChillEvent/Entity/EventType.php similarity index 100% rename from Entity/EventType.php rename to src/Bundle/ChillEvent/Entity/EventType.php diff --git a/Entity/Participation.php b/src/Bundle/ChillEvent/Entity/Participation.php similarity index 100% rename from Entity/Participation.php rename to src/Bundle/ChillEvent/Entity/Participation.php diff --git a/Entity/Role.php b/src/Bundle/ChillEvent/Entity/Role.php similarity index 100% rename from Entity/Role.php rename to src/Bundle/ChillEvent/Entity/Role.php diff --git a/Entity/Status.php b/src/Bundle/ChillEvent/Entity/Status.php similarity index 100% rename from Entity/Status.php rename to src/Bundle/ChillEvent/Entity/Status.php diff --git a/Form/ChoiceLoader/EventChoiceLoader.php b/src/Bundle/ChillEvent/Form/ChoiceLoader/EventChoiceLoader.php similarity index 100% rename from Form/ChoiceLoader/EventChoiceLoader.php rename to src/Bundle/ChillEvent/Form/ChoiceLoader/EventChoiceLoader.php diff --git a/Form/EventType.php b/src/Bundle/ChillEvent/Form/EventType.php similarity index 100% rename from Form/EventType.php rename to src/Bundle/ChillEvent/Form/EventType.php diff --git a/Form/EventTypeType.php b/src/Bundle/ChillEvent/Form/EventTypeType.php similarity index 100% rename from Form/EventTypeType.php rename to src/Bundle/ChillEvent/Form/EventTypeType.php diff --git a/Form/ParticipationType.php b/src/Bundle/ChillEvent/Form/ParticipationType.php similarity index 100% rename from Form/ParticipationType.php rename to src/Bundle/ChillEvent/Form/ParticipationType.php diff --git a/Form/RoleType.php b/src/Bundle/ChillEvent/Form/RoleType.php similarity index 100% rename from Form/RoleType.php rename to src/Bundle/ChillEvent/Form/RoleType.php diff --git a/Form/StatusType.php b/src/Bundle/ChillEvent/Form/StatusType.php similarity index 100% rename from Form/StatusType.php rename to src/Bundle/ChillEvent/Form/StatusType.php diff --git a/Form/Type/PickEventType.php b/src/Bundle/ChillEvent/Form/Type/PickEventType.php similarity index 100% rename from Form/Type/PickEventType.php rename to src/Bundle/ChillEvent/Form/Type/PickEventType.php diff --git a/Form/Type/PickEventTypeType.php b/src/Bundle/ChillEvent/Form/Type/PickEventTypeType.php similarity index 100% rename from Form/Type/PickEventTypeType.php rename to src/Bundle/ChillEvent/Form/Type/PickEventTypeType.php diff --git a/Form/Type/PickRoleType.php b/src/Bundle/ChillEvent/Form/Type/PickRoleType.php similarity index 100% rename from Form/Type/PickRoleType.php rename to src/Bundle/ChillEvent/Form/Type/PickRoleType.php diff --git a/Form/Type/PickStatusType.php b/src/Bundle/ChillEvent/Form/Type/PickStatusType.php similarity index 100% rename from Form/Type/PickStatusType.php rename to src/Bundle/ChillEvent/Form/Type/PickStatusType.php diff --git a/LICENSE.txt b/src/Bundle/ChillEvent/LICENSE.txt similarity index 100% rename from LICENSE.txt rename to src/Bundle/ChillEvent/LICENSE.txt diff --git a/Menu/PersonMenuBuilder.php b/src/Bundle/ChillEvent/Menu/PersonMenuBuilder.php similarity index 100% rename from Menu/PersonMenuBuilder.php rename to src/Bundle/ChillEvent/Menu/PersonMenuBuilder.php diff --git a/README.md b/src/Bundle/ChillEvent/README.md similarity index 100% rename from README.md rename to src/Bundle/ChillEvent/README.md diff --git a/Repository/EventRepository.php b/src/Bundle/ChillEvent/Repository/EventRepository.php similarity index 100% rename from Repository/EventRepository.php rename to src/Bundle/ChillEvent/Repository/EventRepository.php diff --git a/Repository/ParticipationRepository.php b/src/Bundle/ChillEvent/Repository/ParticipationRepository.php similarity index 100% rename from Repository/ParticipationRepository.php rename to src/Bundle/ChillEvent/Repository/ParticipationRepository.php diff --git a/Resources/public/css/chillevent.css b/src/Bundle/ChillEvent/Resources/public/css/chillevent.css similarity index 100% rename from Resources/public/css/chillevent.css rename to src/Bundle/ChillEvent/Resources/public/css/chillevent.css diff --git a/Resources/public/index.js b/src/Bundle/ChillEvent/Resources/public/index.js similarity index 100% rename from Resources/public/index.js rename to src/Bundle/ChillEvent/Resources/public/index.js diff --git a/Resources/test/Fixtures/App/AppKernel.php b/src/Bundle/ChillEvent/Resources/test/Fixtures/App/AppKernel.php similarity index 100% rename from Resources/test/Fixtures/App/AppKernel.php rename to src/Bundle/ChillEvent/Resources/test/Fixtures/App/AppKernel.php diff --git a/Resources/test/Fixtures/App/config/config.yml b/src/Bundle/ChillEvent/Resources/test/Fixtures/App/config/config.yml similarity index 100% rename from Resources/test/Fixtures/App/config/config.yml rename to src/Bundle/ChillEvent/Resources/test/Fixtures/App/config/config.yml diff --git a/Resources/test/Fixtures/App/config/config_test.yml b/src/Bundle/ChillEvent/Resources/test/Fixtures/App/config/config_test.yml similarity index 100% rename from Resources/test/Fixtures/App/config/config_test.yml rename to src/Bundle/ChillEvent/Resources/test/Fixtures/App/config/config_test.yml diff --git a/Resources/test/Fixtures/App/config/parameters.gitlab-ci.yml b/src/Bundle/ChillEvent/Resources/test/Fixtures/App/config/parameters.gitlab-ci.yml similarity index 100% rename from Resources/test/Fixtures/App/config/parameters.gitlab-ci.yml rename to src/Bundle/ChillEvent/Resources/test/Fixtures/App/config/parameters.gitlab-ci.yml diff --git a/Resources/test/Fixtures/App/config/parameters.yml b/src/Bundle/ChillEvent/Resources/test/Fixtures/App/config/parameters.yml similarity index 100% rename from Resources/test/Fixtures/App/config/parameters.yml rename to src/Bundle/ChillEvent/Resources/test/Fixtures/App/config/parameters.yml diff --git a/Resources/test/Fixtures/App/config/parameters.yml.dist b/src/Bundle/ChillEvent/Resources/test/Fixtures/App/config/parameters.yml.dist similarity index 100% rename from Resources/test/Fixtures/App/config/parameters.yml.dist rename to src/Bundle/ChillEvent/Resources/test/Fixtures/App/config/parameters.yml.dist diff --git a/Resources/test/Fixtures/App/config/routing.yml b/src/Bundle/ChillEvent/Resources/test/Fixtures/App/config/routing.yml similarity index 100% rename from Resources/test/Fixtures/App/config/routing.yml rename to src/Bundle/ChillEvent/Resources/test/Fixtures/App/config/routing.yml diff --git a/Resources/test/Fixtures/App/console b/src/Bundle/ChillEvent/Resources/test/Fixtures/App/console similarity index 100% rename from Resources/test/Fixtures/App/console rename to src/Bundle/ChillEvent/Resources/test/Fixtures/App/console diff --git a/Resources/test/bootstrap.php b/src/Bundle/ChillEvent/Resources/test/bootstrap.php similarity index 100% rename from Resources/test/bootstrap.php rename to src/Bundle/ChillEvent/Resources/test/bootstrap.php diff --git a/Resources/views/Admin/layout.html.twig b/src/Bundle/ChillEvent/Resources/views/Admin/layout.html.twig similarity index 100% rename from Resources/views/Admin/layout.html.twig rename to src/Bundle/ChillEvent/Resources/views/Admin/layout.html.twig diff --git a/Resources/views/Admin/menu.html.twig b/src/Bundle/ChillEvent/Resources/views/Admin/menu.html.twig similarity index 100% rename from Resources/views/Admin/menu.html.twig rename to src/Bundle/ChillEvent/Resources/views/Admin/menu.html.twig diff --git a/Resources/views/Event/confirm_delete.html.twig b/src/Bundle/ChillEvent/Resources/views/Event/confirm_delete.html.twig similarity index 100% rename from Resources/views/Event/confirm_delete.html.twig rename to src/Bundle/ChillEvent/Resources/views/Event/confirm_delete.html.twig diff --git a/Resources/views/Event/edit.html.twig b/src/Bundle/ChillEvent/Resources/views/Event/edit.html.twig similarity index 100% rename from Resources/views/Event/edit.html.twig rename to src/Bundle/ChillEvent/Resources/views/Event/edit.html.twig diff --git a/Resources/views/Event/index.html.twig b/src/Bundle/ChillEvent/Resources/views/Event/index.html.twig similarity index 100% rename from Resources/views/Event/index.html.twig rename to src/Bundle/ChillEvent/Resources/views/Event/index.html.twig diff --git a/Resources/views/Event/list.html.twig b/src/Bundle/ChillEvent/Resources/views/Event/list.html.twig similarity index 100% rename from Resources/views/Event/list.html.twig rename to src/Bundle/ChillEvent/Resources/views/Event/list.html.twig diff --git a/Resources/views/Event/listByPerson.html.twig b/src/Bundle/ChillEvent/Resources/views/Event/listByPerson.html.twig similarity index 100% rename from Resources/views/Event/listByPerson.html.twig rename to src/Bundle/ChillEvent/Resources/views/Event/listByPerson.html.twig diff --git a/Resources/views/Event/new.html.twig b/src/Bundle/ChillEvent/Resources/views/Event/new.html.twig similarity index 100% rename from Resources/views/Event/new.html.twig rename to src/Bundle/ChillEvent/Resources/views/Event/new.html.twig diff --git a/Resources/views/Event/newPickCenter.html.twig b/src/Bundle/ChillEvent/Resources/views/Event/newPickCenter.html.twig similarity index 100% rename from Resources/views/Event/newPickCenter.html.twig rename to src/Bundle/ChillEvent/Resources/views/Event/newPickCenter.html.twig diff --git a/Resources/views/Event/show.html.twig b/src/Bundle/ChillEvent/Resources/views/Event/show.html.twig similarity index 100% rename from Resources/views/Event/show.html.twig rename to src/Bundle/ChillEvent/Resources/views/Event/show.html.twig diff --git a/Resources/views/EventReason/macro.html.twig b/src/Bundle/ChillEvent/Resources/views/EventReason/macro.html.twig similarity index 100% rename from Resources/views/EventReason/macro.html.twig rename to src/Bundle/ChillEvent/Resources/views/EventReason/macro.html.twig diff --git a/Resources/views/EventType/edit.html.twig b/src/Bundle/ChillEvent/Resources/views/EventType/edit.html.twig similarity index 100% rename from Resources/views/EventType/edit.html.twig rename to src/Bundle/ChillEvent/Resources/views/EventType/edit.html.twig diff --git a/Resources/views/EventType/index.html.twig b/src/Bundle/ChillEvent/Resources/views/EventType/index.html.twig similarity index 100% rename from Resources/views/EventType/index.html.twig rename to src/Bundle/ChillEvent/Resources/views/EventType/index.html.twig diff --git a/Resources/views/EventType/new.html.twig b/src/Bundle/ChillEvent/Resources/views/EventType/new.html.twig similarity index 100% rename from Resources/views/EventType/new.html.twig rename to src/Bundle/ChillEvent/Resources/views/EventType/new.html.twig diff --git a/Resources/views/EventType/show.html.twig b/src/Bundle/ChillEvent/Resources/views/EventType/show.html.twig similarity index 100% rename from Resources/views/EventType/show.html.twig rename to src/Bundle/ChillEvent/Resources/views/EventType/show.html.twig diff --git a/Resources/views/Participation/_ignored_participations.html.twig b/src/Bundle/ChillEvent/Resources/views/Participation/_ignored_participations.html.twig similarity index 100% rename from Resources/views/Participation/_ignored_participations.html.twig rename to src/Bundle/ChillEvent/Resources/views/Participation/_ignored_participations.html.twig diff --git a/Resources/views/Participation/confirm_delete.html.twig b/src/Bundle/ChillEvent/Resources/views/Participation/confirm_delete.html.twig similarity index 100% rename from Resources/views/Participation/confirm_delete.html.twig rename to src/Bundle/ChillEvent/Resources/views/Participation/confirm_delete.html.twig diff --git a/Resources/views/Participation/edit-multiple.html.twig b/src/Bundle/ChillEvent/Resources/views/Participation/edit-multiple.html.twig similarity index 100% rename from Resources/views/Participation/edit-multiple.html.twig rename to src/Bundle/ChillEvent/Resources/views/Participation/edit-multiple.html.twig diff --git a/Resources/views/Participation/edit.html.twig b/src/Bundle/ChillEvent/Resources/views/Participation/edit.html.twig similarity index 100% rename from Resources/views/Participation/edit.html.twig rename to src/Bundle/ChillEvent/Resources/views/Participation/edit.html.twig diff --git a/Resources/views/Participation/new-multiple.html.twig b/src/Bundle/ChillEvent/Resources/views/Participation/new-multiple.html.twig similarity index 100% rename from Resources/views/Participation/new-multiple.html.twig rename to src/Bundle/ChillEvent/Resources/views/Participation/new-multiple.html.twig diff --git a/Resources/views/Participation/new.html.twig b/src/Bundle/ChillEvent/Resources/views/Participation/new.html.twig similarity index 100% rename from Resources/views/Participation/new.html.twig rename to src/Bundle/ChillEvent/Resources/views/Participation/new.html.twig diff --git a/Resources/views/Role/edit.html.twig b/src/Bundle/ChillEvent/Resources/views/Role/edit.html.twig similarity index 100% rename from Resources/views/Role/edit.html.twig rename to src/Bundle/ChillEvent/Resources/views/Role/edit.html.twig diff --git a/Resources/views/Role/index.html.twig b/src/Bundle/ChillEvent/Resources/views/Role/index.html.twig similarity index 100% rename from Resources/views/Role/index.html.twig rename to src/Bundle/ChillEvent/Resources/views/Role/index.html.twig diff --git a/Resources/views/Role/new.html.twig b/src/Bundle/ChillEvent/Resources/views/Role/new.html.twig similarity index 100% rename from Resources/views/Role/new.html.twig rename to src/Bundle/ChillEvent/Resources/views/Role/new.html.twig diff --git a/Resources/views/Role/show.html.twig b/src/Bundle/ChillEvent/Resources/views/Role/show.html.twig similarity index 100% rename from Resources/views/Role/show.html.twig rename to src/Bundle/ChillEvent/Resources/views/Role/show.html.twig diff --git a/Resources/views/Status/edit.html.twig b/src/Bundle/ChillEvent/Resources/views/Status/edit.html.twig similarity index 100% rename from Resources/views/Status/edit.html.twig rename to src/Bundle/ChillEvent/Resources/views/Status/edit.html.twig diff --git a/Resources/views/Status/index.html.twig b/src/Bundle/ChillEvent/Resources/views/Status/index.html.twig similarity index 100% rename from Resources/views/Status/index.html.twig rename to src/Bundle/ChillEvent/Resources/views/Status/index.html.twig diff --git a/Resources/views/Status/new.html.twig b/src/Bundle/ChillEvent/Resources/views/Status/new.html.twig similarity index 100% rename from Resources/views/Status/new.html.twig rename to src/Bundle/ChillEvent/Resources/views/Status/new.html.twig diff --git a/Resources/views/Status/show.html.twig b/src/Bundle/ChillEvent/Resources/views/Status/show.html.twig similarity index 100% rename from Resources/views/Status/show.html.twig rename to src/Bundle/ChillEvent/Resources/views/Status/show.html.twig diff --git a/Resources/views/Timeline/event_person_context.html.twig b/src/Bundle/ChillEvent/Resources/views/Timeline/event_person_context.html.twig similarity index 100% rename from Resources/views/Timeline/event_person_context.html.twig rename to src/Bundle/ChillEvent/Resources/views/Timeline/event_person_context.html.twig diff --git a/Resources/views/layout.html.twig b/src/Bundle/ChillEvent/Resources/views/layout.html.twig similarity index 100% rename from Resources/views/layout.html.twig rename to src/Bundle/ChillEvent/Resources/views/layout.html.twig diff --git a/Search/EventSearch.php b/src/Bundle/ChillEvent/Search/EventSearch.php similarity index 100% rename from Search/EventSearch.php rename to src/Bundle/ChillEvent/Search/EventSearch.php diff --git a/Security/Authorization/EventVoter.php b/src/Bundle/ChillEvent/Security/Authorization/EventVoter.php similarity index 100% rename from Security/Authorization/EventVoter.php rename to src/Bundle/ChillEvent/Security/Authorization/EventVoter.php diff --git a/Security/Authorization/ParticipationVoter.php b/src/Bundle/ChillEvent/Security/Authorization/ParticipationVoter.php similarity index 100% rename from Security/Authorization/ParticipationVoter.php rename to src/Bundle/ChillEvent/Security/Authorization/ParticipationVoter.php diff --git a/Tests/Controller/EventControllerTest.php b/src/Bundle/ChillEvent/Tests/Controller/EventControllerTest.php similarity index 100% rename from Tests/Controller/EventControllerTest.php rename to src/Bundle/ChillEvent/Tests/Controller/EventControllerTest.php diff --git a/Tests/Controller/EventTypeControllerTest.php b/src/Bundle/ChillEvent/Tests/Controller/EventTypeControllerTest.php similarity index 100% rename from Tests/Controller/EventTypeControllerTest.php rename to src/Bundle/ChillEvent/Tests/Controller/EventTypeControllerTest.php diff --git a/Tests/Controller/ParticipationControllerTest.php b/src/Bundle/ChillEvent/Tests/Controller/ParticipationControllerTest.php similarity index 100% rename from Tests/Controller/ParticipationControllerTest.php rename to src/Bundle/ChillEvent/Tests/Controller/ParticipationControllerTest.php diff --git a/Tests/Controller/RoleControllerTest.php b/src/Bundle/ChillEvent/Tests/Controller/RoleControllerTest.php similarity index 100% rename from Tests/Controller/RoleControllerTest.php rename to src/Bundle/ChillEvent/Tests/Controller/RoleControllerTest.php diff --git a/Tests/Controller/StatusControllerTest.php b/src/Bundle/ChillEvent/Tests/Controller/StatusControllerTest.php similarity index 100% rename from Tests/Controller/StatusControllerTest.php rename to src/Bundle/ChillEvent/Tests/Controller/StatusControllerTest.php diff --git a/Tests/Search/EventSearchTest.php b/src/Bundle/ChillEvent/Tests/Search/EventSearchTest.php similarity index 100% rename from Tests/Search/EventSearchTest.php rename to src/Bundle/ChillEvent/Tests/Search/EventSearchTest.php diff --git a/Timeline/TimelineEventProvider.php b/src/Bundle/ChillEvent/Timeline/TimelineEventProvider.php similarity index 100% rename from Timeline/TimelineEventProvider.php rename to src/Bundle/ChillEvent/Timeline/TimelineEventProvider.php diff --git a/apigen.neon b/src/Bundle/ChillEvent/apigen.neon similarity index 100% rename from apigen.neon rename to src/Bundle/ChillEvent/apigen.neon diff --git a/chill.webpack.config.js b/src/Bundle/ChillEvent/chill.webpack.config.js similarity index 100% rename from chill.webpack.config.js rename to src/Bundle/ChillEvent/chill.webpack.config.js diff --git a/composer.json b/src/Bundle/ChillEvent/composer.json similarity index 100% rename from composer.json rename to src/Bundle/ChillEvent/composer.json diff --git a/config/routes.yaml b/src/Bundle/ChillEvent/config/routes.yaml similarity index 100% rename from config/routes.yaml rename to src/Bundle/ChillEvent/config/routes.yaml diff --git a/config/routes/event.yaml b/src/Bundle/ChillEvent/config/routes/event.yaml similarity index 100% rename from config/routes/event.yaml rename to src/Bundle/ChillEvent/config/routes/event.yaml diff --git a/config/routes/eventtype.yaml b/src/Bundle/ChillEvent/config/routes/eventtype.yaml similarity index 100% rename from config/routes/eventtype.yaml rename to src/Bundle/ChillEvent/config/routes/eventtype.yaml diff --git a/config/routes/participation.yaml b/src/Bundle/ChillEvent/config/routes/participation.yaml similarity index 100% rename from config/routes/participation.yaml rename to src/Bundle/ChillEvent/config/routes/participation.yaml diff --git a/config/routes/role.yaml b/src/Bundle/ChillEvent/config/routes/role.yaml similarity index 100% rename from config/routes/role.yaml rename to src/Bundle/ChillEvent/config/routes/role.yaml diff --git a/config/routes/status.yaml b/src/Bundle/ChillEvent/config/routes/status.yaml similarity index 100% rename from config/routes/status.yaml rename to src/Bundle/ChillEvent/config/routes/status.yaml diff --git a/config/services.yaml b/src/Bundle/ChillEvent/config/services.yaml similarity index 100% rename from config/services.yaml rename to src/Bundle/ChillEvent/config/services.yaml diff --git a/config/services/authorization.yaml b/src/Bundle/ChillEvent/config/services/authorization.yaml similarity index 100% rename from config/services/authorization.yaml rename to src/Bundle/ChillEvent/config/services/authorization.yaml diff --git a/config/services/controller.yaml b/src/Bundle/ChillEvent/config/services/controller.yaml similarity index 100% rename from config/services/controller.yaml rename to src/Bundle/ChillEvent/config/services/controller.yaml diff --git a/config/services/fixtures.yaml b/src/Bundle/ChillEvent/config/services/fixtures.yaml similarity index 100% rename from config/services/fixtures.yaml rename to src/Bundle/ChillEvent/config/services/fixtures.yaml diff --git a/config/services/forms.yaml b/src/Bundle/ChillEvent/config/services/forms.yaml similarity index 100% rename from config/services/forms.yaml rename to src/Bundle/ChillEvent/config/services/forms.yaml diff --git a/config/services/menu.yaml b/src/Bundle/ChillEvent/config/services/menu.yaml similarity index 100% rename from config/services/menu.yaml rename to src/Bundle/ChillEvent/config/services/menu.yaml diff --git a/config/services/repositories.yaml b/src/Bundle/ChillEvent/config/services/repositories.yaml similarity index 100% rename from config/services/repositories.yaml rename to src/Bundle/ChillEvent/config/services/repositories.yaml diff --git a/config/services/search.yaml b/src/Bundle/ChillEvent/config/services/search.yaml similarity index 100% rename from config/services/search.yaml rename to src/Bundle/ChillEvent/config/services/search.yaml diff --git a/config/services/timeline.yaml b/src/Bundle/ChillEvent/config/services/timeline.yaml similarity index 100% rename from config/services/timeline.yaml rename to src/Bundle/ChillEvent/config/services/timeline.yaml diff --git a/config/validation.yaml b/src/Bundle/ChillEvent/config/validation.yaml similarity index 100% rename from config/validation.yaml rename to src/Bundle/ChillEvent/config/validation.yaml diff --git a/migrations/Version20160318111334.php b/src/Bundle/ChillEvent/migrations/Version20160318111334.php similarity index 100% rename from migrations/Version20160318111334.php rename to src/Bundle/ChillEvent/migrations/Version20160318111334.php diff --git a/migrations/Version20190110140538.php b/src/Bundle/ChillEvent/migrations/Version20190110140538.php similarity index 100% rename from migrations/Version20190110140538.php rename to src/Bundle/ChillEvent/migrations/Version20190110140538.php diff --git a/migrations/Version20190115140042.php b/src/Bundle/ChillEvent/migrations/Version20190115140042.php similarity index 100% rename from migrations/Version20190115140042.php rename to src/Bundle/ChillEvent/migrations/Version20190115140042.php diff --git a/migrations/Version20190201143121.php b/src/Bundle/ChillEvent/migrations/Version20190201143121.php similarity index 100% rename from migrations/Version20190201143121.php rename to src/Bundle/ChillEvent/migrations/Version20190201143121.php diff --git a/phpunit.xml.dist b/src/Bundle/ChillEvent/phpunit.xml.dist similarity index 100% rename from phpunit.xml.dist rename to src/Bundle/ChillEvent/phpunit.xml.dist diff --git a/translations/messages.fr.yml b/src/Bundle/ChillEvent/translations/messages.fr.yml similarity index 100% rename from translations/messages.fr.yml rename to src/Bundle/ChillEvent/translations/messages.fr.yml