diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..0340427 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,6 @@ +[report] +include = + src/bika/* +omit = + */test* + */upgrades/* diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a83363b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +[*] +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +[{*.py,*.cfg}] +indent_size = 4 + +[{*.html,*.dtml,*.pt,*.zpt,*.xml,*.zcml,*.js}] +indent_size = 2 + +[Makefile] +indent_style = tab diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..af46901 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +CHANGES.rst merge=union \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..447e6e4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,16 @@ +* bika.aquaculture version: +* Plone Version: +* Python version: +* Operating System: Linux + +### Description + +Describe what you were trying to get done. +Tell us what happened, what went wrong, and what you expected to happen. + +### What I Did + +``` +Paste the command(s) you ran and the output. +If there was a crash, please include the traceback here. +``` diff --git a/.github/workflows/plone-package.yml b/.github/workflows/plone-package.yml new file mode 100644 index 0000000..bcbb03e --- /dev/null +++ b/.github/workflows/plone-package.yml @@ -0,0 +1,50 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Plone package + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: [3.7, 3.8, 3.9, 2.7] + + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: | + ~/.cache/pip + ~/buildout-cache + ~/extends + key: ${{ runner.os }}-tox-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/tox.ini') }} + restore-keys: | + ${{ runner.os }}-tox- + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install system libraries + run: sudo apt-get install libxml2-dev libxslt1-dev libjpeg-dev + - name: setup buildout cache + run: | + mkdir -p ~/buildout-cache/{eggs,downloads} + mkdir ~/.buildout + echo "[buildout]" > $HOME/.buildout/default.cfg + echo "download-cache = $HOME/buildout-cache/downloads" >> $HOME/.buildout/default.cfg + echo "eggs-directory = $HOME/buildout-cache/eggs" >> $HOME/.buildout/default.cfg + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox tox-gh-actions + - name: Test with tox + run: | + tox -r diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1567ab --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +.coverage +*.egg-info +*.log +*.mo +*.py? +*.swp +# dirs +bin/ +buildout-cache/ +develop-eggs/ +eggs/ +htmlcov/ +include/ +lib/ +local/ +node_modules/ +parts/ +dist/* +test.plone_addon/ +var/ +# files +.installed.cfg +.mr.developer.cfg +lib64 +log.html +output.xml +pip-selfcheck.json +report.html +.vscode/ +.tox/ +reports/ +venv/ +# excludes diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..1190cc4 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,70 @@ +# This file is a template, and might need editing before it works on your project. +# Official language image. Look for the different tagged releases at: +# https://hub.docker.com/r/library/plone/tags/ +image: python:2.7-stretch + +# Change pip's cache directory to be inside the project directory since we can +# only cache local items. +variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache" + +# Pip's cache doesn't store the python packages +# https://pip.pypa.io/en/stable/reference/pip_install/#caching +# +# If you want to also cache the installed packages, you have to install +# them in a virtualenv and cache it as well. +cache: + paths: + - .cache/pip + - venv/ + - downloads/ + - eggs/ + +# Set execution order: first run jobs on 'test' stage on parallel +# then run jobs on 'report' stage +stages: + - test + - report + +before_script: + - echo "deb http://ftp.de.debian.org/debian/ stretch main contrib non-free" >> /etc/apt/sources.list + - apt-get update + - apt-get install -y firefoxdriver + - apt-get install -y xvfb + - python -V # Print out python version for debugging + - pip install virtualenv + - export LC_CTYPE=en_US.UTF-8 + - export LC_ALL=en_US.UTF-8 + - export LANG=en_US.UTF-8 + - virtualenv --clear -p python2.7 venv + - source venv/bin/activate + - pip install -r requirements.txt + - buildout bootstrap + - bin/buildout -n -c buildout.cfg code-analysis:return-status-codes=True + +code-analysis: + stage: test + # still not available, see: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5004 + # success_with_warnings: True + script: + - bin/code-analysis + +robot: + stage: test + script: + - export DISPLAY=:99.0 + # - sh -e /etc/init.d/xvfb start + - xvfb-run bin/test --all + +coverage: + stage: report + script: + - bin/createcoverage + - bin/coverage html + - bin/coverage report + when: on_success + + coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+\%)/' + artifacts: + paths: + - htmlcov diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0bb2ac1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,61 @@ +dist: bionic +language: python +cache: + pip: true + directories: + - eggs + - $HOME/buildout-cache + - $HOME/.buildout +python: + - "2.7" +matrix: + include: + - python: "2.7" + env: PLONE_VERSION=43 + - python: "2.7" + env: PLONE_VERSION=51 + - python: "2.7" + env: PLONE_VERSION=52 + - python: "3.7" + env: PLONE_VERSION=52 + fast_finish: true + +before_install: + - mkdir -p $HOME/buildout-cache/{downloads,eggs,extends} + - mkdir -p $HOME/.buildout + - echo "[buildout]" > $HOME/.buildout/default.cfg + - echo "download-cache = $HOME/buildout-cache/downloads" >> $HOME/.buildout/default.cfg + - echo "eggs-directory = $HOME/buildout-cache/eggs" >> $HOME/.buildout/default.cfg + - echo "extends-cache = $HOME/buildout-cache/extends" >> $HOME/.buildout/default.cfg + - echo "abi-tag-eggs = true" >> $HOME/.buildout/default.cfg + - git config --global user.email "travis@travis-ci.org" + - git config --global user.name "Travis CI" + - sudo apt-get install -y firefox-geckodriver + - virtualenv -p `which python` . + - bin/pip install -r requirements.txt -c constraints_plone$PLONE_VERSION.txt + - cp test_plone$PLONE_VERSION.cfg buildout.cfg + +install: + - travis_retry pip install -U tox coveralls coverage -c constraints.txt + +before_script: + - 'export DISPLAY=:99.0' + - export VERBOSE=true + - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & + - sleep 3 + +script: + - PYTEST_ADDOPTS="-s -vv" tox + +after_success: + - python -m coverage.pickle2json + - coverage combine + - coveralls + +notifications: + email: + recipients: +# - travis-reports@plone.com + - {author} + on_success: change + on_failure: change diff --git a/CHANGES.rst b/CHANGES.rst new file mode 100644 index 0000000..7197bad --- /dev/null +++ b/CHANGES.rst @@ -0,0 +1,9 @@ +Changelog +========= + + +1.0a1 (unreleased) +------------------ + +- Initial release. + [lunga001] diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst new file mode 100644 index 0000000..99dfb50 --- /dev/null +++ b/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +Contributors +============ + +- Lunga Baliwe, lunga001@gmail.com diff --git a/DEVELOP.rst b/DEVELOP.rst new file mode 100644 index 0000000..cd8979a --- /dev/null +++ b/DEVELOP.rst @@ -0,0 +1,42 @@ +Using the development buildout +============================== + +Create a virtualenv in the package:: + + $ virtualenv --clear . + +Install requirements with pip:: + + $ ./bin/pip install -r requirements.txt + +Run buildout:: + + $ ./bin/buildout + +Start Plone in foreground: + + $ ./bin/instance fg + + +Running tests +------------- + + $ tox + +list all tox environments: + + $ tox -l + py27-Plone43 + py27-Plone51 + py27-Plone52 + py37-Plone52 + build_instance + code-analysis + lint-py27 + lint-py37 + coverage-report + +run a specific tox env: + + $ tox -e py37-Plone52 + diff --git a/LICENSE.GPL b/LICENSE.GPL new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE.GPL @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + 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 +this service 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. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +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 +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE 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. + + 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 +convey 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 General Public License as published by + the Free Software Foundation; either version 2 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/LICENSE.rst b/LICENSE.rst new file mode 100644 index 0000000..0a51afb --- /dev/null +++ b/LICENSE.rst @@ -0,0 +1,15 @@ +bika.aquaculture Copyright 2023, Lunga Baliwe + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, +MA 02111-1307 USA. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..9c4e1d3 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +graft src/bika +graft docs +include *.rst +global-exclude *.pyc diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..93f0ff0 --- /dev/null +++ b/README.rst @@ -0,0 +1,94 @@ +.. This README is meant for consumption by humans and pypi. Pypi can render rst files so please do not use Sphinx features. + If you want to learn more about writing documentation, please check out: http://docs.plone.org/about/documentation_styleguide.html + This text does not appear on pypi or github. It is a comment. + +.. image:: https://travis-ci.org/collective/bika.aquaculture.svg?branch=master + :target: https://travis-ci.org/collective/bika.aquaculture + +.. image:: https://coveralls.io/repos/github/collective/bika.aquaculture/badge.svg?branch=master + :target: https://coveralls.io/github/collective/bika.aquaculture?branch=master + :alt: Coveralls + +.. image:: https://img.shields.io/pypi/v/bika.aquaculture.svg + :target: https://pypi.python.org/pypi/bika.aquaculture/ + :alt: Latest Version + +.. image:: https://img.shields.io/pypi/status/bika.aquaculture.svg + :target: https://pypi.python.org/pypi/bika.aquaculture + :alt: Egg Status + +.. image:: https://img.shields.io/pypi/pyversions/bika.aquaculture.svg?style=plastic :alt: Supported - Python Versions + +.. image:: https://img.shields.io/pypi/l/bika.aquaculture.svg + :target: https://pypi.python.org/pypi/bika.aquaculture/ + :alt: License + + +================ +bika.aquaculture +================ + +Tell me what your product does + +Features +-------- + +- Can be bullet points + + +Examples +-------- + +This add-on can be seen in action at the following sites: +- Is there a page on the internet where everybody can see the features? + + +Documentation +------------- + +Full documentation for end users can be found in the "docs" folder, and is also available online at http://docs.plone.org/foo/bar + + +Translations +------------ + +This product has been translated into + +- Klingon (thanks, K'Plai) + + +Installation +------------ + +Install bika.aquaculture by adding it to your buildout:: + + [buildout] + + ... + + eggs = + bika.aquaculture + + +and then running ``bin/buildout`` + + +Contribute +---------- + +- Issue Tracker: https://github.com/collective/bika.aquaculture/issues +- Source Code: https://github.com/collective/bika.aquaculture +- Documentation: https://docs.plone.org/foo/bar + + +Support +------- + +If you are having issues, please let us know. +We have a mailing list located at: project@example.com + + +License +------- + +The project is licensed under the GPLv2. diff --git a/base.cfg b/base.cfg new file mode 100644 index 0000000..f5502f0 --- /dev/null +++ b/base.cfg @@ -0,0 +1,111 @@ +[buildout] +show-picked-versions = true +extensions = + mr.developer + +parts = + instance + test +# we use tox for testing and linting, by default +# code-analysis + coverage + test-coverage + createcoverage + releaser + i18ndude + omelette + robot + plone-helper-scripts +# vscode + +develop = . + + +[instance] +recipe = plone.recipe.zope2instance +user = admin:admin +http-address = 8080 +environment-vars = + zope_i18n_compile_mo_files true +eggs = + Plone + Pillow + bika.aquaculture [test] + +[vscode] +recipe = collective.recipe.vscode +eggs = ${instance:eggs} +autocomplete-use-omelette = True + +# [code-analysis] +# recipe = plone.recipe.codeanalysis +# directory = ${buildout:directory}/src/bika +# return-status-codes = False + + +[omelette] +recipe = collective.recipe.omelette +eggs = ${instance:eggs} + + +[test] +recipe = zc.recipe.testrunner +eggs = ${instance:eggs} +initialization = + os.environ['TZ'] = 'UTC' +defaults = ['-s', 'bika.aquaculture', '--auto-color', '--auto-progress'] + + +[coverage] +recipe = zc.recipe.egg +eggs = coverage + + +[test-coverage] +recipe = collective.recipe.template +input = inline: + #!/bin/bash + export TZ=UTC + ${buildout:directory}/bin/coverage run bin/test $* + ${buildout:directory}/bin/coverage html + ${buildout:directory}/bin/coverage report -m --fail-under=90 + # Fail (exit status 1) if coverage returns exit status 2 (this happens + # when test coverage is below 100%. +output = ${buildout:directory}/bin/test-coverage +mode = 755 + + +[createcoverage] +recipe = zc.recipe.egg +eggs = createcoverage + + +[robot] +recipe = zc.recipe.egg +eggs = + ${test:eggs} + plone.app.robotframework[debug,reload] + + +[releaser] +recipe = zc.recipe.egg +eggs = zest.releaser + + +[i18ndude] +recipe = zc.recipe.egg +eggs = i18ndude + +[plone-helper-scripts] +recipe = zc.recipe.egg +eggs = + Products.CMFPlone + ${instance:eggs} +interpreter = zopepy +scripts = + zopepy + plone-compile-resources + +[versions] +# Don't use a released version of bika.aquaculture +bika.aquaculture = diff --git a/bobtemplate.cfg b/bobtemplate.cfg new file mode 100644 index 0000000..e5fa276 --- /dev/null +++ b/bobtemplate.cfg @@ -0,0 +1,5 @@ +[main] +version = 5.2.13 +template = plone_addon +git_init = True +python = python3 diff --git a/buildout.cfg b/buildout.cfg new file mode 100644 index 0000000..80d7a7f --- /dev/null +++ b/buildout.cfg @@ -0,0 +1,9 @@ +[buildout] + +# use this extend one of the buildout configuration: +extends = +# -*- mrbob: extra extends -*- +# test_plone43.cfg +# test_plone50.cfg +# test_plone51.cfg + test_plone52.cfg diff --git a/constraints.txt b/constraints.txt new file mode 100644 index 0000000..24cbf87 --- /dev/null +++ b/constraints.txt @@ -0,0 +1 @@ +-c constraints_plone52.txt diff --git a/constraints_plone43.txt b/constraints_plone43.txt new file mode 100644 index 0000000..f3a36b2 --- /dev/null +++ b/constraints_plone43.txt @@ -0,0 +1,2 @@ +setuptools==27.3.0 +zc.buildout==2.5.3 diff --git a/constraints_plone51.txt b/constraints_plone51.txt new file mode 100644 index 0000000..8dcbff1 --- /dev/null +++ b/constraints_plone51.txt @@ -0,0 +1,3 @@ +-c https://dist.plone.org/release/5.1-latest/requirements.txt +# setuptools==39.1.0 +# zc.buildout==2.11.4 diff --git a/constraints_plone52.txt b/constraints_plone52.txt new file mode 100644 index 0000000..3dd8048 --- /dev/null +++ b/constraints_plone52.txt @@ -0,0 +1,3 @@ +-c https://dist.plone.org/release/5.2-latest/requirements.txt +# setuptools==40.2.0 +# zc.buildout==2.13.2 diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..7c50d9f --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,239 @@ +# -*- coding: utf-8 -*- +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'bika.aquaculture' +copyright = u'Lunga Baliwe (lunga001)' +author = u'Lunga Baliwe (lunga001)' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = u'3.0' +# The full version, including alpha/beta/rc tags. +release = u'3.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. +# " v documentation" by default. +#html_title = u'bobtemplates.plone v3.0' + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (relative to this directory) to use as a favicon of +# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not None, a 'Last updated on:' timestamp is inserted at every page +# bottom, using the given strftime format. +# The empty string is equivalent to '%b %d, %Y'. +#html_last_updated_fmt = None + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' +#html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# 'ja' uses this config value. +# 'zh' user can custom change `jieba` dictionary path. +#html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +#html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'bika.aquaculturedoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', + +# Latex figure (float) alignment +#'figure_align': 'htbp', +} + + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..4c341fb --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,5 @@ +================ +bika.aquaculture +================ + +User documentation diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..06390bd --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +-c constraints.txt +setuptools +zc.buildout diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..5029d67 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,35 @@ +[check-manifest] +ignore = + *.cfg + .coveragerc + .editorconfig + .gitattributes + +[isort] +# black compatible isort rules: +force_alphabetical_sort = True +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +use_parentheses = True +lines_after_imports = 2 +line_length = 88 +not_skip = + __init__.py +skip = + +[flake8] +# black compatible flake8 rules: +ignore = + W503, + C812, + E501 + T001 + C813 +# E203, E266 +exclude = bootstrap.py,docs,*.egg.,omelette +max-line-length = 88 +max-complexity = 18 +select = B,C,E,F,W,T4,B9 + +builtins = unicode,basestring diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f61b17c --- /dev/null +++ b/setup.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +"""Installer for the bika.aquaculture package.""" + +from setuptools import find_packages +from setuptools import setup + + +long_description = '\n\n'.join([ + open('README.rst').read(), + open('CONTRIBUTORS.rst').read(), + open('CHANGES.rst').read(), +]) + + +setup( + name='bika.aquaculture', + version='1.0a1', + description="An add-on for Plone", + long_description=long_description, + # Get more from https://pypi.org/classifiers/ + classifiers=[ + "Environment :: Web Environment", + "Framework :: Plone", + "Framework :: Plone :: Addon", + "Framework :: Plone :: 5.2", + "Programming Language :: Python", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3.7", + "Operating System :: OS Independent", + "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", + ], + keywords='Python Plone CMS', + author='Lunga Baliwe', + author_email='lunga001@gmail.com', + url='https://github.com/collective/bika.aquaculture', + project_urls={ + 'PyPI': 'https://pypi.python.org/pypi/bika.aquaculture', + 'Source': 'https://github.com/collective/bika.aquaculture', + 'Tracker': 'https://github.com/collective/bika.aquaculture/issues', + # 'Documentation': 'https://bika.aquaculture.readthedocs.io/en/latest/', + }, + license='GPL version 2', + packages=find_packages('src', exclude=['ez_setup']), + namespace_packages=['bika'], + package_dir={'': 'src'}, + include_package_data=True, + zip_safe=False, + python_requires="==2.7, >=3.6", + install_requires=[ + 'setuptools', + # -*- Extra requirements: -*- + 'z3c.jbot', + 'plone.api>=1.8.4', + 'plone.restapi < 8.0.0', + 'plone.app.dexterity', + ], + extras_require={ + 'test': [ + 'plone.app.testing', + # Plone KGS does not use this version, because it would break + # Remove if your package shall be part of coredev. + # plone_coredev tests as of 2016-04-01. + 'plone.testing>=5.0.0', + 'plone.app.contenttypes', + 'plone.app.robotframework[debug]', + ], + }, + entry_points=""" + [z3c.autoinclude.plugin] + target = plone + [console_scripts] + update_locale = bika.aquaculture.locales.update:update_locale + """, +) diff --git a/src/bika/__init__.py b/src/bika/__init__.py new file mode 100644 index 0000000..03d08ff --- /dev/null +++ b/src/bika/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +__import__("pkg_resources").declare_namespace(__name__) diff --git a/src/bika/aquaculture/__init__.py b/src/bika/aquaculture/__init__.py new file mode 100644 index 0000000..2f192c8 --- /dev/null +++ b/src/bika/aquaculture/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +"""Init and utils.""" +from zope.i18nmessageid import MessageFactory + + +_ = MessageFactory('bika.aquaculture') diff --git a/src/bika/aquaculture/browser/__init__.py b/src/bika/aquaculture/browser/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bika/aquaculture/browser/configure.zcml b/src/bika/aquaculture/browser/configure.zcml new file mode 100644 index 0000000..6f34065 --- /dev/null +++ b/src/bika/aquaculture/browser/configure.zcml @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/src/bika/aquaculture/browser/overrides/.gitkeep b/src/bika/aquaculture/browser/overrides/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/bika/aquaculture/browser/static/.gitkeep b/src/bika/aquaculture/browser/static/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/bika/aquaculture/configure.zcml b/src/bika/aquaculture/configure.zcml new file mode 100644 index 0000000..4a7c82f --- /dev/null +++ b/src/bika/aquaculture/configure.zcml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/bika/aquaculture/interfaces.py b/src/bika/aquaculture/interfaces.py new file mode 100644 index 0000000..6810687 --- /dev/null +++ b/src/bika/aquaculture/interfaces.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +"""Module where all interfaces, events and exceptions live.""" + +from zope.publisher.interfaces.browser import IDefaultBrowserLayer + + +class IBikaAquacultureLayer(IDefaultBrowserLayer): + """Marker interface that defines a browser layer.""" diff --git a/src/bika/aquaculture/locales/README.rst b/src/bika/aquaculture/locales/README.rst new file mode 100644 index 0000000..c0b3cdf --- /dev/null +++ b/src/bika/aquaculture/locales/README.rst @@ -0,0 +1,37 @@ +Adding and updating locales +--------------------------- + +For every language you want to translate into you need a +locales/[language]/LC_MESSAGES/collective.task.po +(e.g. locales/de/LC_MESSAGES/collective.task.po) + +For German + +.. code-block:: console + + $ mkdir de + +For updating locales + +.. code-block:: console + + $ ./bin/update_locale + +Note +---- + +The script uses gettext package for internationalization. + +Install it before running the script. + +On macOS +-------- + +.. code-block:: console + + $ brew install gettext + +On Windows +---------- + +see https://mlocati.github.io/articles/gettext-iconv-windows.html diff --git a/src/bika/aquaculture/locales/__init__.py b/src/bika/aquaculture/locales/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bika/aquaculture/locales/bika.aquaculture.pot b/src/bika/aquaculture/locales/bika.aquaculture.pot new file mode 100644 index 0000000..e69de29 diff --git a/src/bika/aquaculture/locales/en/LC_MESSAGES/bika.aquaculture.po b/src/bika/aquaculture/locales/en/LC_MESSAGES/bika.aquaculture.po new file mode 100644 index 0000000..e69de29 diff --git a/src/bika/aquaculture/locales/update.py b/src/bika/aquaculture/locales/update.py new file mode 100644 index 0000000..5977cfb --- /dev/null +++ b/src/bika/aquaculture/locales/update.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- + +import os +import pkg_resources +import subprocess + + +domain = 'bika.aquaculture' +os.chdir(pkg_resources.resource_filename(domain, '')) +os.chdir('../../../') +target_path = 'src/bika/aquaculture/' +locale_path = target_path + 'locales/' +i18ndude = './bin/i18ndude' + +# ignore node_modules files resulting in errors +excludes = '"*.html *json-schema*.xml"' + + +def locale_folder_setup(): + os.chdir(locale_path) + languages = [d for d in os.listdir('.') if os.path.isdir(d)] + for lang in languages: + folder = os.listdir(lang) + if 'LC_MESSAGES' in folder: + continue + else: + lc_messages_path = lang + '/LC_MESSAGES/' + os.mkdir(lc_messages_path) + cmd = 'msginit --locale={0} --input={1}.pot --output={2}/LC_MESSAGES/{3}.po'.format( # NOQA: E501 + lang, + domain, + lang, + domain, + ) + subprocess.call( + cmd, + shell=True, + ) + + os.chdir('../../../../') + + +def _rebuild(): + cmd = '{i18ndude} rebuild-pot --pot {locale_path}/{domain}.pot --exclude {excludes} --create {domain} {target_path}'.format( # NOQA: E501 + i18ndude=i18ndude, + locale_path=locale_path, + domain=domain, + target_path=target_path, + excludes=excludes, + ) + subprocess.call( + cmd, + shell=True, + ) + + +def _sync(): + cmd = '{0} sync --pot {1}/{2}.pot {3}*/LC_MESSAGES/{4}.po'.format( + i18ndude, + locale_path, + domain, + locale_path, + domain, + ) + subprocess.call( + cmd, + shell=True, + ) + + +def update_locale(): + locale_folder_setup() + _sync() + _rebuild() diff --git a/src/bika/aquaculture/locales/update.sh b/src/bika/aquaculture/locales/update.sh new file mode 100755 index 0000000..c9a541f --- /dev/null +++ b/src/bika/aquaculture/locales/update.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# i18ndude should be available in current $PATH (eg by running +# ``export PATH=$PATH:$BUILDOUT_DIR/bin`` when i18ndude is located in your buildout's bin directory) +# +# For every language you want to translate into you need a +# locales/[language]/LC_MESSAGES/bika.aquaculture.po +# (e.g. locales/de/LC_MESSAGES/bika.aquaculture.po) + +domain=bika.aquaculture + +i18ndude rebuild-pot --pot $domain.pot --create $domain ../ +i18ndude sync --pot $domain.pot */LC_MESSAGES/$domain.po diff --git a/src/bika/aquaculture/permissions.zcml b/src/bika/aquaculture/permissions.zcml new file mode 100644 index 0000000..1f79c8a --- /dev/null +++ b/src/bika/aquaculture/permissions.zcml @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/src/bika/aquaculture/profiles/default/browserlayer.xml b/src/bika/aquaculture/profiles/default/browserlayer.xml new file mode 100644 index 0000000..0540866 --- /dev/null +++ b/src/bika/aquaculture/profiles/default/browserlayer.xml @@ -0,0 +1,7 @@ + + + + diff --git a/src/bika/aquaculture/profiles/default/catalog.xml b/src/bika/aquaculture/profiles/default/catalog.xml new file mode 100644 index 0000000..0685c9d --- /dev/null +++ b/src/bika/aquaculture/profiles/default/catalog.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/bika/aquaculture/profiles/default/metadata.xml b/src/bika/aquaculture/profiles/default/metadata.xml new file mode 100644 index 0000000..3fcf1da --- /dev/null +++ b/src/bika/aquaculture/profiles/default/metadata.xml @@ -0,0 +1,7 @@ + + + 1000 + + + + diff --git a/src/bika/aquaculture/profiles/default/registry/main.xml b/src/bika/aquaculture/profiles/default/registry/main.xml new file mode 100644 index 0000000..d291567 --- /dev/null +++ b/src/bika/aquaculture/profiles/default/registry/main.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/bika/aquaculture/profiles/default/rolemap.xml b/src/bika/aquaculture/profiles/default/rolemap.xml new file mode 100644 index 0000000..0a24e7e --- /dev/null +++ b/src/bika/aquaculture/profiles/default/rolemap.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/bika/aquaculture/profiles/uninstall/browserlayer.xml b/src/bika/aquaculture/profiles/uninstall/browserlayer.xml new file mode 100644 index 0000000..3e3d400 --- /dev/null +++ b/src/bika/aquaculture/profiles/uninstall/browserlayer.xml @@ -0,0 +1,7 @@ + + + + diff --git a/src/bika/aquaculture/setuphandlers.py b/src/bika/aquaculture/setuphandlers.py new file mode 100644 index 0000000..814ee96 --- /dev/null +++ b/src/bika/aquaculture/setuphandlers.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +from Products.CMFPlone.interfaces import INonInstallable +from zope.interface import implementer + + +@implementer(INonInstallable) +class HiddenProfiles(object): + + def getNonInstallableProfiles(self): + """Hide uninstall profile from site-creation and quickinstaller.""" + return [ + 'bika.aquaculture:uninstall', + ] + + +def post_install(context): + """Post install script""" + # Do something at the end of the installation of this package. + + +def uninstall(context): + """Uninstall script""" + # Do something at the end of the uninstallation of this package. diff --git a/src/bika/aquaculture/testing.py b/src/bika/aquaculture/testing.py new file mode 100644 index 0000000..f7c873c --- /dev/null +++ b/src/bika/aquaculture/testing.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE +from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE +from plone.app.testing import ( + applyProfile, + FunctionalTesting, + IntegrationTesting, + PloneSandboxLayer, +) +from plone.testing import z2 + +import bika.aquaculture + + +class BikaAquacultureLayer(PloneSandboxLayer): + + defaultBases = (PLONE_APP_CONTENTTYPES_FIXTURE,) + + def setUpZope(self, app, configurationContext): + # Load any other ZCML that is required for your tests. + # The z3c.autoinclude feature is disabled in the Plone fixture base + # layer. + import plone.restapi + self.loadZCML(package=plone.restapi) + self.loadZCML(package=bika.aquaculture) + + def setUpPloneSite(self, portal): + applyProfile(portal, 'bika.aquaculture:default') + + +BIKA_AQUACULTURE_FIXTURE = BikaAquacultureLayer() + + +BIKA_AQUACULTURE_INTEGRATION_TESTING = IntegrationTesting( + bases=(BIKA_AQUACULTURE_FIXTURE,), + name='BikaAquacultureLayer:IntegrationTesting', +) + + +BIKA_AQUACULTURE_FUNCTIONAL_TESTING = FunctionalTesting( + bases=(BIKA_AQUACULTURE_FIXTURE,), + name='BikaAquacultureLayer:FunctionalTesting', +) + + +BIKA_AQUACULTURE_ACCEPTANCE_TESTING = FunctionalTesting( + bases=( + BIKA_AQUACULTURE_FIXTURE, + REMOTE_LIBRARY_BUNDLE_FIXTURE, + z2.ZSERVER_FIXTURE, + ), + name='BikaAquacultureLayer:AcceptanceTesting', +) diff --git a/src/bika/aquaculture/tests/__init__.py b/src/bika/aquaculture/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bika/aquaculture/tests/robot/test_example.robot b/src/bika/aquaculture/tests/robot/test_example.robot new file mode 100644 index 0000000..9124fff --- /dev/null +++ b/src/bika/aquaculture/tests/robot/test_example.robot @@ -0,0 +1,66 @@ +# ============================================================================ +# EXAMPLE ROBOT TESTS +# ============================================================================ +# +# Run this robot test stand-alone: +# +# $ bin/test -s bika.aquaculture -t test_example.robot --all +# +# Run this robot test with robot server (which is faster): +# +# 1) Start robot server: +# +# $ bin/robot-server --reload-path src bika.aquaculture.testing.BIKA_AQUACULTURE_ACCEPTANCE_TESTING +# +# 2) Run robot tests: +# +# $ bin/robot src/bika/aquaculture/tests/robot/test_example.robot +# +# See the http://docs.plone.org for further details (search for robot +# framework). +# +# ============================================================================ + +*** Settings ***************************************************************** + +Resource plone/app/robotframework/selenium.robot +Resource plone/app/robotframework/keywords.robot + +Library Remote ${PLONE_URL}/RobotRemote + +Test Setup Open test browser +Test Teardown Close all browsers + + +*** Test Cases *************************************************************** + +Scenario: As a member I want to be able to log into the website + [Documentation] Example of a BDD-style (Behavior-driven development) test. + Given a login form + When I enter valid credentials + Then I am logged in + + +*** Keywords ***************************************************************** + +# --- Given ------------------------------------------------------------------ + +a login form + Go To ${PLONE_URL}/login_form + Wait until page contains Login Name + Wait until page contains Password + + +# --- WHEN ------------------------------------------------------------------- + +I enter valid credentials + Input Text __ac_name admin + Input Text __ac_password secret + Click Button Log in + + +# --- THEN ------------------------------------------------------------------- + +I am logged in + Wait until page contains You are now logged in + Page should contain You are now logged in diff --git a/src/bika/aquaculture/tests/test_robot.py b/src/bika/aquaculture/tests/test_robot.py new file mode 100644 index 0000000..94f1767 --- /dev/null +++ b/src/bika/aquaculture/tests/test_robot.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +from bika.aquaculture.testing import BIKA_AQUACULTURE_ACCEPTANCE_TESTING # noqa: E501 +from plone.app.testing import ROBOT_TEST_LEVEL +from plone.testing import layered + +import os +import robotsuite +import unittest + + +def test_suite(): + suite = unittest.TestSuite() + current_dir = os.path.abspath(os.path.dirname(__file__)) + robot_dir = os.path.join(current_dir, 'robot') + robot_tests = [ + os.path.join('robot', doc) for doc in os.listdir(robot_dir) + if doc.endswith('.robot') and doc.startswith('test_') + ] + for robot_test in robot_tests: + robottestsuite = robotsuite.RobotTestSuite(robot_test) + robottestsuite.level = ROBOT_TEST_LEVEL + suite.addTests([ + layered( + robottestsuite, + layer=BIKA_AQUACULTURE_ACCEPTANCE_TESTING, + ), + ]) + return suite diff --git a/src/bika/aquaculture/tests/test_setup.py b/src/bika/aquaculture/tests/test_setup.py new file mode 100644 index 0000000..096863e --- /dev/null +++ b/src/bika/aquaculture/tests/test_setup.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +"""Setup tests for this package.""" +from bika.aquaculture.testing import BIKA_AQUACULTURE_INTEGRATION_TESTING # noqa: E501 +from plone import api +from plone.app.testing import setRoles, TEST_USER_ID + +import unittest + + +try: + from Products.CMFPlone.utils import get_installer +except ImportError: + get_installer = None + + +class TestSetup(unittest.TestCase): + """Test that bika.aquaculture is properly installed.""" + + layer = BIKA_AQUACULTURE_INTEGRATION_TESTING + + def setUp(self): + """Custom shared utility setup for tests.""" + self.portal = self.layer['portal'] + if get_installer: + self.installer = get_installer(self.portal, self.layer['request']) + else: + self.installer = api.portal.get_tool('portal_quickinstaller') + + def test_product_installed(self): + """Test if bika.aquaculture is installed.""" + self.assertTrue(self.installer.isProductInstalled( + 'bika.aquaculture')) + + def test_browserlayer(self): + """Test that IBikaAquacultureLayer is registered.""" + from bika.aquaculture.interfaces import ( + IBikaAquacultureLayer) + from plone.browserlayer import utils + self.assertIn( + IBikaAquacultureLayer, + utils.registered_layers()) + + +class TestUninstall(unittest.TestCase): + + layer = BIKA_AQUACULTURE_INTEGRATION_TESTING + + def setUp(self): + self.portal = self.layer['portal'] + if get_installer: + self.installer = get_installer(self.portal, self.layer['request']) + else: + self.installer = api.portal.get_tool('portal_quickinstaller') + roles_before = api.user.get_roles(TEST_USER_ID) + setRoles(self.portal, TEST_USER_ID, ['Manager']) + self.installer.uninstallProducts(['bika.aquaculture']) + setRoles(self.portal, TEST_USER_ID, roles_before) + + def test_product_uninstalled(self): + """Test if bika.aquaculture is cleanly uninstalled.""" + self.assertFalse(self.installer.isProductInstalled( + 'bika.aquaculture')) + + def test_browserlayer_removed(self): + """Test that IBikaAquacultureLayer is removed.""" + from bika.aquaculture.interfaces import \ + IBikaAquacultureLayer + from plone.browserlayer import utils + self.assertNotIn( + IBikaAquacultureLayer, + utils.registered_layers()) diff --git a/test_plone43.cfg b/test_plone43.cfg new file mode 100644 index 0000000..256bc96 --- /dev/null +++ b/test_plone43.cfg @@ -0,0 +1,32 @@ +[buildout] + +extends = + https://raw.githubusercontent.com/collective/buildout.plonetest/master/test-4.3.x.cfg + https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg + base.cfg + +update-versions-file = test_plone43.cfg + +index = https://pypi.org/simple/ + +[versions] +zc.buildout = 2.5.3 +setuptools = 27.3.0 +# Pillow = 5.1.0 + +# manual pinnings +PyJWT = <2.0.0a1 +plone.app.referenceablebehavior = 0.7.7 +collective.recipe.vscode = >=0.1.6 +backports.functools_lru_cache = 1.5 +isort = 4.3.21 +# 2.1.1 is the last supported version for Plone 4.3, but plone.app.contenttypes 1.1.6 is requirering <2.1.0: +plone.app.dexterity = <2.1.0 +#docutils = 0.17.1 +plone.app.robotframework = 1.2.1 +configparser = 3.5.3 +plone.testing = 5.0.0 +jsonschema = 2.6.0 +### + + diff --git a/test_plone51.cfg b/test_plone51.cfg new file mode 100644 index 0000000..619424c --- /dev/null +++ b/test_plone51.cfg @@ -0,0 +1,14 @@ +[buildout] + +extends = + https://raw.githubusercontent.com/collective/buildout.plonetest/master/test-5.1.x.cfg + https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg + base.cfg + +update-versions-file = test_plone51.cfg + +[versions] +plone.testing = 5.1.1 +plone.schema = 1.2.1 +collective.recipe.vscode = >=0.1.6 +PyJWT = <2.0.0a1 diff --git a/test_plone52.cfg b/test_plone52.cfg new file mode 100644 index 0000000..ed1d481 --- /dev/null +++ b/test_plone52.cfg @@ -0,0 +1,13 @@ +[buildout] + +extends = + https://raw.githubusercontent.com/collective/buildout.plonetest/master/test-5.2.x.cfg + https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg + base.cfg + +update-versions-file = test_plone52.cfg + +[versions] +plone.testing = 7.0.1 +collective.recipe.vscode = >=0.1.6 +importlib-metadata = 1.1.3 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..4005cf8 --- /dev/null +++ b/tox.ini @@ -0,0 +1,162 @@ +[tox] +envlist = + py27-lint, + py37-lint, + py{27}-Plone{43,51}, + py{27,37}-Plone{52}, +# build_instance, +# docs, +# coverage-report, + +skip_missing_interpreters = True + +[testenv] +skip_install = true + +extras = + develop + test + +commands = + {envbindir}/buildout -q -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} bootstrap +# {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} annotate + {envbindir}/buildout -n -qq -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} install test robot + coverage run {envbindir}/test -v1 --auto-color {posargs} + # coverage run {envbindir}/test -v --all -t robot {posargs} + +setenv = + COVERAGE_FILE=.coverage.{envname} + version_file=test_plone52.cfg + Plone43: version_file=test_plone43.cfg + Plone51: version_file=test_plone51.cfg + Plone52: version_file=test_plone52.cfg + +deps = + -rrequirements.txt + Plone43: -cconstraints_plone43.txt + Plone51: -cconstraints_plone51.txt + Plone52: -cconstraints_plone52.txt + coverage + + +[testenv:coverage-report] +skip_install = true +usedevelop = True +basepython = python3.7 + +deps = + coverage + -cconstraints_plone52.txt + +setenv = + COVERAGE_FILE=.coverage + +commands = + coverage erase + coverage combine + coverage html + coverage xml + coverage report + + +[lint] +skip_install = true + +deps = + isort<5 + flake8 + # helper to generate HTML reports: + flake8-html + # Useful flake8 plugins that are Python and Plone specific: + flake8-coding + flake8-debugger + flake8-deprecated + flake8-print + #flake8-pytest + flake8-todo + mccabe + # Potential flake8 plugins that should be used: # TBD + #flake8-blind-except + #flake8-commas + #flake8-docstrings + #flake8-mypy + #flake8-pep3101 + #flake8-plone-hasattr + #flake8-string-format + #flake8_strict + #flake8-quotes + #flake8-polyfill + +commands = + mkdir -p {toxinidir}/reports/flake8 + - flake8 --format=html --htmldir={toxinidir}/reports/flake8 --doctests src setup.py + flake8 --doctests src setup.py + isort --check-only --recursive {toxinidir}/src + +whitelist_externals = + mkdir + +[testenv:isort-apply] +skip_install = true + +deps = + isort<5 + +commands = + isort --recursive --apply {toxinidir}/src + +[testenv:py27-lint] +basepython = python2.7 +skip_install = true +deps = {[lint]deps} +commands = {[lint]commands} +whitelist_externals = {[lint]whitelist_externals} + + +[testenv:py37-lint] +basepython = python3.7 +skip_install = true +deps = {[lint]deps} +commands = {[lint]commands} +whitelist_externals = {[lint]whitelist_externals} + +[testenv:docs] +skip_install = true + +deps = + Sphinx + +commands = + sphinx-build -b html -d _build/docs/doctrees docs _build/docs/html + +[testenv:update_translation] +skip_install = true + +deps = + i18ndude + +commands = + i18ndude find-untranslated + i18ndude rebuild-pot + i18ndude merge + i18ndude sync + i18ndude list + +[testenv:release] +basepython = python3.7 +skip_install = true + +deps = + zest.releaser[recommended] + +commands = + fullrelease --no-input -v + +[testenv:build_instance] +basepython = python3.7 +skip_install = true + +commands = + {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={toxinidir} bootstrap + {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={toxinidir} annotate + {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={toxinidir}