From 172b459ac6524be405b68d443a8694ce0b3e1a82 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Thu, 30 Mar 2023 08:22:01 -0600 Subject: [PATCH 1/7] version bumps. add more checks --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ce5f297..f229421 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -60,7 +60,7 @@ repos: --report-level=warning, ] - repo: https://github.com/codespell-project/codespell - rev: v2.2.2 + rev: v2.2.4 hooks: - id: codespell files: \.(py|sh|rst|yml|yaml)$ From 0f91d5f7ce0185dd3fe2b4fb941032ccd1564a04 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Thu, 30 Mar 2023 14:30:12 -0600 Subject: [PATCH 2/7] add backward compatibility to xmodule imports. enahance setup.py --- CHANGELOG.md | 9 + LICENSE.txt | 671 ++++++++++++++++++ README.md | 1 + __about__.py | 27 + openedx_plugin/dashboard/views.py | 41 +- openedx_plugin/version.py | 3 +- openedx_plugin_api/api.py | 33 +- .../tests/test_edxapi_endpoints.py | 11 +- openedx_plugin_api/utils.py | 14 +- openedx_plugin_api/version.py | 3 +- openedx_plugin_cms/auditor.py | 20 +- openedx_plugin_cms/signals.py | 22 +- openedx_plugin_cms/utils.py | 30 +- openedx_plugin_cms/version.py | 3 +- openedx_plugin_cms/views/change_log.py | 18 +- openedx_plugin_cms/views/course_audit.py | 57 +- openedx_plugin_mobile_api/version.py | 3 +- setup.py | 49 +- 18 files changed, 927 insertions(+), 88 deletions(-) create mode 100644 LICENSE.txt create mode 100644 __about__.py diff --git a/CHANGELOG.md b/CHANGELOG.md index caa22e3..9a06831 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.1.3] (2022-3-30) + +- add AGPLv3 license +- make xmodule imports backward compatible to nutmeg and earlier +- add __about__.py +- enhance setup.up setup() meta data +- bump classifier from alpha to beta +- refactor in order to make repo more condusive to uploading to PyPi + ## [0.1.2] (2022-3-29) - add a module level IS_READY boolean to prevent ready() from running multiple times during init diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..1eb391f --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,671 @@ + 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 +. + +EdX Inc. wishes to state, in clarification of the above license terms, that +any public, independently available web service offered over the network and +communicating with edX's copyrighted works by any form of inter-service +communication, including but not limited to Remote Procedure Call (RPC) +interfaces, is not a work based on our copyrighted work within the meaning +of the license. "Corresponding Source" of this work, or works based on this +work, as defined by the terms of this license do not include source code +files for programs used solely to provide those public, independently +available web services. diff --git a/README.md b/README.md index c671126..84adb9c 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ tutor local run cms ./manage.py cms openedx_plugin_cms_init * Set your Python interpreter to 3.8x * install black: * install flake8: +* pip install flake8-coding ```bash # Run these from within your edx-platform virtual environment diff --git a/__about__.py b/__about__.py new file mode 100644 index 0000000..4b80029 --- /dev/null +++ b/__about__.py @@ -0,0 +1,27 @@ +# coding=utf-8 +import os + +# Increment this version number to trigger a new release. See +# CHANGELOG.md for information on the versioning scheme. +__version__ = "0.1.3" + +# The version suffix will be appended to the actual version, separated by a +# dash. Use this suffix to differentiate between the actual released version and +# the versions from other branches. For instance: set the suffix to "nightly" in +# the nightly branch. +# The suffix is cleanly separated from the __version__ in this module to avoid +# conflicts when merging branches. +__version_suffix__ = "" + +# The app name will be used to define the name of the default plugin root and +# plugin directory. To avoid conflicts between multiple locally-installed +# versions, if it is defined the version suffix will also be appended to the app +# name. +__app__ = os.environ.get("OPENEDX_PLUGIN_EXAMPLE", "example-plugin") + +# Package version, as installed by pip, does not include the version suffix. +__package_version__ = __version__ + +if __version_suffix__: + __version__ += "-" + __version_suffix__ + __app__ += "-" + __version_suffix__ diff --git a/openedx_plugin/dashboard/views.py b/openedx_plugin/dashboard/views.py index ff8d345..e9d7300 100644 --- a/openedx_plugin/dashboard/views.py +++ b/openedx_plugin/dashboard/views.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -9,19 +10,28 @@ - redirect the user elsewhere, like say, an onboarding page - update user profile data """ +# python stuff import logging from urllib.parse import urlparse +# django stuff from django.shortcuts import redirect from django.urls import reverse from django.contrib.auth.decorators import login_required from django.views.decorators.csrf import ensure_csrf_cookie +# open edx stuff from opaque_keys.edx.keys import CourseKey from common.djangoapps.student.models import CourseEnrollment -from xmodule.modulestore.django import modulestore +try: + # for olive and later + from xmodule.modulestore.django import modulestore +except ImportError: + # for backward compatibility with nutmeg and earlier + from common.lib.xmodule.xmodule.modulestore.django import modulestore +# our stuff from .utils import set_language_preference log = logging.getLogger(__name__) @@ -58,10 +68,13 @@ def student_dashboard(request): ) ) else: - log.info("student_dashboard() - initiating after referal {referer}".format(referer=referer.netloc)) + log.info("student_dashboard() - initiating after referral {referer}".format(referer=referer.netloc)) log.info( - "student_dashboard() - user {username} is accessing example via {platform}. Referer is {referer}. Received a language preference of {language_param} and a pre-enrollment course key of {enroll_in}".format( + "student_dashboard() - user {username} is accessing example via \ + {platform}. Referer is {referer}. Received a language \ + preference of {language_param} and a pre-enrollment \ + course key of {enroll_in}".format( username=username, platform=platform, referer=referer.netloc, @@ -85,9 +98,11 @@ def student_dashboard(request): try: course_key = CourseKey.from_string(enroll_in) - except Exception: + except Exception: # noqa: B902 log.warning( - "student_dashboard() received an invalid CourseKey string in the enroll url param. Ignoring. value was: {enroll_in}".format( + "student_dashboard() received an invalid CourseKey string in \ + the enroll url param. Ignoring. value was: \ + {enroll_in}".format( enroll_in=enroll_in ) ) @@ -95,9 +110,11 @@ def student_dashboard(request): if course_key: try: course = modulestore().get_course(course_key) - except Exception as e: + except Exception as e: # noqa: B902 log.warning( - "student_dashboard() encountered a handled exception while attempting to initialize course object for course key {enroll_in}. Exception: {e}".format( + "student_dashboard() encountered a handled exception \ + while attempting to initialize course object for \ + course key {enroll_in}. Exception: {e}".format( enroll_in=enroll_in, e=e ) ) @@ -121,14 +138,18 @@ def student_dashboard(request): ) else: log.info( - "student_dashboard() course {enroll_in} has not yet started. Redirecting the user to their dashboard.".format( + "student_dashboard() course {enroll_in} has not yet \ + started. Redirecting the user to their \ + dashboard.".format( enroll_in=enroll_in ) ) - except Exception as e: + except Exception as e: # noqa: B902 log.warning( - "student_dashboard() encountered a handled exception while attempting to enroll user {username} in the course {enroll_in}. Exception: {e}".format( + "student_dashboard() encountered a handled exception while\ + attempting to enroll user {username} in the course \ + {enroll_in}. Exception: {e}".format( username=request.user.username, enroll_in=enroll_in, e=e ) ) diff --git a/openedx_plugin/version.py b/openedx_plugin/version.py index d8981f2..48509da 100644 --- a/openedx_plugin/version.py +++ b/openedx_plugin/version.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -6,4 +7,4 @@ usage: semantic version control for openedx_plugin """ -__version__ = "0.1.0" +__version__ = "0.1.1" diff --git a/openedx_plugin_api/api.py b/openedx_plugin_api/api.py index e1ca718..d11730d 100644 --- a/openedx_plugin_api/api.py +++ b/openedx_plugin_api/api.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -7,9 +8,11 @@ usage: Example custom REST API leveraging misc functionality from Open edX repos. """ +# python stuff import os import json +# django stuff from django.contrib.auth import get_user_model from django.http.response import HttpResponseNotFound from openedx.core.djangoapps.oauth_dispatch.jwt import create_jwt_for_user @@ -20,28 +23,36 @@ from rest_framework.views import APIView from social_django.models import UserSocialAuth +# open edx stuff from opaque_keys.edx.keys import CourseKey from openedx.core.djangoapps.enrollments import api from common.djangoapps.student.models import CourseEnrollment from common.djangoapps.student.roles import CourseDataResearcherRole from openedx.core.djangoapps.content.course_overviews.models import CourseOverview from common.djangoapps.course_modes.models import CourseMode -from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.course_module import DEFAULT_START_DATE, CourseFields from lms.djangoapps.certificates.models import CertificateGenerationCourseSetting from lms.djangoapps.bulk_email.models import CourseAuthorization - -import openedx.core.djangoapps.django_comment_common.comment_client as cc -import lms.djangoapps.discussion.django_comment_client.utils as utils - - from lms.djangoapps.courseware.models import StudentModule from lms.djangoapps.grades.models import PersistentCourseGrade - from openedx.core.djangoapps.django_comment_common.models import ( FORUM_ROLE_MODERATOR, Role, ) +import openedx.core.djangoapps.django_comment_common.comment_client as cc +import lms.djangoapps.discussion.django_comment_client.utils as utils + +try: + # for olive and later + from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.course_module import DEFAULT_START_DATE, CourseFields +except ImportError: + # for backward compatibility with nutmeg and earlier + from common.lib.xmodule.xmodule.modulestore.django import ( + modulestore, + ) # lint-amnesty, pylint: disable=wrong-import-order + from common.lib.xmodule.xmodule.course_module import DEFAULT_START_DATE, CourseFields + +# our stuff from .utils import get_course_info from .models import CoursePoints from .version import __version__ @@ -237,10 +248,10 @@ def get(self, request, course_key): try: key = CourseKey.from_string(course_key) response = get_course_info(key) - except Exception as exc: + except Exception as exc: # noqa: B902 response["error"] = str(exc) finally: - return ResponseSuccess(response) + return ResponseSuccess(response) # noqa: B012 @view_auth_classes(is_authenticated=True) @@ -253,7 +264,7 @@ def get(self, request, course_key): except CoursePoints.DoesNotExist: response["error"] = "This course does not define points" finally: - return ResponseSuccess(response) + return ResponseSuccess(response) # noqa: B012 def post(self, request, course_key): response = {} diff --git a/openedx_plugin_api/tests/test_edxapi_endpoints.py b/openedx_plugin_api/tests/test_edxapi_endpoints.py index 7af9b3e..7b67f78 100644 --- a/openedx_plugin_api/tests/test_edxapi_endpoints.py +++ b/openedx_plugin_api/tests/test_edxapi_endpoints.py @@ -1,13 +1,22 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Aug-2021 Tests of the openedx_plugin_api """ + +# djanog stuff from django.urls import reverse from rest_framework.test import APITestCase -from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase +# open edx stuff +try: + # for olive and later + from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase +except ImportError: + # for backward compatibility with nutmeg and earlier + from common.lib.xmodule.xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase class TestAPIEndpoints(SharedModuleStoreTestCase, APITestCase): diff --git a/openedx_plugin_api/utils.py b/openedx_plugin_api/utils.py index 2e5dac3..cd49a9c 100644 --- a/openedx_plugin_api/utils.py +++ b/openedx_plugin_api/utils.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -7,19 +8,30 @@ usage: utility and convenience functions for openedx_plugin_api plugin """ +# python stuff from datetime import datetime from pytz import UTC import re +# django stuff from django.urls import reverse from django.urls.exceptions import NoReverseMatch +# open edx stuff from openedx.core.djangoapps.user_api.accounts.utils import ( retrieve_last_sitewide_block_completed, ) from opaque_keys.edx.keys import CourseKey from common.djangoapps.util.date_utils import get_default_time_display -from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order + +try: + # for olive and later + from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order +except ImportError: + # for backward compatibility with nutmeg and earlier + from common.lib.xmodule.xmodule.modulestore.django import ( + modulestore, + ) # lint-amnesty, pylint: disable=wrong-import-order def get_course_info(course_key: CourseKey): diff --git a/openedx_plugin_api/version.py b/openedx_plugin_api/version.py index 90bafc7..49d7c20 100644 --- a/openedx_plugin_api/version.py +++ b/openedx_plugin_api/version.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -6,4 +7,4 @@ usage: version control for openedx_plugin_api plugin """ -__version__ = "0.1.0" +__version__ = "0.1.1" diff --git a/openedx_plugin_cms/auditor.py b/openedx_plugin_cms/auditor.py index f21436a..10cc88d 100644 --- a/openedx_plugin_cms/auditor.py +++ b/openedx_plugin_cms/auditor.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Oct-2021 @@ -9,23 +10,31 @@ import json import logging -# django +# django stuff from django.conf import settings from django.contrib.auth import get_user_model -# common libs +# open edx common libs from opaque_keys.edx.keys import CourseKey, UsageKey from xblock.core import XBlock -# open edx +# open edx stuff from cms.djangoapps.contentstore.utils import ( get_lms_link_for_item, is_currently_visible_to_students, ) -from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order from openedx.core.djangoapps.content.block_structure.api import get_course_in_cache -# this repo +try: + # for olive and later + from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order +except ImportError: + # for backward compatibility with nutmeg and earlier + from common.lib.xmodule.xmodule.modulestore.django import ( + modulestore, + ) # lint-amnesty, pylint: disable=wrong-import-order + +# our stuff from .utils import ( round_seconds, get_user, @@ -174,7 +183,6 @@ def eval_course_block_changes(course_key: CourseKey, user: User) -> None: # # block_key is opaque_keys.edx.locator.BlockUsageLocator for block_key in collected_block_structure.topological_traversal(): - # xblock is also a BlockUsageLocator, but it's fully # initialized (the data contents at the block location are also initialized) xblock = store.get_item(block_key) diff --git a/openedx_plugin_cms/signals.py b/openedx_plugin_cms/signals.py index 21ee7ac..18f97aa 100644 --- a/openedx_plugin_cms/signals.py +++ b/openedx_plugin_cms/signals.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com oct-2021 @@ -9,20 +10,28 @@ Also see: https://docs.djangoproject.com/en/3.2/topics/signals/ """ -# Python +# Python stuff import logging -# Django +# Django stuff from django.dispatch import receiver from celery import shared_task from edx_django_utils.monitoring import set_code_owner_attribute -# Open edX -# see: https://discuss.openedx.org/t/django-plugin-app-works-with-some-django-signals-but-not-others/5949/3 -from xmodule.modulestore.django import SignalHandler +# Open edX stuff from opaque_keys.edx.keys import CourseKey -from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order +try: + # for olive and later + # see: https://discuss.openedx.org/t/django-plugin-app-works-with-some-django-signals-but-not-others/5949/3 + from xmodule.modulestore.django import SignalHandler + from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order +except ImportError: + # for backward compatibility with nutmeg and earlier + from common.lib.xmodule.xmodule.modulestore.django import SignalHandler + from common.lib.xmodule.xmodule.modulestore.django import ( + modulestore, + ) # lint-amnesty, pylint: disable=wrong-import-order # this repo from .auditor import ( @@ -81,7 +90,6 @@ def _plugin_handle_item_deleted(**kwargs): """ usage_key = kwargs.get("usage_key") if usage_key: - # Strip branch info usage_key = usage_key.for_branch(None) user_id = kwargs.get("user_id") diff --git a/openedx_plugin_cms/utils.py b/openedx_plugin_cms/utils.py index 2fbbab8..e91905a 100644 --- a/openedx_plugin_cms/utils.py +++ b/openedx_plugin_cms/utils.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Oct-2021 @@ -13,22 +14,29 @@ from os.path import basename from urllib.parse import urlparse -# django +# django stuff from django.conf import settings from django.contrib.auth import get_user_model -# common libs +# open edx common libs from xblock.fields import Boolean, String from xblock.core import XBlock from opaque_keys.edx.keys import UsageKey # open edx stuff -from xmodule.modulestore.django import modulestore -from xmodule.course_module import CourseBlock # lint-amnesty, pylint: disable=wrong-import-order from cms.djangoapps.contentstore.utils import get_lms_link_for_item -# this repo +try: + # for olive and later + from xmodule.modulestore.django import modulestore + from xmodule.course_module import CourseBlock # lint-amnesty, pylint: disable=wrong-import-order +except ImportError: + # for backward compatibility with nutmeg and earlier + from common.lib.xmodule.xmodule.modulestore.django import modulestore + from common.lib.xmodule.xmodule.course_module import CourseBlock # lint-amnesty, pylint: disable=wrong-import-order + +# our stuff from .models import CourseChangeLog User = get_user_model() @@ -42,7 +50,7 @@ def link_extractor(html: str): """ try: doc = fromstring(html) - except Exception: + except Exception: # noqa: B902 return "" retval = [] @@ -63,7 +71,7 @@ def asset_extractor(html: str): """ try: doc = fromstring(html) - except Exception: + except Exception: # noqa: B902 return "" retval = [] @@ -76,7 +84,7 @@ def asset_extractor(html: str): def get_grade_weight(xblock: XBlock, course: CourseBlock): """ - retreive the problem weight from the grading policy + retrieve the problem weight from the grading policy based on Xblock type. raw_grader: [ @@ -158,7 +166,7 @@ def get_parent_location(category: String, block_key: UsageKey) -> UsageKey: def get_problem_type(xblock: XBlock) -> str: """ - Xblock accomodates multiple problem types, + Xblock accommodates multiple problem types, but in our use case we are only interested in the first of these. """ @@ -179,7 +187,6 @@ def get_host_url(app="cms") -> str: def get_user(user_id): - try: return User.objects.get(id=user_id) except User.DoesNotExist: @@ -187,12 +194,11 @@ def get_user(user_id): def get_xblock_attribute(usage_key: UsageKey, attr: String): - if usage_key: try: xblock = modulestore().get_item(usage_key) return xblock.__getattribute__(attr) - except Exception: + except Exception: # noqa: B902 return None return None diff --git a/openedx_plugin_cms/version.py b/openedx_plugin_cms/version.py index 3dc1f76..42910c3 100644 --- a/openedx_plugin_cms/version.py +++ b/openedx_plugin_cms/version.py @@ -1 +1,2 @@ -__version__ = "0.1.0" +# coding=utf-8 +__version__ = "0.1.1" diff --git a/openedx_plugin_cms/views/change_log.py b/openedx_plugin_cms/views/change_log.py index bdbb821..6b10a5c 100644 --- a/openedx_plugin_cms/views/change_log.py +++ b/openedx_plugin_cms/views/change_log.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Oct-2021 @@ -5,12 +6,12 @@ View to dump log data to a simple row-column paginated layout. see: https://docs.djangoproject.com/en/2.2/topics/pagination/ """ -# Python +# Python stuff import csv from typing import List import logging -# Django +# Django stuff from django.core.paginator import Paginator from django.contrib.auth.decorators import login_required from django.views.decorators.cache import cache_control @@ -18,13 +19,19 @@ from six import StringIO -# Open edX +# Open edX stuff from common.djangoapps.util.views import ensure_valid_course_key from common.djangoapps.edxmako.shortcuts import render_to_response from opaque_keys.edx.keys import CourseKey -from xmodule.course_module import CourseSummary -# This repo +try: + # for olive and later + from xmodule.course_module import CourseSummary +except ImportError: + # for backward compatibility with nutmeg and earlier + from common.lib.xmodule.xmodule.course_module import CourseSummary + +# our stuff from openedx_plugin_cms.models import CourseChangeLog from openedx_plugin_cms.utils import get_xblock_attribute @@ -34,7 +41,6 @@ def get_csv_url(course_id=None, page_number=None): - if course_id: url = "/plugin_cms/courses/{course_id}/log/csv/".format(course_id=course_id) else: diff --git a/openedx_plugin_cms/views/course_audit.py b/openedx_plugin_cms/views/course_audit.py index 1835d0e..3687662 100644 --- a/openedx_plugin_cms/views/course_audit.py +++ b/openedx_plugin_cms/views/course_audit.py @@ -1,15 +1,13 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Nov-2021 CMS App - Course Audit views -see: https://co-digitallearning.atlassian.net/browse/CODLT-383 - https://docs.google.com/spreadsheets/d/1v08r5KEarvsMiqHSlELWnFNqBwgdkofDvgj4ogyGmiw/edit#gid=0 - https://co-digitallearning.atlassian.net/wiki/spaces/CODLT/pages/2326536/Course+Inventory also: https://docs.djangoproject.com/en/2.2/topics/pagination/ """ -# Python +# Python stuff import time import csv import logging @@ -18,7 +16,7 @@ from contextlib import contextmanager from hashlib import md5 -# Django +# Django stuff from django.conf import settings from django.contrib.auth.decorators import login_required from django.core.paginator import Paginator @@ -40,26 +38,42 @@ from celery.exceptions import SoftTimeLimitExceeded from celery_utils.persist_on_failure import LoggedPersistOnFailureTask -# Open edX +# Open edX stuff from common.djangoapps.util.views import ensure_valid_course_key from openedx.core.lib.cache_utils import request_cached from common.djangoapps.edxmako.shortcuts import render_to_response - -# Open edX course content from cms.djangoapps.models.settings.course_grading import CourseGradingModel from opaque_keys.edx.keys import CourseKey from xblock.core import XBlock -from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.course_module import CourseBlock # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.seq_module import SequenceBlock, SectionBlock # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.vertical_block import VerticalBlock # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.unit_block import UnitBlock # Units are verticals. + +try: + # for olive and later + from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.course_module import CourseBlock # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.seq_module import SequenceBlock, SectionBlock # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.vertical_block import VerticalBlock # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.unit_block import UnitBlock # Units are verticals. +except ImportError: + # for backward compatibility with nutmeg and earlier + from common.lib.xmodule.xmodule.modulestore.django import ( + modulestore, + ) # lint-amnesty, pylint: disable=wrong-import-order + from common.lib.xmodule.xmodule.modulestore import ( + ModuleStoreEnum, + ) # lint-amnesty, pylint: disable=wrong-import-order + from common.lib.xmodule.xmodule.course_module import CourseBlock # lint-amnesty, pylint: disable=wrong-import-order + from common.lib.xmodule.xmodule.seq_module import ( + SequenceBlock, + SectionBlock, + ) # lint-amnesty, pylint: disable=wrong-import-order + from common.lib.xmodule.xmodule.vertical_block import ( + VerticalBlock, + ) # lint-amnesty, pylint: disable=wrong-import-order + from common.lib.xmodule.xmodule.unit_block import UnitBlock # Units are verticals. # This repo from openedx_plugin_cms.models import CourseAudit - - from openedx_plugin_cms.utils import ( get_user, xblock_edit_dates, @@ -85,7 +99,10 @@ SoftTimeLimitExceeded, ) RETRY_DELAY_SECONDS = 60 -TASK_TIME_LIMIT = LOCK_EXPIRE # Task hard time limit in seconds. The worker processing the task will be killed and replaced with a new one when this is exceeded. +TASK_TIME_LIMIT = LOCK_EXPIRE # Task hard time limit in seconds. The worker +# processing the task will be killed and +# replaced with a new one when this is +# exceeded. TASK_SOFT_TIME_LIMIT = ( None # https://docs.celeryproject.org/en/stable/userguide/configuration.html#std-setting-task_soft_time_limit ) @@ -112,7 +129,7 @@ def task_lock(oid, course_id): try: yield status - except Exception as e: + except Exception as e: # noqa: B902 log.error("error while attempting lock: {err}".format(err=e)) finally: if time.monotonic() < timeout_at and status: @@ -184,7 +201,6 @@ def get_sequence_dict( chapter: SectionBlock, sequence: SequenceBlock, ) -> Dict: - row = get_chapter_dict(i, course, chapter) row["d_section"] = sequence.display_name # e_unit -- skip. handled in get_vertical_dict() @@ -202,7 +218,6 @@ def get_vertical_dict( sequence: SequenceBlock, vertical: VerticalBlock, ) -> Dict: - row = get_sequence_dict(i, course, chapter, sequence) row["e_unit"] = vertical.display_name row["e2_block_type"] = vertical.location.block_type @@ -228,7 +243,7 @@ def get_vertical_child_dict( child can be any of ProblemBlock, DiscussionXBlock, HtmlBlock (or some kind of specialized XBlock). Ideally we'd cast these after introspecting their type, but, we only need to extract a couple of pieces - of data and so we'll defer that indefinitely until a real neeed arises. + of data and so we'll defer that indefinitely until a real need arises. """ edited_on, published_on = xblock_edit_dates(child) row = get_vertical_dict(i, course, chapter, sequence, vertical) diff --git a/openedx_plugin_mobile_api/version.py b/openedx_plugin_mobile_api/version.py index 465df24..8754943 100644 --- a/openedx_plugin_mobile_api/version.py +++ b/openedx_plugin_mobile_api/version.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -6,4 +7,4 @@ usage: semantic version control for openedx_plugin_mobile_api """ -__version__ = "0.1.0" +__version__ = "0.1.1" diff --git a/setup.py b/setup.py index b2a36a9..4bc88bf 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,39 @@ +# coding=utf-8 +""" +Lawrence McDaniel https://lawrencemcdaniel.com + +The style and organizational scheme for this setup.py is largely copied from +these two projects: + openedx: https://github.com/openedx/edx-platform/blob/master/setup.py + tutor: https://github.com/overhangio/tutor/blob/master/setup.py +""" # pylint: disable=open-builtin +import io import os from setuptools import find_packages, setup +from typing import Dict, List + +HERE = os.path.abspath(os.path.dirname(__file__)) # allow setup.py to be run from any path os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) -def load_requirements(*requirements_paths): +def load_readme() -> str: + with io.open(os.path.join(HERE, "README.md"), "rt", encoding="utf8") as f: + readme = f.read() + # Replace img src for publication on pypi + return readme.replace("./doc/", "https://github.com/cookiecutter-openedx/cookiecutter-openedx-devops/raw/main/doc/") + + +def load_about() -> Dict[str, str]: + about: Dict[str, str] = {} + with io.open(os.path.join(HERE, "__about__.py"), "rt", encoding="utf-8") as f: + exec(f.read(), about) # pylint: disable=exec-used + return about + + +def load_requirements(*requirements_paths) -> List[str]: """ Load all requirements from the specified requirements files. Returns: @@ -20,7 +47,7 @@ def load_requirements(*requirements_paths): return list(requirements) -def is_requirement(line): +def is_requirement(line) -> bool: """ Return True if the requirement line is a package requirement. Returns: @@ -38,28 +65,30 @@ def is_requirement(line): README = open(os.path.join(os.path.dirname(__file__), "README.md")).read() CHANGELOG = open(os.path.join(os.path.dirname(__file__), "CHANGELOG.md")).read() +ABOUT = load_about() print("Found packages: {packages}".format(packages=find_packages())) - print("requirements found: {requirements}".format(requirements=load_requirements("requirements/common.in"))) setup( name="example-plugin", - version="0.1.2", + version=ABOUT["__package_version__"], packages=find_packages(), package_data={"": ["*.html"]}, # include any Mako templates found in this repo. include_package_data=True, - license="Proprietary", + license_files=("LICENSE.txt",), + license="AGPLv3", description="Django plugin to enhance feature set of base Open edX platform.", - long_description="", + long_description=load_readme(), author="Lawrence McDaniel", author_email="lpm0073@gmail.com", url="https://github.com/cookiecutter-openedx/example-openedx-plugin", + download_url="https://github.com/cookiecutter-openedx/cookiecutter-openedx-devops.git", install_requires=load_requirements("requirements/common.in"), zip_safe=False, - keywords="Django, Open edX", - classifiers=[ - "Development Status :: 3 - Alpha", + keywords="Django, Open edX, Plugin", + classifiers=[ # https://pypi.org/classifiers/ + "Development Status :: 4 - Beta", "Framework :: Django", "Framework :: Django :: 2.2", "Framework :: Django :: 3.0", @@ -71,6 +100,8 @@ def is_requirement(line): "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.8", + "Topic :: Education", + "Topic :: Education :: Computer Aided Instruction (CAI)", ], entry_points={ # mcdaniel feb-2022 From 1cd99314e2abf690d87ac6ccd978b8483fe6a708 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Thu, 30 Mar 2023 15:27:55 -0600 Subject: [PATCH 3/7] PEP 263 and B950 compliance --- openedx_plugin/__init__.py | 1 + openedx_plugin/admin.py | 1 + openedx_plugin/api/serializers.py | 1 + openedx_plugin/api/urls.py | 1 + openedx_plugin/api/views.py | 1 + openedx_plugin/apps.py | 2 +- openedx_plugin/dashboard/utils.py | 25 ++++++++---- openedx_plugin/locale/utils.py | 18 +++++---- openedx_plugin/locale/views.py | 1 + .../commands/openedx_plugin_init.py | 1 + openedx_plugin/middleware.py | 1 + openedx_plugin/migrations/0001_initial.py | 4 +- .../0002_alter_marketingsites_language.py | 2 +- openedx_plugin/models.py | 1 + openedx_plugin/settings/common.py | 1 + openedx_plugin/settings/production.py | 1 + openedx_plugin/signals.py | 3 +- openedx_plugin/urls.py | 1 + openedx_plugin/utils.py | 3 +- openedx_plugin/waffle.py | 10 +++-- openedx_plugin/wordpress_oauth2_backend.py | 1 + openedx_plugin_api/__init__.py | 1 + openedx_plugin_api/admin.py | 1 + openedx_plugin_api/apps.py | 1 + .../create_oauth_application_client_config.py | 1 + .../commands/openedx_plugin_api_init.py | 3 +- openedx_plugin_api/migrations/0001_initial.py | 2 +- openedx_plugin_api/models.py | 1 + openedx_plugin_api/settings/production.py | 1 + openedx_plugin_api/signals.py | 1 + openedx_plugin_api/urls.py | 1 + openedx_plugin_api/waffle.py | 10 +++-- openedx_plugin_cms/__init__.py | 1 + openedx_plugin_cms/admin.py | 1 + openedx_plugin_cms/apps.py | 1 + .../{course_audit.py => course_audit.json} | 0 .../management/commands/course_audit.py | 1 + .../management/commands/eval_course.py | 1 + .../commands/openedx_plugin_cms_init.py | 1 + openedx_plugin_cms/migrations/0001_initial.py | 16 ++++---- .../migrations/0002_courseaudit.py | 10 ++--- .../migrations/0003_auto_20211215_0428.py | 2 +- .../migrations/0004_auto_20211215_1645.py | 4 +- openedx_plugin_cms/migrations/__init__.py | 1 + openedx_plugin_cms/models.py | 39 ++++++++++--------- openedx_plugin_cms/settings/common.py | 1 + openedx_plugin_cms/settings/production.py | 1 + openedx_plugin_cms/urls.py | 1 + openedx_plugin_cms/views/__init__.py | 1 + openedx_plugin_cms/views/course_audit_html.py | 1 + openedx_plugin_cms/waffle.py | 10 +++-- openedx_plugin_mobile_api/__init__.py | 1 + openedx_plugin_mobile_api/apps.py | 1 + openedx_plugin_mobile_api/decorators.py | 1 + .../openedx_plugin_mobile_api_init.py | 1 + openedx_plugin_mobile_api/middleware.py | 2 +- openedx_plugin_mobile_api/settings/common.py | 1 + openedx_plugin_mobile_api/urls.py | 1 + .../users/serializers.py | 5 ++- openedx_plugin_mobile_api/users/urls.py | 1 + openedx_plugin_mobile_api/users/views.py | 1 + openedx_plugin_mobile_api/waffle.py | 16 +++++--- 62 files changed, 148 insertions(+), 79 deletions(-) rename openedx_plugin_cms/data/{course_audit.py => course_audit.json} (100%) diff --git a/openedx_plugin/__init__.py b/openedx_plugin/__init__.py index d1162f5..b9cba43 100644 --- a/openedx_plugin/__init__.py +++ b/openedx_plugin/__init__.py @@ -1 +1,2 @@ +# coding=utf-8 default_app_config = "openedx_plugin.apps.CustomPluginConfig" diff --git a/openedx_plugin/admin.py b/openedx_plugin/admin.py index 8876417..a7dbae1 100644 --- a/openedx_plugin/admin.py +++ b/openedx_plugin/admin.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com diff --git a/openedx_plugin/api/serializers.py b/openedx_plugin/api/serializers.py index 01db7b3..ae387bc 100644 --- a/openedx_plugin/api/serializers.py +++ b/openedx_plugin/api/serializers.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com diff --git a/openedx_plugin/api/urls.py b/openedx_plugin/api/urls.py index 9af183b..9b3ef3a 100644 --- a/openedx_plugin/api/urls.py +++ b/openedx_plugin/api/urls.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com diff --git a/openedx_plugin/api/views.py b/openedx_plugin/api/views.py index 447fbc8..c181430 100644 --- a/openedx_plugin/api/views.py +++ b/openedx_plugin/api/views.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com diff --git a/openedx_plugin/apps.py b/openedx_plugin/apps.py index e375179..0bfe4fc 100644 --- a/openedx_plugin/apps.py +++ b/openedx_plugin/apps.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -49,7 +50,6 @@ class CustomPluginConfig(AppConfig): - name = "openedx_plugin" label = "openedx_plugin" diff --git a/openedx_plugin/dashboard/utils.py b/openedx_plugin/dashboard/utils.py index 2ec529b..458db17 100644 --- a/openedx_plugin/dashboard/utils.py +++ b/openedx_plugin/dashboard/utils.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -38,7 +39,8 @@ def set_language_preference(request): language_param = request.GET.get("language") if language_param: log.info( - "set_language_preference() found language url param of {language_param} in the request object".format( + "set_language_preference() found language url param of \ + {language_param} in the request object".format( language_param=language_param ) ) @@ -46,14 +48,17 @@ def set_language_preference(request): preferred_language = get_user_preference(request.user, LANGUAGE_KEY) if preferred_language: log.info( - "set_language_preference() found an existing saved language preference for user {username} of {preferred_language}. Ignoring url param.".format( + "set_language_preference() found an existing saved language \ + preference for user {username} of {preferred_language}. \ + Ignoring url param.".format( username=request.user.username, preferred_language=preferred_language ) ) return None else: log.info( - "set_language_preference() no language preference set for user {username}".format( + "set_language_preference() no language preference set for user \ + {username}".format( username=request.user.username ) ) @@ -68,7 +73,8 @@ def set_language_preference(request): log.info("set_language_preference() no available language, exiting.") return None log.info( - "openedx_plugin.utils.set_language_preference() (2) detected language param={language_param}. closest installed={closest_lang}".format( + "openedx_plugin.utils.set_language_preference() (2) detected \ + language param={language_param}. closest installed={closest_lang}".format( language_param=language_param, closest_lang=closest_lang ) ) @@ -76,7 +82,8 @@ def set_language_preference(request): return None else: log.info( - "set_language_preference() no language param found in the request header for user {username}".format( + "set_language_preference() no language param found in the request\ + header for user {username}".format( username=request.user.username ) ) @@ -85,17 +92,19 @@ def set_language_preference(request): referer = urlparse(request.META.get("HTTP_REFERER", "Direct")) referer_domain = referer.netloc log.info( - "set_language_preference() analyzing http referer {referer} with domain {domain}".format( + "set_language_preference() analyzing http referer {referer} with \ + domain {domain}".format( referer=referer, domain=referer_domain ) ) if referer_domain and referer_domain[:2].lower() == "mx": closest_lang = get_closest_released_language("es_MX") if not closest_lang: - log.info("set_language_preference() no available language, quiting.") + log.info("set_language_preference() no available language, quitting.") return None log.info( - "openedx_plugin.utils.set_language_preference() (3) detected referer_domain={referer_domain}. closest installed={closest_lang}".format( + "openedx_plugin.utils.set_language_preference() (3) detected \ + referer_domain={referer_domain}. closest installed={closest_lang}".format( referer_domain=referer_domain, closest_lang=closest_lang ) ) diff --git a/openedx_plugin/locale/utils.py b/openedx_plugin/locale/utils.py index 554b4e4..8a889ed 100644 --- a/openedx_plugin/locale/utils.py +++ b/openedx_plugin/locale/utils.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Feb-2022 @@ -20,7 +21,7 @@ def get_marketing_site(request): """ Returns the url to the marketing site for the user - based on informatin that can be gleaned from the request object. + based on information that can be gleaned from the request object. First, determine the best possible language code for the user taking into account all available information and meta data we have about the user. @@ -44,18 +45,19 @@ def language_from_request(request): """ preferred_language = None - # 1.) try to get the Open edX language setting chosen explicitely by the user + # 1.) try to get the Open edX language setting chosen explicitly by the user # using the language drop-down in the LMS site header. try: if request.user and request.user.is_authenticated: preferred_language = get_user_preference(request.user, LANGUAGE_KEY) log.info( - "language_from_request() found an existing language preference of {preferred_language} for username {username}".format( + "language_from_request() found an existing language preference\ + of {preferred_language} for username {username}".format( preferred_language=preferred_language, username=request.user.username, ) ) - except Exception: + except Exception: # noqa: B902 # is the user is not authenticated or if the user is logging out # then this is prone to raising an exception. pass @@ -69,7 +71,9 @@ def language_from_request(request): # if necessary, reduce the language setting to the most closely installed language closest_released_language = get_closest_released_language(preferred_language) log.info( - "language_from_request() found language param of {preferred_language} in the request params. Closest released language is {closest_released_language}".format( + "language_from_request() found language param of \ + {preferred_language} in the request params. Closest released \ + language is {closest_released_language}".format( preferred_language=preferred_language, closest_released_language=closest_released_language, ) @@ -82,7 +86,7 @@ def language_from_request(request): try: if request.LANGUAGE_CODE: return request.LANGUAGE_CODE - except Exception: + except Exception: # noqa: B902 pass # 4.) Try to grab the Django-assigned default language code, if its assigned. @@ -91,7 +95,7 @@ def language_from_request(request): # the Django default language if request.LANGUAGE: return request.LANGUAGE - except Exception: + except Exception: # noqa: B902 pass # 5.) All possible methods failed, so use the system default of English. diff --git a/openedx_plugin/locale/views.py b/openedx_plugin/locale/views.py index 5f0bfe7..b36894d 100644 --- a/openedx_plugin/locale/views.py +++ b/openedx_plugin/locale/views.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Feb-2022 diff --git a/openedx_plugin/management/commands/openedx_plugin_init.py b/openedx_plugin/management/commands/openedx_plugin_init.py index 0915b2f..cc20e53 100644 --- a/openedx_plugin/management/commands/openedx_plugin_init.py +++ b/openedx_plugin/management/commands/openedx_plugin_init.py @@ -1,3 +1,4 @@ +# coding=utf-8 from django.core.management.base import BaseCommand from ...waffle import waffle_init diff --git a/openedx_plugin/middleware.py b/openedx_plugin/middleware.py index e9a491e..2eb9bd9 100644 --- a/openedx_plugin/middleware.py +++ b/openedx_plugin/middleware.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com diff --git a/openedx_plugin/migrations/0001_initial.py b/openedx_plugin/migrations/0001_initial.py index a6c4b23..09adc7e 100644 --- a/openedx_plugin/migrations/0001_initial.py +++ b/openedx_plugin/migrations/0001_initial.py @@ -1,3 +1,4 @@ +# coding=utf-8 # Generated by Django 2.2.25 on 2022-01-15 18:29 from django.db import migrations, models @@ -6,7 +7,6 @@ class Migration(migrations.Migration): - initial = True dependencies = [] @@ -115,7 +115,7 @@ class Migration(migrations.Migration): "province", models.CharField( blank=True, - help_text="A sub-region for the language code. Example: for language code en-US valid possibles include TX, FL, CA, DC, KY, etc.", + help_text="A sub-region for the language code. Example: for language code en-US valid possibles include TX, FL, CA, DC, KY, etc.", # noqa: B950 max_length=20, ), ), diff --git a/openedx_plugin/migrations/0002_alter_marketingsites_language.py b/openedx_plugin/migrations/0002_alter_marketingsites_language.py index e409c13..8543769 100644 --- a/openedx_plugin/migrations/0002_alter_marketingsites_language.py +++ b/openedx_plugin/migrations/0002_alter_marketingsites_language.py @@ -1,10 +1,10 @@ +# coding=utf-8 # Generated by Django 3.2.12 on 2022-02-27 21:59 from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ ("openedx_plugin", "0001_initial"), ] diff --git a/openedx_plugin/models.py b/openedx_plugin/models.py index 155cbd6..8af30a2 100644 --- a/openedx_plugin/models.py +++ b/openedx_plugin/models.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com diff --git a/openedx_plugin/settings/common.py b/openedx_plugin/settings/common.py index 0a7bc95..efcce28 100644 --- a/openedx_plugin/settings/common.py +++ b/openedx_plugin/settings/common.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Common Pluggable Django App settings diff --git a/openedx_plugin/settings/production.py b/openedx_plugin/settings/production.py index a82b93c..1c8562d 100644 --- a/openedx_plugin/settings/production.py +++ b/openedx_plugin/settings/production.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Common Pluggable Django App settings """ diff --git a/openedx_plugin/signals.py b/openedx_plugin/signals.py index b77e1ba..f5542b3 100644 --- a/openedx_plugin/signals.py +++ b/openedx_plugin/signals.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -26,7 +27,7 @@ def signals_enabled() -> bool: try: return waffle_switches[SIGNALS] - except Exception: + except Exception: # noqa: B902 # to resolve a race condition during application launch. # the waffle_switches are inspected before the db service # has initialized. diff --git a/openedx_plugin/urls.py b/openedx_plugin/urls.py index 6540153..06acc41 100644 --- a/openedx_plugin/urls.py +++ b/openedx_plugin/urls.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Feb-2022 diff --git a/openedx_plugin/utils.py b/openedx_plugin/utils.py index fde7d34..0e7d4bc 100644 --- a/openedx_plugin/utils.py +++ b/openedx_plugin/utils.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -93,6 +94,6 @@ def default(self, obj): return "" try: return json.JSONEncoder.default(self, obj) - except Exception: + except Exception: # noqa: B902 # obj probably is not json serializable. return "" diff --git a/openedx_plugin/waffle.py b/openedx_plugin/waffle.py index fe44a27..eb48e82 100644 --- a/openedx_plugin/waffle.py +++ b/openedx_plugin/waffle.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -79,7 +80,7 @@ def is_ready(): try: SIGNALS_WAFFLE.is_enabled() return True - except Exception: + except Exception: # noqa: B902 return False @@ -90,7 +91,7 @@ def is_enabled(switch: WaffleSwitch) -> bool: """ try: return switch.is_enabled() - except Exception: + except Exception: # noqa: B902 return False @@ -149,13 +150,14 @@ def waffle_init(): if not is_ready(): log.warning( - "{django_app}: unable to verify initialization status of waffle switches. Try running manage.py lms {django_app}_init".format( + "{django_app}: unable to verify initialization status of waffle \ + switches. Try running manage.py lms {django_app}_init".format( django_app=WAFFLE_NAMESPACE ) ) return - for switch_name, switch_object in waffle_switches.items(): + for switch_name, _switch_object in waffle_switches.items(): try: this_switch = Switch.objects.get(name=switch_name) except ObjectDoesNotExist: diff --git a/openedx_plugin/wordpress_oauth2_backend.py b/openedx_plugin/wordpress_oauth2_backend.py index 7174827..242bf90 100644 --- a/openedx_plugin/wordpress_oauth2_backend.py +++ b/openedx_plugin/wordpress_oauth2_backend.py @@ -1,3 +1,4 @@ +# coding=utf-8 from oauth2_wordpress.wp_oauth import WPOpenEdxOAuth2 diff --git a/openedx_plugin_api/__init__.py b/openedx_plugin_api/__init__.py index 5329ca1..8f9284c 100644 --- a/openedx_plugin_api/__init__.py +++ b/openedx_plugin_api/__init__.py @@ -1 +1,2 @@ +# coding=utf-8 default_app_config = "openedx_plugin_api.apps.CustomPluginAPIConfig" diff --git a/openedx_plugin_api/admin.py b/openedx_plugin_api/admin.py index e8dd2df..66dfc4a 100644 --- a/openedx_plugin_api/admin.py +++ b/openedx_plugin_api/admin.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com diff --git a/openedx_plugin_api/apps.py b/openedx_plugin_api/apps.py index 57f016f..82b203b 100644 --- a/openedx_plugin_api/apps.py +++ b/openedx_plugin_api/apps.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com diff --git a/openedx_plugin_api/management/commands/create_oauth_application_client_config.py b/openedx_plugin_api/management/commands/create_oauth_application_client_config.py index 1f2044d..32ffe6d 100644 --- a/openedx_plugin_api/management/commands/create_oauth_application_client_config.py +++ b/openedx_plugin_api/management/commands/create_oauth_application_client_config.py @@ -1,3 +1,4 @@ +# coding=utf-8 from argparse import RawTextHelpFormatter import os diff --git a/openedx_plugin_api/management/commands/openedx_plugin_api_init.py b/openedx_plugin_api/management/commands/openedx_plugin_api_init.py index 9c00c02..6fd25f6 100644 --- a/openedx_plugin_api/management/commands/openedx_plugin_api_init.py +++ b/openedx_plugin_api/management/commands/openedx_plugin_api_init.py @@ -1,3 +1,4 @@ +# coding=utf-8 import os import logging @@ -66,7 +67,7 @@ def api_access(self): access.status = ApiAccessRequest.APPROVED access.website = OPENEDX_COMPLETE_DOMAIN_NAME access.site = site - access.reason = "Created from bootsrap script" + access.reason = "Created from bootstrap script" access.save() application, _ = Application.objects.get_or_create( user=user, diff --git a/openedx_plugin_api/migrations/0001_initial.py b/openedx_plugin_api/migrations/0001_initial.py index c380b58..77fe791 100644 --- a/openedx_plugin_api/migrations/0001_initial.py +++ b/openedx_plugin_api/migrations/0001_initial.py @@ -1,8 +1,8 @@ +# coding=utf-8 from django.db import migrations, models class Migration(migrations.Migration): - initial = True dependencies = [] diff --git a/openedx_plugin_api/models.py b/openedx_plugin_api/models.py index 2e33c1c..e88a620 100644 --- a/openedx_plugin_api/models.py +++ b/openedx_plugin_api/models.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com diff --git a/openedx_plugin_api/settings/production.py b/openedx_plugin_api/settings/production.py index e092994..0395bc8 100644 --- a/openedx_plugin_api/settings/production.py +++ b/openedx_plugin_api/settings/production.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Common Pluggable Django App settings """ diff --git a/openedx_plugin_api/signals.py b/openedx_plugin_api/signals.py index 831bdcd..664a10d 100644 --- a/openedx_plugin_api/signals.py +++ b/openedx_plugin_api/signals.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com diff --git a/openedx_plugin_api/urls.py b/openedx_plugin_api/urls.py index 6ee5ab9..8d0b0ad 100644 --- a/openedx_plugin_api/urls.py +++ b/openedx_plugin_api/urls.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com diff --git a/openedx_plugin_api/waffle.py b/openedx_plugin_api/waffle.py index fc8ebc1..25e77ba 100644 --- a/openedx_plugin_api/waffle.py +++ b/openedx_plugin_api/waffle.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -108,7 +109,7 @@ def is_ready(): try: API_STUDENT_WAFFLE.is_enabled() return True - except Exception: + except Exception: # noqa: B902 return False @@ -119,7 +120,7 @@ def is_enabled(switch: WaffleSwitch) -> bool: """ try: return switch.is_enabled() - except Exception: + except Exception: # noqa: B902 return False @@ -181,13 +182,14 @@ def waffle_init(): if not is_ready(): log.warning( - "{django_app}: unable to verify initialization status of waffle switches. Try running manage.py lms {django_app}_init".format( + "{django_app}: unable to verify initialization status of waffle \ + switches. Try running manage.py lms {django_app}_init".format( django_app=WAFFLE_NAMESPACE ) ) return - for switch_name, switch_object in waffle_switches.items(): + for switch_name, _switch_object in waffle_switches.items(): try: this_switch = Switch.objects.get(name=switch_name) except ObjectDoesNotExist: diff --git a/openedx_plugin_cms/__init__.py b/openedx_plugin_cms/__init__.py index cbd8535..eee0e9b 100644 --- a/openedx_plugin_cms/__init__.py +++ b/openedx_plugin_cms/__init__.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Oct-2021 diff --git a/openedx_plugin_cms/admin.py b/openedx_plugin_cms/admin.py index 3a31007..4923a05 100644 --- a/openedx_plugin_cms/admin.py +++ b/openedx_plugin_cms/admin.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Oct-2021 diff --git a/openedx_plugin_cms/apps.py b/openedx_plugin_cms/apps.py index c4777bf..42e4f6e 100644 --- a/openedx_plugin_cms/apps.py +++ b/openedx_plugin_cms/apps.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Oct-2021 diff --git a/openedx_plugin_cms/data/course_audit.py b/openedx_plugin_cms/data/course_audit.json similarity index 100% rename from openedx_plugin_cms/data/course_audit.py rename to openedx_plugin_cms/data/course_audit.json diff --git a/openedx_plugin_cms/management/commands/course_audit.py b/openedx_plugin_cms/management/commands/course_audit.py index c3a74de..b8a559c 100644 --- a/openedx_plugin_cms/management/commands/course_audit.py +++ b/openedx_plugin_cms/management/commands/course_audit.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Dec-2021 diff --git a/openedx_plugin_cms/management/commands/eval_course.py b/openedx_plugin_cms/management/commands/eval_course.py index ce8525d..ca62484 100644 --- a/openedx_plugin_cms/management/commands/eval_course.py +++ b/openedx_plugin_cms/management/commands/eval_course.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Oct-2021 diff --git a/openedx_plugin_cms/management/commands/openedx_plugin_cms_init.py b/openedx_plugin_cms/management/commands/openedx_plugin_cms_init.py index 0915b2f..cc20e53 100644 --- a/openedx_plugin_cms/management/commands/openedx_plugin_cms_init.py +++ b/openedx_plugin_cms/management/commands/openedx_plugin_cms_init.py @@ -1,3 +1,4 @@ +# coding=utf-8 from django.core.management.base import BaseCommand from ...waffle import waffle_init diff --git a/openedx_plugin_cms/migrations/0001_initial.py b/openedx_plugin_cms/migrations/0001_initial.py index 22d5c73..7f46b0c 100644 --- a/openedx_plugin_cms/migrations/0001_initial.py +++ b/openedx_plugin_cms/migrations/0001_initial.py @@ -1,3 +1,4 @@ +# coding=utf-8 # Generated by Django 2.2.24 on 2021-10-19 20:57 """ Lawrence McDaniel - https://lawrencemcdaniel.com @@ -14,7 +15,6 @@ class Migration(migrations.Migration): - initial = True dependencies = [ @@ -82,7 +82,7 @@ class Migration(migrations.Migration): "url", models.URLField( blank=True, - help_text="Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b", + help_text="Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b", # noqa: B950 null=True, verbose_name="LMS URL", ), @@ -129,7 +129,7 @@ class Migration(migrations.Migration): "chapter_url", models.URLField( blank=True, - help_text="The Usage Key for the Chapter in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/graded_interactions", + help_text="The Usage Key for the Chapter in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/graded_interactions", # noqa: B950 max_length=255, null=True, ), @@ -142,7 +142,7 @@ class Migration(migrations.Migration): "sequential_url", models.URLField( blank=True, - help_text="The Usage Key for the Section in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/basic_questions", + help_text="The Usage Key for the Section in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/basic_questions", # noqa: B950 max_length=255, null=True, ), @@ -155,7 +155,7 @@ class Migration(migrations.Migration): "vertical_url", models.URLField( blank=True, - help_text="The Usage Key for the Vertical in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/vertical_d32bf9b2242c", + help_text="The Usage Key for the Vertical in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/vertical_d32bf9b2242c", # noqa: B950 max_length=255, null=True, ), @@ -177,7 +177,7 @@ class Migration(migrations.Migration): "update_version", opaque_keys.edx.django.models.UsageKeyField( blank=True, - help_text="Guid for the structure where this XBlock got its current field values. May point to a structure not in this structure's history (e.g., to a draft branch from which this version was published).", + help_text="Guid for the structure where this XBlock got its current field values. May point to a structure not in this structure's history (e.g., to a draft branch from which this version was published).", # noqa: B950 max_length=255, null=True, ), @@ -186,7 +186,7 @@ class Migration(migrations.Migration): "previous_version", opaque_keys.edx.django.models.UsageKeyField( blank=True, - help_text="Guid for the structure which previously changed this XBlock. (Will be the previous value of 'update_version'.)", + help_text="Guid for the structure which previously changed this XBlock. (Will be the previous value of 'update_version'.)", # noqa: B950 max_length=255, null=True, ), @@ -195,7 +195,7 @@ class Migration(migrations.Migration): "original_usage", opaque_keys.edx.django.models.UsageKeyField( blank=True, - help_text="If this block has been copied from a library using copy_from_template, points to the original block in the library", + help_text="If this block has been copied from a library using copy_from_template, points to the original block in the library", # noqa: B950 max_length=255, null=True, ), diff --git a/openedx_plugin_cms/migrations/0002_courseaudit.py b/openedx_plugin_cms/migrations/0002_courseaudit.py index 770a93c..4391fae 100644 --- a/openedx_plugin_cms/migrations/0002_courseaudit.py +++ b/openedx_plugin_cms/migrations/0002_courseaudit.py @@ -1,3 +1,4 @@ +# coding=utf-8 # Generated by Django 2.2.24 on 2021-12-15 01:50 from django.conf import settings @@ -9,7 +10,6 @@ class Migration(migrations.Migration): - dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ("openedx_plugin_cms", "0001_initial"), @@ -57,7 +57,7 @@ class Migration(migrations.Migration): "a_order", models.IntegerField( blank=True, - help_text="the sequence in which this block is presented in the course, based on the outline format in Course Management Studio.", + help_text="the sequence in which this block is presented in the course, based on the outline format in Course Management Studio.", # noqa: B950 null=True, verbose_name="Order", ), @@ -144,7 +144,7 @@ class Migration(migrations.Migration): "i_component_type", models.CharField( blank=True, - help_text="For problem types only: the kind of Xblock used. Examples: imageresponse, customresponse, optionresponse, formularesponse, numericalresponse.", + help_text="For problem types only: the kind of Xblock used. Examples: imageresponse, customresponse, optionresponse, formularesponse, numericalresponse.", # noqa: B950 max_length=255, null=True, verbose_name="Component Type", @@ -176,7 +176,7 @@ class Migration(migrations.Migration): "n_asset_type", models.CharField( blank=True, - help_text="The kind of file types referenced in any freeform html content in this block. Example: getting-started_x250.png", + help_text="The kind of file types referenced in any freeform html content in this block. Example: getting-started_x250.png", # noqa: B950 max_length=255, null=True, verbose_name="Asset Type", @@ -194,7 +194,7 @@ class Migration(migrations.Migration): "q_xml_filename", models.CharField( blank=True, - help_text="the full path to the xml file for this block, if it exists. Example: html/030e35c4756a4ddc8d40b95fbbfff4d4.xml", + help_text="the full path to the xml file for this block, if it exists. Example: html/030e35c4756a4ddc8d40b95fbbfff4d4.xml", # noqa: B950 max_length=255, null=True, verbose_name="XML Filename", diff --git a/openedx_plugin_cms/migrations/0003_auto_20211215_0428.py b/openedx_plugin_cms/migrations/0003_auto_20211215_0428.py index 7d85649..4e480f0 100644 --- a/openedx_plugin_cms/migrations/0003_auto_20211215_0428.py +++ b/openedx_plugin_cms/migrations/0003_auto_20211215_0428.py @@ -1,10 +1,10 @@ +# coding=utf-8 # Generated by Django 2.2.24 on 2021-12-15 04:28 from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ ("openedx_plugin_cms", "0002_courseaudit"), ] diff --git a/openedx_plugin_cms/migrations/0004_auto_20211215_1645.py b/openedx_plugin_cms/migrations/0004_auto_20211215_1645.py index f2bc70d..4aa76c2 100644 --- a/openedx_plugin_cms/migrations/0004_auto_20211215_1645.py +++ b/openedx_plugin_cms/migrations/0004_auto_20211215_1645.py @@ -1,10 +1,10 @@ +# coding=utf-8 # Generated by Django 2.2.24 on 2021-12-15 16:45 from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ ("openedx_plugin_cms", "0003_auto_20211215_0428"), ] @@ -25,7 +25,7 @@ class Migration(migrations.Migration): name="n_asset_type", field=models.TextField( blank=True, - help_text="The kind of file types referenced in any freeform html content in this block. Example: getting-started_x250.png", + help_text="The kind of file types referenced in any freeform html content in this block. Example: getting-started_x250.png", # noqa: B950 max_length=255, null=True, verbose_name="Asset Type", diff --git a/openedx_plugin_cms/migrations/__init__.py b/openedx_plugin_cms/migrations/__init__.py index 4cc7107..2f18199 100644 --- a/openedx_plugin_cms/migrations/__init__.py +++ b/openedx_plugin_cms/migrations/__init__.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Oct-2021 diff --git a/openedx_plugin_cms/models.py b/openedx_plugin_cms/models.py index b725f57..d5dd250 100644 --- a/openedx_plugin_cms/models.py +++ b/openedx_plugin_cms/models.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Oct-2021 @@ -26,21 +27,21 @@ def __str__(self): a_order = models.IntegerField( verbose_name="Order", - help_text="the sequence in which this block is presented in the course, based on the outline format in Course Management Studio.", + help_text="the sequence in which this block is presented in the course, based on the outline format in Course Management Studio.", # noqa: B950 blank=True, null=True, ) b_course = models.CharField( max_length=255, verbose_name="Course Display Name", - help_text="The display name of the course from Course Management Studio.", + help_text="The display name of the course from Course Management Studio.", # noqa: B950 blank=True, null=True, ) c_module = models.CharField( max_length=255, verbose_name="Course Module", - help_text="The display name of the Course Module (aka Chapter) in Course Management Studio.", + help_text="The display name of the Course Module (aka Chapter) in Course Management Studio.", # noqa: B950 blank=True, null=True, ) @@ -54,14 +55,14 @@ def __str__(self): e_unit = models.CharField( max_length=255, verbose_name="Course Unit", - help_text="The display name of the Course Unit (aka Subsection) in Course Management Studio.", + help_text="The display name of the Course Unit (aka Subsection) in Course Management Studio.", # noqa: B950 blank=True, null=True, ) e2_block_type = models.CharField( max_length=255, verbose_name="Block Type", - help_text="Type of XBlock. Usually chapter, sequential, vertical, html, discussion, or problem.", + help_text="Type of XBlock. Usually chapter, sequential, vertical, html, discussion, or problem.", # noqa: B950 blank=True, null=True, ) @@ -94,7 +95,7 @@ def __str__(self): i_component_type = models.CharField( max_length=255, verbose_name="Component Type", - help_text="For problem types only: the kind of Xblock used. Examples: imageresponse, customresponse, optionresponse, formularesponse, numericalresponse.", + help_text="For problem types only: the kind of Xblock used. Examples: imageresponse, customresponse, optionresponse, formularesponse, numericalresponse.", # noqa: B950 blank=True, null=True, ) @@ -106,7 +107,7 @@ def __str__(self): ) k_problem_weight = models.FloatField( verbose_name="Problem Weight", - help_text="The point potential of this problem based on the grading policy for the course.", + help_text="The point potential of this problem based on the grading policy for the course.", # noqa: B950 blank=True, null=True, ) @@ -118,14 +119,14 @@ def __str__(self): ) m_external_links = models.TextField( verbose_name="External Links", - help_text="A list of all links to sites outside of this Open edX platform installation", + help_text="A list of all links to sites outside of this Open edX platform installation", # noqa: B950 blank=True, null=True, ) n_asset_type = models.TextField( max_length=255, verbose_name="Asset Type", - help_text="The kind of file types referenced in any freeform html content in this block. Example: getting-started_x250.png", + help_text="The kind of file types referenced in any freeform html content in this block. Example: getting-started_x250.png", # noqa: B950 blank=True, null=True, ) @@ -144,7 +145,7 @@ def __str__(self): q_xml_filename = models.CharField( max_length=255, verbose_name="XML Filename", - help_text="the full path to the xml file for this block, if it exists. Example: html/030e35c4756a4ddc8d40b95fbbfff4d4.xml", + help_text="the full path to the xml file for this block, if it exists. Example: html/030e35c4756a4ddc8d40b95fbbfff4d4.xml", # noqa: B950 blank=True, null=True, ) @@ -158,7 +159,7 @@ def __str__(self): s_changed_by = models.ForeignKey( User, verbose_name="Changed By", - help_text="the username of the person who most recently published or modified this block.", + help_text="the username of the person who most recently published or modified this block.", # noqa: B950 on_delete=models.CASCADE, db_index=True, blank=True, @@ -190,7 +191,7 @@ def __str__(self): max_length=255, db_index=True, verbose_name="Location Usage Key", - help_text="Example: block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b", + help_text="Example: block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b", # noqa: B950 ) display_name = models.CharField(max_length=255) ordinal_position = models.IntegerField(blank=True, null=True) @@ -205,7 +206,7 @@ def __str__(self): verbose_name="LMS URL", blank=True, null=True, - help_text="Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b", + help_text="Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b", # noqa: B950 ) visible = models.BooleanField(default=True, verbose_name="Is Visible to Students") category = models.CharField( @@ -230,21 +231,21 @@ def __str__(self): chapter_location = UsageKeyField(max_length=255, db_index=True, blank=True, null=True) chapter_url = models.URLField( max_length=255, - help_text="The Usage Key for the Chapter in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/graded_interactions", + help_text="The Usage Key for the Chapter in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/graded_interactions", # noqa: B950 blank=True, null=True, ) sequential_location = UsageKeyField(max_length=255, db_index=True, blank=True, null=True) sequential_url = models.URLField( max_length=255, - help_text="The Usage Key for the Section in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/basic_questions", + help_text="The Usage Key for the Section in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/basic_questions", # noqa: B950 blank=True, null=True, ) vertical_location = UsageKeyField(max_length=255, db_index=True, blank=True, null=True) vertical_url = models.URLField( max_length=255, - help_text="The Usage Key for the Vertical in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/vertical_d32bf9b2242c", + help_text="The Usage Key for the Vertical in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/vertical_d32bf9b2242c", # noqa: B950 blank=True, null=True, ) @@ -263,20 +264,20 @@ def __str__(self): source_version = UsageKeyField(max_length=255, blank=True, null=True) update_version = UsageKeyField( max_length=255, - help_text="Guid for the structure where this XBlock got its current field values. May point to a structure not in this structure's history (e.g., to a draft branch from which this version was published).", + help_text="Guid for the structure where this XBlock got its current field values. May point to a structure not in this structure's history (e.g., to a draft branch from which this version was published).", # noqa: B950 blank=True, null=True, ) previous_version = UsageKeyField( max_length=255, - help_text="Guid for the structure which previously changed this XBlock. (Will be the previous value of 'update_version'.)", + help_text="Guid for the structure which previously changed this XBlock. (Will be the previous value of 'update_version'.)", # noqa: B950 blank=True, null=True, ) original_usage = UsageKeyField( max_length=255, - help_text="If this block has been copied from a library using copy_from_template, points to the original block in the library", + help_text="If this block has been copied from a library using copy_from_template, points to the original block in the library", # noqa: B950 null=True, blank=True, ) diff --git a/openedx_plugin_cms/settings/common.py b/openedx_plugin_cms/settings/common.py index b3589ae..d9a5683 100644 --- a/openedx_plugin_cms/settings/common.py +++ b/openedx_plugin_cms/settings/common.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Oct-2021 diff --git a/openedx_plugin_cms/settings/production.py b/openedx_plugin_cms/settings/production.py index 142c0f5..1e9fbb9 100644 --- a/openedx_plugin_cms/settings/production.py +++ b/openedx_plugin_cms/settings/production.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Oct-2021 diff --git a/openedx_plugin_cms/urls.py b/openedx_plugin_cms/urls.py index 4a9fe49..6267a70 100644 --- a/openedx_plugin_cms/urls.py +++ b/openedx_plugin_cms/urls.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Oct-2021 diff --git a/openedx_plugin_cms/views/__init__.py b/openedx_plugin_cms/views/__init__.py index 57fe8d6..1b0a60d 100644 --- a/openedx_plugin_cms/views/__init__.py +++ b/openedx_plugin_cms/views/__init__.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Nov-2021 diff --git a/openedx_plugin_cms/views/course_audit_html.py b/openedx_plugin_cms/views/course_audit_html.py index b5105f9..d29ff31 100644 --- a/openedx_plugin_cms/views/course_audit_html.py +++ b/openedx_plugin_cms/views/course_audit_html.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Lawrence McDaniel - https://lawrencemcdaniel.com Dec-2021 diff --git a/openedx_plugin_cms/waffle.py b/openedx_plugin_cms/waffle.py index 9d165e6..dde7f00 100644 --- a/openedx_plugin_cms/waffle.py +++ b/openedx_plugin_cms/waffle.py @@ -1,3 +1,4 @@ +# coding=utf-8 import logging from edx_toggles.toggles import WaffleSwitch @@ -28,7 +29,7 @@ def is_ready(): try: AUDIT_REPORT_WAFFLE.is_enabled() return True - except Exception: + except Exception: # noqa: B902 return False @@ -39,7 +40,7 @@ def is_enabled(switch: WaffleSwitch) -> bool: """ try: return switch.is_enabled() - except Exception: + except Exception: # noqa: B902 return False @@ -94,13 +95,14 @@ def waffle_init(): if not is_ready(): log.warning( - "{django_app}: unable to verify initialization status of waffle switches. Try running manage.py lms {django_app}_init".format( + "{django_app}: unable to verify initialization status of waffle \ + switches. Try running manage.py lms {django_app}_init".format( django_app=WAFFLE_NAMESPACE ) ) return - for switch_name, switch_object in waffle_switches.items(): + for switch_name, _switch_object in waffle_switches.items(): try: this_switch = Switch.objects.get(name=switch_name) except ObjectDoesNotExist: diff --git a/openedx_plugin_mobile_api/__init__.py b/openedx_plugin_mobile_api/__init__.py index 449aca5..31cb770 100644 --- a/openedx_plugin_mobile_api/__init__.py +++ b/openedx_plugin_mobile_api/__init__.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ # lint-amnesty, pylint: disable=django-not-configured Mobile API diff --git a/openedx_plugin_mobile_api/apps.py b/openedx_plugin_mobile_api/apps.py index ef2ddd9..e8664ca 100644 --- a/openedx_plugin_mobile_api/apps.py +++ b/openedx_plugin_mobile_api/apps.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com diff --git a/openedx_plugin_mobile_api/decorators.py b/openedx_plugin_mobile_api/decorators.py index 0375cc5..77b8631 100644 --- a/openedx_plugin_mobile_api/decorators.py +++ b/openedx_plugin_mobile_api/decorators.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Decorators for Mobile APIs. """ diff --git a/openedx_plugin_mobile_api/management/commands/openedx_plugin_mobile_api_init.py b/openedx_plugin_mobile_api/management/commands/openedx_plugin_mobile_api_init.py index 0915b2f..cc20e53 100644 --- a/openedx_plugin_mobile_api/management/commands/openedx_plugin_mobile_api_init.py +++ b/openedx_plugin_mobile_api/management/commands/openedx_plugin_mobile_api_init.py @@ -1,3 +1,4 @@ +# coding=utf-8 from django.core.management.base import BaseCommand from ...waffle import waffle_init diff --git a/openedx_plugin_mobile_api/middleware.py b/openedx_plugin_mobile_api/middleware.py index b95b525..389f145 100644 --- a/openedx_plugin_mobile_api/middleware.py +++ b/openedx_plugin_mobile_api/middleware.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -22,7 +23,6 @@ def __init__(self, get_response): self.get_response = get_response def __call__(self, request): - if request.path.startswith(MOBILE_USER_API_URL) and waffle_switches[OVERRIDE_MOBILE_USER_API_URL]: log.info( "openedx_plugin_api.middleware.APIRedirectMiddleware.__call__() redirecting host: {host} path: {path}".format( diff --git a/openedx_plugin_mobile_api/settings/common.py b/openedx_plugin_mobile_api/settings/common.py index 281cf20..d60b19e 100644 --- a/openedx_plugin_mobile_api/settings/common.py +++ b/openedx_plugin_mobile_api/settings/common.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Common Pluggable Django App settings diff --git a/openedx_plugin_mobile_api/urls.py b/openedx_plugin_mobile_api/urls.py index 826fa1a..bb7dc22 100644 --- a/openedx_plugin_mobile_api/urls.py +++ b/openedx_plugin_mobile_api/urls.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ URLs for mobile API """ diff --git a/openedx_plugin_mobile_api/users/serializers.py b/openedx_plugin_mobile_api/users/serializers.py index 5037b6d..1290ab1 100644 --- a/openedx_plugin_mobile_api/users/serializers.py +++ b/openedx_plugin_mobile_api/users/serializers.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Serializer for user API """ @@ -31,13 +32,13 @@ def get_course_enrollments(self, model): def get_dob(self, model): try: return model.ttb_profile.dob.strftime("%Y-%m-%d") - except Exception: + except Exception: # noqa: B902 return None def get_yob(self, model): try: return model.ttb_profile.yob - except Exception: + except Exception: # noqa: B902 return None class Meta: diff --git a/openedx_plugin_mobile_api/users/urls.py b/openedx_plugin_mobile_api/users/urls.py index 40c9b76..36e38c8 100644 --- a/openedx_plugin_mobile_api/users/urls.py +++ b/openedx_plugin_mobile_api/users/urls.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ URLs for user API """ diff --git a/openedx_plugin_mobile_api/users/views.py b/openedx_plugin_mobile_api/users/views.py index 0b8d6e5..dcc73c5 100644 --- a/openedx_plugin_mobile_api/users/views.py +++ b/openedx_plugin_mobile_api/users/views.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ Views for user API """ diff --git a/openedx_plugin_mobile_api/waffle.py b/openedx_plugin_mobile_api/waffle.py index f20911e..d267194 100644 --- a/openedx_plugin_mobile_api/waffle.py +++ b/openedx_plugin_mobile_api/waffle.py @@ -1,3 +1,4 @@ +# coding=utf-8 """ written by: Lawrence McDaniel https://lawrencemcdaniel.com @@ -38,7 +39,7 @@ def is_ready(): try: OVERRIDE_MOBILE_USER_API_URL_WAFFLE.is_enabled() return True - except Exception: + except Exception: # noqa: B902 return False @@ -49,7 +50,7 @@ def is_enabled(switch: WaffleSwitch) -> bool: """ try: return switch.is_enabled() - except Exception: + except Exception: # noqa: B902 return False @@ -90,7 +91,8 @@ def waffle_init(): # # assumption: edX guys have not and will not subclass Switch log.warning( - "{django_app}: get_waffle_model() not found. Importing Switch class directly from waffle.models".format( + "{django_app}: get_waffle_model() not found. Importing Switch \ + class directly from waffle.models".format( django_app=WAFFLE_NAMESPACE ) ) @@ -104,13 +106,14 @@ def waffle_init(): if not is_ready(): log.warning( - "{django_app}: unable to verify initialization status of waffle switches. Try running manage.py lms {django_app}_init".format( + "{django_app}: unable to verify initialization status of waffle \ + switches. Try running manage.py lms {django_app}_init".format( django_app=WAFFLE_NAMESPACE ) ) return - for switch_name, switch_object in waffle_switches.items(): + for switch_name, _switch_object in waffle_switches.items(): try: this_switch = Switch.objects.get(name=switch_name) except ObjectDoesNotExist: @@ -124,7 +127,8 @@ def waffle_init(): # - https://github.com/django-waffle/django-waffle/blob/master/waffle/models.py#L438 # - https://github.com/openedx/edx-toggles/blob/master/edx_toggles/toggles/internal/waffle/switch.py#L19 log.info( - "WaffleSwitch {switch_name} was previously initialized {and_is_or_is_not} enabled.".format( + "WaffleSwitch {switch_name} was previously initialized \ + {and_is_or_is_not} enabled.".format( switch_name=switch_name, and_is_or_is_not="and is" if this_switch.active else "but is not" ) ) From 13a3ce9a751719153aee1a3fafd5be837651fd00 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Thu, 30 Mar 2023 16:54:03 -0600 Subject: [PATCH 4/7] switch to 120 character line length in flake8 and black --- openedx_plugin/apps.py | 9 ++- openedx_plugin/dashboard/utils.py | 40 ++++------ openedx_plugin/dashboard/views.py | 43 +++++----- openedx_plugin/locale/utils.py | 10 +-- openedx_plugin/middleware.py | 5 +- openedx_plugin/migrations/0001_initial.py | 20 +++-- openedx_plugin/models.py | 19 +++-- openedx_plugin/waffle.py | 17 ++-- openedx_plugin_api/api.py | 9 ++- openedx_plugin_api/signals.py | 5 +- .../tests/test_edxapi_endpoints.py | 4 +- openedx_plugin_api/utils.py | 4 +- openedx_plugin_api/waffle.py | 17 ++-- openedx_plugin_cms/auditor.py | 4 +- openedx_plugin_cms/migrations/0001_initial.py | 47 ++++++++--- .../migrations/0002_courseaudit.py | 49 ++++++++---- .../migrations/0004_auto_20211215_1645.py | 7 +- openedx_plugin_cms/models.py | 78 ++++++++++++++----- openedx_plugin_cms/signals.py | 4 +- openedx_plugin_cms/utils.py | 8 +- openedx_plugin_cms/views/course_audit.py | 27 +++++-- openedx_plugin_cms/waffle.py | 17 ++-- openedx_plugin_mobile_api/apps.py | 2 +- openedx_plugin_mobile_api/middleware.py | 5 +- .../users/serializers.py | 4 +- openedx_plugin_mobile_api/waffle.py | 19 ++--- setup.py | 11 ++- 27 files changed, 302 insertions(+), 182 deletions(-) diff --git a/openedx_plugin/apps.py b/openedx_plugin/apps.py index 0bfe4fc..25a15c8 100644 --- a/openedx_plugin/apps.py +++ b/openedx_plugin/apps.py @@ -14,7 +14,11 @@ # see: https://github.com/openedx/edx-django-utils/blob/master/edx_django_utils/plugins/ from edx_django_utils.plugins import PluginSettings, PluginURLs -from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType, PluginSignals +from openedx.core.djangoapps.plugins.constants import ( + ProjectType, + SettingsType, + PluginSignals, +) # Signals (aka receivers) defined in https://github.com/openedx/openedx-events/blob/main/openedx_events/learning/signals.py @@ -142,7 +146,8 @@ def ready(self): log.info("{label} {version} is ready.".format(label=self.label, version=__version__)) log.info( "{label} found the following Django signals: {signals}".format( - label=self.label, signals=json.dumps(OPENEDX_SIGNALS, cls=PluginJSONEncoder, indent=4) + label=self.label, + signals=json.dumps(OPENEDX_SIGNALS, cls=PluginJSONEncoder, indent=4), ) ) waffle_init() diff --git a/openedx_plugin/dashboard/utils.py b/openedx_plugin/dashboard/utils.py index 458db17..18fd70b 100644 --- a/openedx_plugin/dashboard/utils.py +++ b/openedx_plugin/dashboard/utils.py @@ -39,28 +39,22 @@ def set_language_preference(request): language_param = request.GET.get("language") if language_param: log.info( - "set_language_preference() found language url param of \ - {language_param} in the request object".format( - language_param=language_param - ) + "set_language_preference() found language url param of " + " {language_param} in the request object".format(language_param=language_param) ) preferred_language = get_user_preference(request.user, LANGUAGE_KEY) if preferred_language: log.info( - "set_language_preference() found an existing saved language \ - preference for user {username} of {preferred_language}. \ - Ignoring url param.".format( - username=request.user.username, preferred_language=preferred_language - ) + "set_language_preference() found an existing saved language " + " preference for user {username} of {preferred_language}. " + " Ignoring url param.".format(username=request.user.username, preferred_language=preferred_language) ) return None else: log.info( - "set_language_preference() no language preference set for user \ - {username}".format( - username=request.user.username - ) + "set_language_preference() no language preference set for user " + " {username}".format(username=request.user.username) ) languages = released_languages() @@ -73,8 +67,8 @@ def set_language_preference(request): log.info("set_language_preference() no available language, exiting.") return None log.info( - "openedx_plugin.utils.set_language_preference() (2) detected \ - language param={language_param}. closest installed={closest_lang}".format( + "openedx_plugin.utils.set_language_preference() (2) detected " + " language param={language_param}. closest installed={closest_lang}".format( language_param=language_param, closest_lang=closest_lang ) ) @@ -82,20 +76,16 @@ def set_language_preference(request): return None else: log.info( - "set_language_preference() no language param found in the request\ - header for user {username}".format( - username=request.user.username - ) + "set_language_preference() no language param found in the request " + " header for user {username}".format(username=request.user.username) ) # 3.) try infer a language preference from the referring host referer = urlparse(request.META.get("HTTP_REFERER", "Direct")) referer_domain = referer.netloc log.info( - "set_language_preference() analyzing http referer {referer} with \ - domain {domain}".format( - referer=referer, domain=referer_domain - ) + "set_language_preference() analyzing http referer {referer} with domain" + " {domain}".format(referer=referer, domain=referer_domain) ) if referer_domain and referer_domain[:2].lower() == "mx": closest_lang = get_closest_released_language("es_MX") @@ -103,8 +93,8 @@ def set_language_preference(request): log.info("set_language_preference() no available language, quitting.") return None log.info( - "openedx_plugin.utils.set_language_preference() (3) detected \ - referer_domain={referer_domain}. closest installed={closest_lang}".format( + "openedx_plugin.utils.set_language_preference() (3) detected " + " referer_domain={referer_domain}. closest installed={closest_lang}".format( referer_domain=referer_domain, closest_lang=closest_lang ) ) diff --git a/openedx_plugin/dashboard/views.py b/openedx_plugin/dashboard/views.py index e9d7300..d82398b 100644 --- a/openedx_plugin/dashboard/views.py +++ b/openedx_plugin/dashboard/views.py @@ -71,10 +71,10 @@ def student_dashboard(request): log.info("student_dashboard() - initiating after referral {referer}".format(referer=referer.netloc)) log.info( - "student_dashboard() - user {username} is accessing example via \ - {platform}. Referer is {referer}. Received a language \ - preference of {language_param} and a pre-enrollment \ - course key of {enroll_in}".format( + "student_dashboard() - user {username} is accessing example via " + " {platform}. Referer is {referer}. Received a language " + " preference of {language_param} and a pre-enrollment course" + " key of {enroll_in}".format( username=username, platform=platform, referer=referer.netloc, @@ -100,11 +100,9 @@ def student_dashboard(request): course_key = CourseKey.from_string(enroll_in) except Exception: # noqa: B902 log.warning( - "student_dashboard() received an invalid CourseKey string in \ - the enroll url param. Ignoring. value was: \ - {enroll_in}".format( - enroll_in=enroll_in - ) + "student_dashboard() received an invalid CourseKey string in " + " the enroll url param. Ignoring. value was: " + " {enroll_in}".format(enroll_in=enroll_in) ) if course_key: @@ -112,11 +110,9 @@ def student_dashboard(request): course = modulestore().get_course(course_key) except Exception as e: # noqa: B902 log.warning( - "student_dashboard() encountered a handled exception \ - while attempting to initialize course object for \ - course key {enroll_in}. Exception: {e}".format( - enroll_in=enroll_in, e=e - ) + "student_dashboard() encountered a handled exception " + " while attempting to initialize course object for " + " course key {enroll_in}. Exception: {e}".format(enroll_in=enroll_in, e=e) ) try: @@ -124,9 +120,8 @@ def student_dashboard(request): CourseEnrollment.enroll(request.user, course_key=course_key) else: log.info( - "student_dashboard() user {username} is already enrolled in course {enroll_in}.".format( - username=request.user.username, enroll_in=enroll_in - ) + "student_dashboard() user {username} is already enrolled in" + " course {enroll_in}.".format(username=request.user.username, enroll_in=enroll_in) ) if course.has_started(): @@ -138,18 +133,16 @@ def student_dashboard(request): ) else: log.info( - "student_dashboard() course {enroll_in} has not yet \ - started. Redirecting the user to their \ - dashboard.".format( - enroll_in=enroll_in - ) + "student_dashboard() course {enroll_in} has not yet " + " started. Redirecting the user to their " + " dashboard.".format(enroll_in=enroll_in) ) except Exception as e: # noqa: B902 log.warning( - "student_dashboard() encountered a handled exception while\ - attempting to enroll user {username} in the course \ - {enroll_in}. Exception: {e}".format( + "student_dashboard() encountered a handled exception while " + " attempting to enroll user {username} in the course " + " {enroll_in}. Exception: {e}".format( username=request.user.username, enroll_in=enroll_in, e=e ) ) diff --git a/openedx_plugin/locale/utils.py b/openedx_plugin/locale/utils.py index 8a889ed..86c0177 100644 --- a/openedx_plugin/locale/utils.py +++ b/openedx_plugin/locale/utils.py @@ -51,8 +51,8 @@ def language_from_request(request): if request.user and request.user.is_authenticated: preferred_language = get_user_preference(request.user, LANGUAGE_KEY) log.info( - "language_from_request() found an existing language preference\ - of {preferred_language} for username {username}".format( + "language_from_request() found an existing language preference " + " of {preferred_language} for username {username}".format( preferred_language=preferred_language, username=request.user.username, ) @@ -71,9 +71,9 @@ def language_from_request(request): # if necessary, reduce the language setting to the most closely installed language closest_released_language = get_closest_released_language(preferred_language) log.info( - "language_from_request() found language param of \ - {preferred_language} in the request params. Closest released \ - language is {closest_released_language}".format( + "language_from_request() found language param of " + " {preferred_language} in the request params. Closest released " + " language is {closest_released_language}".format( preferred_language=preferred_language, closest_released_language=closest_released_language, ) diff --git a/openedx_plugin/middleware.py b/openedx_plugin/middleware.py index 2eb9bd9..9141a2a 100644 --- a/openedx_plugin/middleware.py +++ b/openedx_plugin/middleware.py @@ -43,9 +43,8 @@ def __call__(self, request): # require a Waffle flag to enable overrides of the stock openedx api functionality if request.path.startswith(OPENEDX_DJANGO_LOGIN_URL) and waffle_switches[OVERRIDE_OPENEDX_DJANGO_LOGIN]: log.info( - "openedx_plugin.middleware.RedirectDjangoAdminMiddleware.__call__() redirecting host: {host} path: {path}".format( - host=request.META["HTTP_HOST"], path=request.path - ) + "openedx_plugin.middleware.RedirectDjangoAdminMiddleware.__call__()" + " redirecting host: {host} path: {path}".format(host=request.META["HTTP_HOST"], path=request.path) ) template = loader.get_template("admin/login.html") context = Context({}) diff --git a/openedx_plugin/migrations/0001_initial.py b/openedx_plugin/migrations/0001_initial.py index 09adc7e..7a98207 100644 --- a/openedx_plugin/migrations/0001_initial.py +++ b/openedx_plugin/migrations/0001_initial.py @@ -40,7 +40,7 @@ class Migration(migrations.Migration): ("prod", "Production"), ], default="dev", - help_text="Type of Open edX environment in which this configuration will be used.", + help_text=("Type of Open edX environment in which this configuration" " will be used."), max_length=24, primary_key=True, serialize=False, @@ -107,7 +107,7 @@ class Migration(migrations.Migration): ("it-it", "Italiano (Italia)"), ("fr", "Français"), ], - help_text="A language code. Examples: en, en-US, es, es-419, es-MX", + help_text=("A language code. Examples: en, en-US, es, es-419, es-MX"), max_length=20, ), ), @@ -115,7 +115,11 @@ class Migration(migrations.Migration): "province", models.CharField( blank=True, - help_text="A sub-region for the language code. Example: for language code en-US valid possibles include TX, FL, CA, DC, KY, etc.", # noqa: B950 + help_text=( # noqa: B950 + "A sub-region for the language code. Example: for language" + " code en-US valid possibles include TX, FL, CA, DC, KY," + " etc." + ), max_length=20, ), ), @@ -123,7 +127,9 @@ class Migration(migrations.Migration): "site_url", models.URLField( default="https://example.org", - help_text="URL for for anchor tag for this language. Example: https://example.org/contact/", + help_text=( + "URL for for anchor tag for this language. Example:" " https://example.org/contact/" + ), ), ), ], @@ -174,20 +180,20 @@ class Migration(migrations.Migration): ("es-419", "Español (Latinoamérica)"), ("pt-pt", "Português (Portugal)"), ], - help_text="A language code. Examples: en, en-US, es, es-419, es-MX", + help_text=("A language code. Examples: en, en-US, es, es-419, es-MX"), max_length=20, ), ), ( "url", models.URLField( - help_text="URL for for anchor tag for this language. Example: https://example.org/contact/" + help_text=("URL for for anchor tag for this language. Example:" " https://example.org/contact/") ), ), ( "value", models.CharField( - help_text="The text value of this html element. Example: Contacto", + help_text=("The text value of this html element. Example: Contacto"), max_length=255, ), ), diff --git a/openedx_plugin/models.py b/openedx_plugin/models.py index 8af30a2..052e740 100644 --- a/openedx_plugin/models.py +++ b/openedx_plugin/models.py @@ -52,13 +52,16 @@ class Meta: max_length=20, blank=True, help_text=_( - "A sub-region for the language code. Example: for language code en-US valid possibles include TX, FL, CA, DC, KY, etc." + "A sub-region for the language code. Example: for language code " + " en-US valid possibles include TX, FL, CA, DC, KY, etc." ), ) site_url = models.URLField( default="https://example.org", blank=False, - help_text=_("URL for for anchor tag for this language. Example: https://example.org/contact/"), + help_text=_( + "URL for for anchor tag for this language. Example:" " https://example.org/contact/" + ), ) def __str__(self): @@ -67,9 +70,9 @@ def __str__(self): class Locale(TimeStampedModel): """ - Stores localized urls and translated html tag element values by language code - Used in conjunction with Mako templates to localize example specific page content - such as footer links. + Stores localized urls and translated html tag element values by language + code Used in conjunction with Mako templates to localize example + specific page content such as footer links. """ class Meta: @@ -88,7 +91,9 @@ class Meta: ) url = models.URLField( blank=False, - help_text=_("URL for for anchor tag for this language. Example: https://example.org/contact/"), + help_text=_( + "URL for for anchor tag for this language. Example:" " https://example.org/contact/" + ), ) value = models.CharField( blank=False, @@ -121,7 +126,7 @@ class Configuration(TimeStampedModel): choices=configuration_type, default=DEVELOP, unique=True, - help_text=_("Type of Open edX environment in which this configuration will be used."), + help_text=_("Type of Open edX environment in which this configuration " " will be used."), ) example_host = models.URLField(max_length=255, blank=True, help_text=_("the URL pointing to some server.")) diff --git a/openedx_plugin/waffle.py b/openedx_plugin/waffle.py index eb48e82..ae13a86 100644 --- a/openedx_plugin/waffle.py +++ b/openedx_plugin/waffle.py @@ -136,9 +136,8 @@ def waffle_init(): # # assumption: edX guys have not and will not subclass Switch log.warning( - "{django_app}: get_waffle_model() not found. Importing Switch class directly from waffle.models".format( - django_app=WAFFLE_NAMESPACE - ) + "{django_app}: get_waffle_model() not found. Importing Switch class" + " directly from waffle.models".format(django_app=WAFFLE_NAMESPACE) ) from waffle.models import Switch @@ -150,10 +149,8 @@ def waffle_init(): if not is_ready(): log.warning( - "{django_app}: unable to verify initialization status of waffle \ - switches. Try running manage.py lms {django_app}_init".format( - django_app=WAFFLE_NAMESPACE - ) + "{django_app}: unable to verify initialization status of waffle " + " switches. Try running manage.py lms {django_app}_init".format(django_app=WAFFLE_NAMESPACE) ) return @@ -171,8 +168,10 @@ def waffle_init(): # - https://github.com/django-waffle/django-waffle/blob/master/waffle/models.py#L438 # - https://github.com/openedx/edx-toggles/blob/master/edx_toggles/toggles/internal/waffle/switch.py#L19 log.info( - "WaffleSwitch {switch_name} was previously initialized {and_is_or_is_not} enabled.".format( - switch_name=switch_name, and_is_or_is_not="and is" if this_switch.active else "but is not" + "WaffleSwitch {switch_name} was previously initialized" + " {and_is_or_is_not} enabled.".format( + switch_name=switch_name, + and_is_or_is_not="and is" if this_switch.active else "but is not", ) ) else: diff --git a/openedx_plugin_api/api.py b/openedx_plugin_api/api.py index d11730d..b6e27b2 100644 --- a/openedx_plugin_api/api.py +++ b/openedx_plugin_api/api.py @@ -43,14 +43,19 @@ try: # for olive and later - from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.modulestore.django import ( + modulestore, + ) # lint-amnesty, pylint: disable=wrong-import-order from xmodule.course_module import DEFAULT_START_DATE, CourseFields except ImportError: # for backward compatibility with nutmeg and earlier from common.lib.xmodule.xmodule.modulestore.django import ( modulestore, ) # lint-amnesty, pylint: disable=wrong-import-order - from common.lib.xmodule.xmodule.course_module import DEFAULT_START_DATE, CourseFields + from common.lib.xmodule.xmodule.course_module import ( + DEFAULT_START_DATE, + CourseFields, + ) # our stuff from .utils import get_course_info diff --git a/openedx_plugin_api/signals.py b/openedx_plugin_api/signals.py index 664a10d..471085a 100644 --- a/openedx_plugin_api/signals.py +++ b/openedx_plugin_api/signals.py @@ -32,7 +32,6 @@ def listen_for_passing_grade(sender, user, course_id, **kwargs): # pylint: disa Listen for a signal indicating that the user has passed a course run. """ log.info( - "Enrolled student {username} has achieved a passing grade in the course {course_id} [{kwargs}]".format( - username=user.username, course_id=course_id, kwargs=kwargs - ) + "Enrolled student {username} has achieved a passing grade in the course" + " {course_id} [{kwargs}]".format(username=user.username, course_id=course_id, kwargs=kwargs) ) diff --git a/openedx_plugin_api/tests/test_edxapi_endpoints.py b/openedx_plugin_api/tests/test_edxapi_endpoints.py index 7b67f78..4016d88 100644 --- a/openedx_plugin_api/tests/test_edxapi_endpoints.py +++ b/openedx_plugin_api/tests/test_edxapi_endpoints.py @@ -16,7 +16,9 @@ from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase except ImportError: # for backward compatibility with nutmeg and earlier - from common.lib.xmodule.xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase + from common.lib.xmodule.xmodule.modulestore.tests.django_utils import ( + SharedModuleStoreTestCase, + ) class TestAPIEndpoints(SharedModuleStoreTestCase, APITestCase): diff --git a/openedx_plugin_api/utils.py b/openedx_plugin_api/utils.py index cd49a9c..7d1539c 100644 --- a/openedx_plugin_api/utils.py +++ b/openedx_plugin_api/utils.py @@ -26,7 +26,9 @@ try: # for olive and later - from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.modulestore.django import ( + modulestore, + ) # lint-amnesty, pylint: disable=wrong-import-order except ImportError: # for backward compatibility with nutmeg and earlier from common.lib.xmodule.xmodule.modulestore.django import ( diff --git a/openedx_plugin_api/waffle.py b/openedx_plugin_api/waffle.py index 25e77ba..e31868a 100644 --- a/openedx_plugin_api/waffle.py +++ b/openedx_plugin_api/waffle.py @@ -168,9 +168,8 @@ def waffle_init(): # # assumption: edX guys have not and will not subclass Switch log.warning( - "{django_app}: get_waffle_model() not found. Importing Switch class directly from waffle.models".format( - django_app=WAFFLE_NAMESPACE - ) + "{django_app}: get_waffle_model() not found. Importing Switch class" + " directly from waffle.models".format(django_app=WAFFLE_NAMESPACE) ) from waffle.models import Switch @@ -182,10 +181,8 @@ def waffle_init(): if not is_ready(): log.warning( - "{django_app}: unable to verify initialization status of waffle \ - switches. Try running manage.py lms {django_app}_init".format( - django_app=WAFFLE_NAMESPACE - ) + "{django_app}: unable to verify initialization status of waffle " + " switches. Try running manage.py lms {django_app}_init".format(django_app=WAFFLE_NAMESPACE) ) return @@ -203,8 +200,10 @@ def waffle_init(): # - https://github.com/django-waffle/django-waffle/blob/master/waffle/models.py#L438 # - https://github.com/openedx/edx-toggles/blob/master/edx_toggles/toggles/internal/waffle/switch.py#L19 log.info( - "WaffleSwitch {switch_name} was previously initialized {and_is_or_is_not} enabled.".format( - switch_name=switch_name, and_is_or_is_not="and is" if this_switch.active else "but is not" + "WaffleSwitch {switch_name} was previously initialized" + " {and_is_or_is_not} enabled.".format( + switch_name=switch_name, + and_is_or_is_not="and is" if this_switch.active else "but is not", ) ) else: diff --git a/openedx_plugin_cms/auditor.py b/openedx_plugin_cms/auditor.py index 10cc88d..2856c76 100644 --- a/openedx_plugin_cms/auditor.py +++ b/openedx_plugin_cms/auditor.py @@ -27,7 +27,9 @@ try: # for olive and later - from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.modulestore.django import ( + modulestore, + ) # lint-amnesty, pylint: disable=wrong-import-order except ImportError: # for backward compatibility with nutmeg and earlier from common.lib.xmodule.xmodule.modulestore.django import ( diff --git a/openedx_plugin_cms/migrations/0001_initial.py b/openedx_plugin_cms/migrations/0001_initial.py index 7f46b0c..4703216 100644 --- a/openedx_plugin_cms/migrations/0001_initial.py +++ b/openedx_plugin_cms/migrations/0001_initial.py @@ -62,7 +62,9 @@ class Migration(migrations.Migration): "location", opaque_keys.edx.django.models.UsageKeyField( db_index=True, - help_text="Example: block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b", + help_text=( + "Example:" " block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b" + ), max_length=255, verbose_name="Location Usage Key", ), @@ -82,7 +84,10 @@ class Migration(migrations.Migration): "url", models.URLField( blank=True, - help_text="Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b", # noqa: B950 + help_text=( + "Example:" + " https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b" # noqa: B950 + ), null=True, verbose_name="LMS URL", ), @@ -116,7 +121,7 @@ class Migration(migrations.Migration): "parent_url", models.URLField( blank=True, - help_text="The Usage Key for the Parent object in which this block is contained.", + help_text=("The Usage Key for the Parent object in which this block is" " contained."), max_length=255, null=True, ), @@ -129,7 +134,11 @@ class Migration(migrations.Migration): "chapter_url", models.URLField( blank=True, - help_text="The Usage Key for the Chapter in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/graded_interactions", # noqa: B950 + help_text=( + "The Usage Key for the Chapter in which this block is" + " contained. Example:" + " https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/graded_interactions" # noqa: B950 + ), max_length=255, null=True, ), @@ -142,7 +151,11 @@ class Migration(migrations.Migration): "sequential_url", models.URLField( blank=True, - help_text="The Usage Key for the Section in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/basic_questions", # noqa: B950 + help_text=( # noqa: B950 + "The Usage Key for the Section in which this block is" + " contained. Example:" + " https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/basic_questions" + ), max_length=255, null=True, ), @@ -155,7 +168,11 @@ class Migration(migrations.Migration): "vertical_url", models.URLField( blank=True, - help_text="The Usage Key for the Vertical in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/vertical_d32bf9b2242c", # noqa: B950 + help_text=( + "The Usage Key for the Vertical in which this block is" + " contained. Example:" + " https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/vertical_d32bf9b2242c" # noqa: B950 + ), max_length=255, null=True, ), @@ -177,7 +194,12 @@ class Migration(migrations.Migration): "update_version", opaque_keys.edx.django.models.UsageKeyField( blank=True, - help_text="Guid for the structure where this XBlock got its current field values. May point to a structure not in this structure's history (e.g., to a draft branch from which this version was published).", # noqa: B950 + help_text=( # noqa: B950 + "Guid for the structure where this XBlock got its current" + " field values. May point to a structure not in this" + " structure's history (e.g., to a draft branch from which" + " this version was published)." + ), max_length=255, null=True, ), @@ -186,7 +208,10 @@ class Migration(migrations.Migration): "previous_version", opaque_keys.edx.django.models.UsageKeyField( blank=True, - help_text="Guid for the structure which previously changed this XBlock. (Will be the previous value of 'update_version'.)", # noqa: B950 + help_text=( # noqa: B950 + "Guid for the structure which previously changed this" + " XBlock. (Will be the previous value of 'update_version'.)" + ), max_length=255, null=True, ), @@ -195,7 +220,11 @@ class Migration(migrations.Migration): "original_usage", opaque_keys.edx.django.models.UsageKeyField( blank=True, - help_text="If this block has been copied from a library using copy_from_template, points to the original block in the library", # noqa: B950 + help_text=( # noqa: B950 + "If this block has been copied from a library using" + " copy_from_template, points to the original block in the" + " library" + ), max_length=255, null=True, ), diff --git a/openedx_plugin_cms/migrations/0002_courseaudit.py b/openedx_plugin_cms/migrations/0002_courseaudit.py index 4391fae..a627783 100644 --- a/openedx_plugin_cms/migrations/0002_courseaudit.py +++ b/openedx_plugin_cms/migrations/0002_courseaudit.py @@ -57,7 +57,11 @@ class Migration(migrations.Migration): "a_order", models.IntegerField( blank=True, - help_text="the sequence in which this block is presented in the course, based on the outline format in Course Management Studio.", # noqa: B950 + help_text=( # noqa: B950 + "the sequence in which this block is presented in the" + " course, based on the outline format in Course Management" + " Studio." + ), null=True, verbose_name="Order", ), @@ -66,7 +70,7 @@ class Migration(migrations.Migration): "b_course", models.CharField( blank=True, - help_text="The display name of the course from Course Management Studio.", + help_text=("The display name of the course from Course Management" " Studio."), max_length=255, null=True, verbose_name="Course Display Name", @@ -76,7 +80,9 @@ class Migration(migrations.Migration): "c_module", models.CharField( blank=True, - help_text="The display name of the Course Module (aka Chapter) in Course Management Studio.", + help_text=( + "The display name of the Course Module (aka Chapter) in" " Course Management Studio." + ), max_length=255, null=True, verbose_name="Course Module", @@ -86,7 +92,7 @@ class Migration(migrations.Migration): "d_section", models.CharField( blank=True, - help_text="The display name of the Course Section in Course Management Studio.", + help_text=("The display name of the Course Section in Course" " Management Studio."), max_length=255, null=True, verbose_name="Course Section", @@ -96,7 +102,9 @@ class Migration(migrations.Migration): "e_unit", models.CharField( blank=True, - help_text="The display name of the Course Unit (aka Subsection) in Course Management Studio.", + help_text=( + "The display name of the Course Unit (aka Subsection) in" " Course Management Studio." + ), max_length=255, null=True, verbose_name="Course Unit", @@ -106,7 +114,9 @@ class Migration(migrations.Migration): "e2_block_type", models.CharField( blank=True, - help_text="Type of XBlock. Usually chapter, sequential, vertical, html, discussion, or problem.", + help_text=( + "Type of XBlock. Usually chapter, sequential, vertical," " html, discussion, or problem." + ), max_length=255, null=True, verbose_name="Block Type", @@ -135,7 +145,7 @@ class Migration(migrations.Migration): "h_number_graded_sections", models.IntegerField( blank=True, - help_text="The number of graded content blocks within this section.", + help_text=("The number of graded content blocks within this section."), null=True, verbose_name="Number of Graded Sections", ), @@ -144,7 +154,11 @@ class Migration(migrations.Migration): "i_component_type", models.CharField( blank=True, - help_text="For problem types only: the kind of Xblock used. Examples: imageresponse, customresponse, optionresponse, formularesponse, numericalresponse.", # noqa: B950 + help_text=( # noqa: B950 + "For problem types only: the kind of Xblock used. Examples:" + " imageresponse, customresponse, optionresponse," + " formularesponse, numericalresponse." + ), max_length=255, null=True, verbose_name="Component Type", @@ -163,7 +177,9 @@ class Migration(migrations.Migration): "k_problem_weight", models.FloatField( blank=True, - help_text="The point potential of this problem based on the grading policy for the course.", + help_text=( + "The point potential of this problem based on the grading" " policy for the course." + ), null=True, verbose_name="Problem Weight", ), @@ -176,7 +192,10 @@ class Migration(migrations.Migration): "n_asset_type", models.CharField( blank=True, - help_text="The kind of file types referenced in any freeform html content in this block. Example: getting-started_x250.png", # noqa: B950 + help_text=( # noqa: B950 + "The kind of file types referenced in any freeform html" + " content in this block. Example: getting-started_x250.png" + ), max_length=255, null=True, verbose_name="Asset Type", @@ -194,7 +213,11 @@ class Migration(migrations.Migration): "q_xml_filename", models.CharField( blank=True, - help_text="the full path to the xml file for this block, if it exists. Example: html/030e35c4756a4ddc8d40b95fbbfff4d4.xml", # noqa: B950 + help_text=( # noqa: B950 + "the full path to the xml file for this block, if it" + " exists. Example:" + " html/030e35c4756a4ddc8d40b95fbbfff4d4.xml" + ), max_length=255, null=True, verbose_name="XML Filename", @@ -205,7 +228,7 @@ class Migration(migrations.Migration): models.DateTimeField( blank=True, db_index=True, - help_text="The most recent publication or modification date of this block", + help_text=("The most recent publication or modification date of this" " block"), null=True, verbose_name="Publication Date", ), @@ -218,7 +241,7 @@ class Migration(migrations.Migration): "s_changed_by", models.ForeignKey( blank=True, - help_text="the username of the person who most recently published or modified this block.", + help_text=("the username of the person who most recently published or" " modified this block."), null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, diff --git a/openedx_plugin_cms/migrations/0004_auto_20211215_1645.py b/openedx_plugin_cms/migrations/0004_auto_20211215_1645.py index 4aa76c2..6448d40 100644 --- a/openedx_plugin_cms/migrations/0004_auto_20211215_1645.py +++ b/openedx_plugin_cms/migrations/0004_auto_20211215_1645.py @@ -15,7 +15,7 @@ class Migration(migrations.Migration): name="m_external_links", field=models.TextField( blank=True, - help_text="A list of all links to sites outside of this Open edX platform installation", + help_text=("A list of all links to sites outside of this Open edX platform" " installation"), null=True, verbose_name="External Links", ), @@ -25,7 +25,10 @@ class Migration(migrations.Migration): name="n_asset_type", field=models.TextField( blank=True, - help_text="The kind of file types referenced in any freeform html content in this block. Example: getting-started_x250.png", # noqa: B950 + help_text=( # noqa: B950 + "The kind of file types referenced in any freeform html content in" + " this block. Example: getting-started_x250.png" + ), max_length=255, null=True, verbose_name="Asset Type", diff --git a/openedx_plugin_cms/models.py b/openedx_plugin_cms/models.py index d5dd250..c9058bf 100644 --- a/openedx_plugin_cms/models.py +++ b/openedx_plugin_cms/models.py @@ -27,7 +27,10 @@ def __str__(self): a_order = models.IntegerField( verbose_name="Order", - help_text="the sequence in which this block is presented in the course, based on the outline format in Course Management Studio.", # noqa: B950 + help_text=( # noqa: B950 + "the sequence in which this block is presented in the course, based on the" + " outline format in Course Management Studio." + ), blank=True, null=True, ) @@ -41,7 +44,7 @@ def __str__(self): c_module = models.CharField( max_length=255, verbose_name="Course Module", - help_text="The display name of the Course Module (aka Chapter) in Course Management Studio.", # noqa: B950 + help_text=("The display name of the Course Module (aka Chapter) in Course Management" " Studio."), # noqa: B950 blank=True, null=True, ) @@ -55,14 +58,18 @@ def __str__(self): e_unit = models.CharField( max_length=255, verbose_name="Course Unit", - help_text="The display name of the Course Unit (aka Subsection) in Course Management Studio.", # noqa: B950 + help_text=( # noqa: B950 + "The display name of the Course Unit (aka Subsection) in Course Management" " Studio." + ), blank=True, null=True, ) e2_block_type = models.CharField( max_length=255, verbose_name="Block Type", - help_text="Type of XBlock. Usually chapter, sequential, vertical, html, discussion, or problem.", # noqa: B950 + help_text=( # noqa: B950 + "Type of XBlock. Usually chapter, sequential, vertical, html, discussion," " or problem." + ), blank=True, null=True, ) @@ -95,7 +102,10 @@ def __str__(self): i_component_type = models.CharField( max_length=255, verbose_name="Component Type", - help_text="For problem types only: the kind of Xblock used. Examples: imageresponse, customresponse, optionresponse, formularesponse, numericalresponse.", # noqa: B950 + help_text=( # noqa: B950 + "For problem types only: the kind of Xblock used. Examples: imageresponse," + " customresponse, optionresponse, formularesponse, numericalresponse." + ), blank=True, null=True, ) @@ -107,7 +117,7 @@ def __str__(self): ) k_problem_weight = models.FloatField( verbose_name="Problem Weight", - help_text="The point potential of this problem based on the grading policy for the course.", # noqa: B950 + help_text=("The point potential of this problem based on the grading policy for the" " course."), # noqa: B950 blank=True, null=True, ) @@ -119,14 +129,17 @@ def __str__(self): ) m_external_links = models.TextField( verbose_name="External Links", - help_text="A list of all links to sites outside of this Open edX platform installation", # noqa: B950 + help_text=("A list of all links to sites outside of this Open edX platform" " installation"), # noqa: B950 blank=True, null=True, ) n_asset_type = models.TextField( max_length=255, verbose_name="Asset Type", - help_text="The kind of file types referenced in any freeform html content in this block. Example: getting-started_x250.png", # noqa: B950 + help_text=( # noqa: B950 + "The kind of file types referenced in any freeform html content in this" + " block. Example: getting-started_x250.png" + ), blank=True, null=True, ) @@ -145,7 +158,10 @@ def __str__(self): q_xml_filename = models.CharField( max_length=255, verbose_name="XML Filename", - help_text="the full path to the xml file for this block, if it exists. Example: html/030e35c4756a4ddc8d40b95fbbfff4d4.xml", # noqa: B950 + help_text=( # noqa: B950 + "the full path to the xml file for this block, if it exists. Example:" + " html/030e35c4756a4ddc8d40b95fbbfff4d4.xml" + ), blank=True, null=True, ) @@ -159,7 +175,7 @@ def __str__(self): s_changed_by = models.ForeignKey( User, verbose_name="Changed By", - help_text="the username of the person who most recently published or modified this block.", # noqa: B950 + help_text=("the username of the person who most recently published or modified this" " block."), # noqa: B950 on_delete=models.CASCADE, db_index=True, blank=True, @@ -191,7 +207,9 @@ def __str__(self): max_length=255, db_index=True, verbose_name="Location Usage Key", - help_text="Example: block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b", # noqa: B950 + help_text=( # noqa: B950 + "Example:" " block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b" + ), ) display_name = models.CharField(max_length=255) ordinal_position = models.IntegerField(blank=True, null=True) @@ -206,7 +224,10 @@ def __str__(self): verbose_name="LMS URL", blank=True, null=True, - help_text="Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b", # noqa: B950 + help_text=( + "Example:" + " https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b" # noqa: B950 + ), ) visible = models.BooleanField(default=True, verbose_name="Is Visible to Students") category = models.CharField( @@ -224,28 +245,37 @@ def __str__(self): parent_location = UsageKeyField(max_length=255, db_index=True, blank=True, null=True) parent_url = models.URLField( max_length=255, - help_text="The Usage Key for the Parent object in which this block is contained.", + help_text=("The Usage Key for the Parent object in which this block is contained."), blank=True, null=True, ) chapter_location = UsageKeyField(max_length=255, db_index=True, blank=True, null=True) chapter_url = models.URLField( max_length=255, - help_text="The Usage Key for the Chapter in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/graded_interactions", # noqa: B950 + help_text=( # noqa: B950 + "The Usage Key for the Chapter in which this block is contained. Example:" + " https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/graded_interactions" + ), blank=True, null=True, ) sequential_location = UsageKeyField(max_length=255, db_index=True, blank=True, null=True) sequential_url = models.URLField( max_length=255, - help_text="The Usage Key for the Section in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/basic_questions", # noqa: B950 + help_text=( # noqa: B950 + "The Usage Key for the Section in which this block is contained. Example:" + " https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/basic_questions" + ), blank=True, null=True, ) vertical_location = UsageKeyField(max_length=255, db_index=True, blank=True, null=True) vertical_url = models.URLField( max_length=255, - help_text="The Usage Key for the Vertical in which this block is contained. Example: https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/vertical_d32bf9b2242c", # noqa: B950 + help_text=( # noqa: B950 + "The Usage Key for the Vertical in which this block is contained. Example:" + " https://dev.engineplatform.co.uk/courses/course-v1:edX+DemoX+Demo_Course/jump_to_id/vertical_d32bf9b2242c" + ), blank=True, null=True, ) @@ -264,20 +294,30 @@ def __str__(self): source_version = UsageKeyField(max_length=255, blank=True, null=True) update_version = UsageKeyField( max_length=255, - help_text="Guid for the structure where this XBlock got its current field values. May point to a structure not in this structure's history (e.g., to a draft branch from which this version was published).", # noqa: B950 + help_text=( # noqa: B950 + "Guid for the structure where this XBlock got its current field values. May" + " point to a structure not in this structure's history (e.g., to a draft" + " branch from which this version was published)." + ), blank=True, null=True, ) previous_version = UsageKeyField( max_length=255, - help_text="Guid for the structure which previously changed this XBlock. (Will be the previous value of 'update_version'.)", # noqa: B950 + help_text=( # noqa: B950 + "Guid for the structure which previously changed this XBlock. (Will be the" + " previous value of 'update_version'.)" + ), blank=True, null=True, ) original_usage = UsageKeyField( max_length=255, - help_text="If this block has been copied from a library using copy_from_template, points to the original block in the library", # noqa: B950 + help_text=( # noqa: B950 + "If this block has been copied from a library using copy_from_template," + " points to the original block in the library" + ), null=True, blank=True, ) diff --git a/openedx_plugin_cms/signals.py b/openedx_plugin_cms/signals.py index 18f97aa..28345ef 100644 --- a/openedx_plugin_cms/signals.py +++ b/openedx_plugin_cms/signals.py @@ -25,7 +25,9 @@ # for olive and later # see: https://discuss.openedx.org/t/django-plugin-app-works-with-some-django-signals-but-not-others/5949/3 from xmodule.modulestore.django import SignalHandler - from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.modulestore.django import ( + modulestore, + ) # lint-amnesty, pylint: disable=wrong-import-order except ImportError: # for backward compatibility with nutmeg and earlier from common.lib.xmodule.xmodule.modulestore.django import SignalHandler diff --git a/openedx_plugin_cms/utils.py b/openedx_plugin_cms/utils.py index e91905a..e0e8f06 100644 --- a/openedx_plugin_cms/utils.py +++ b/openedx_plugin_cms/utils.py @@ -30,11 +30,15 @@ try: # for olive and later from xmodule.modulestore.django import modulestore - from xmodule.course_module import CourseBlock # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.course_module import ( + CourseBlock, + ) # lint-amnesty, pylint: disable=wrong-import-order except ImportError: # for backward compatibility with nutmeg and earlier from common.lib.xmodule.xmodule.modulestore.django import modulestore - from common.lib.xmodule.xmodule.course_module import CourseBlock # lint-amnesty, pylint: disable=wrong-import-order + from common.lib.xmodule.xmodule.course_module import ( + CourseBlock, + ) # lint-amnesty, pylint: disable=wrong-import-order # our stuff from .models import CourseChangeLog diff --git a/openedx_plugin_cms/views/course_audit.py b/openedx_plugin_cms/views/course_audit.py index 3687662..199751a 100644 --- a/openedx_plugin_cms/views/course_audit.py +++ b/openedx_plugin_cms/views/course_audit.py @@ -48,11 +48,22 @@ try: # for olive and later - from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order - from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order - from xmodule.course_module import CourseBlock # lint-amnesty, pylint: disable=wrong-import-order - from xmodule.seq_module import SequenceBlock, SectionBlock # lint-amnesty, pylint: disable=wrong-import-order - from xmodule.vertical_block import VerticalBlock # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.modulestore.django import ( + modulestore, + ) # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.modulestore import ( + ModuleStoreEnum, + ) # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.course_module import ( + CourseBlock, + ) # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.seq_module import ( + SequenceBlock, + SectionBlock, + ) # lint-amnesty, pylint: disable=wrong-import-order + from xmodule.vertical_block import ( + VerticalBlock, + ) # lint-amnesty, pylint: disable=wrong-import-order from xmodule.unit_block import UnitBlock # Units are verticals. except ImportError: # for backward compatibility with nutmeg and earlier @@ -62,7 +73,9 @@ from common.lib.xmodule.xmodule.modulestore import ( ModuleStoreEnum, ) # lint-amnesty, pylint: disable=wrong-import-order - from common.lib.xmodule.xmodule.course_module import CourseBlock # lint-amnesty, pylint: disable=wrong-import-order + from common.lib.xmodule.xmodule.course_module import ( + CourseBlock, + ) # lint-amnesty, pylint: disable=wrong-import-order from common.lib.xmodule.xmodule.seq_module import ( SequenceBlock, SectionBlock, @@ -556,7 +569,7 @@ def plugin_cms_course_audit_refresh(request, course_id: str, **kwargs): with task_lock(oid="plugin_cms_course_audit_refresh", course_id=course_id) as acquired: if acquired: _plugin_cms_course_audit_refresh(course_id=course_id) - message = "Report data refresh process was successfully initiated for course_key: {course_id}".format( + message = "Report data refresh process was successfully initiated for course_key:" " {course_id}".format( course_id=course_id ) status = 204 diff --git a/openedx_plugin_cms/waffle.py b/openedx_plugin_cms/waffle.py index dde7f00..7640987 100644 --- a/openedx_plugin_cms/waffle.py +++ b/openedx_plugin_cms/waffle.py @@ -81,9 +81,8 @@ def waffle_init(): # # assumption: edX guys have not and will not subclass Switch log.warning( - "{django_app}: get_waffle_model() not found. Importing Switch class directly from waffle.models".format( - django_app=WAFFLE_NAMESPACE - ) + "{django_app}: get_waffle_model() not found. Importing Switch class" + " directly from waffle.models".format(django_app=WAFFLE_NAMESPACE) ) from waffle.models import Switch @@ -95,10 +94,8 @@ def waffle_init(): if not is_ready(): log.warning( - "{django_app}: unable to verify initialization status of waffle \ - switches. Try running manage.py lms {django_app}_init".format( - django_app=WAFFLE_NAMESPACE - ) + "{django_app}: unable to verify initialization status of waffle " + " switches. Try running manage.py lms {django_app}_init".format(django_app=WAFFLE_NAMESPACE) ) return @@ -116,8 +113,10 @@ def waffle_init(): # - https://github.com/django-waffle/django-waffle/blob/master/waffle/models.py#L438 # - https://github.com/openedx/edx-toggles/blob/master/edx_toggles/toggles/internal/waffle/switch.py#L19 log.info( - "WaffleSwitch {switch_name} was previously initialized {and_is_or_is_not} enabled.".format( - switch_name=switch_name, and_is_or_is_not="and is" if this_switch.active else "but is not" + "WaffleSwitch {switch_name} was previously initialized" + " {and_is_or_is_not} enabled.".format( + switch_name=switch_name, + and_is_or_is_not="and is" if this_switch.active else "but is not", ) ) else: diff --git a/openedx_plugin_mobile_api/apps.py b/openedx_plugin_mobile_api/apps.py index e8664ca..beee083 100644 --- a/openedx_plugin_mobile_api/apps.py +++ b/openedx_plugin_mobile_api/apps.py @@ -31,7 +31,7 @@ class MobileApiConfig(AppConfig): name = "openedx_plugin_mobile_api" verbose_name = "Modified LMS Mobile REST API Endpoint" - # See: https://edx.readthedocs.io/projects/edx-django-utils/en/latest/edx_django_utils.plugins.html + # See: https://edx.readthedocs.io/projects/edx-django-utils/en/latest/edx_django_utils.plugins.html # noqa: B950 plugin_app = { # mcdaniel Sep-2021 # this is how you inject a python list of urls into lms.urls.py diff --git a/openedx_plugin_mobile_api/middleware.py b/openedx_plugin_mobile_api/middleware.py index 389f145..5966d67 100644 --- a/openedx_plugin_mobile_api/middleware.py +++ b/openedx_plugin_mobile_api/middleware.py @@ -25,9 +25,8 @@ def __init__(self, get_response): def __call__(self, request): if request.path.startswith(MOBILE_USER_API_URL) and waffle_switches[OVERRIDE_MOBILE_USER_API_URL]: log.info( - "openedx_plugin_api.middleware.APIRedirectMiddleware.__call__() redirecting host: {host} path: {path}".format( - host=request.META["HTTP_HOST"], path=request.path - ) + "openedx_plugin_api.middleware.APIRedirectMiddleware.__call__()" + " redirecting host: {host} path: {path}".format(host=request.META["HTTP_HOST"], path=request.path) ) return redirect("/openedx_plugin/api/mobile/user") diff --git a/openedx_plugin_mobile_api/users/serializers.py b/openedx_plugin_mobile_api/users/serializers.py index 1290ab1..2b11635 100644 --- a/openedx_plugin_mobile_api/users/serializers.py +++ b/openedx_plugin_mobile_api/users/serializers.py @@ -26,7 +26,9 @@ def get_course_enrollments(self, model): api_version = self.context.get("api_version") return reverse( - "courseenrollment-detail", kwargs={"api_version": api_version, "username": model.username}, request=request + "courseenrollment-detail", + kwargs={"api_version": api_version, "username": model.username}, + request=request, ) def get_dob(self, model): diff --git a/openedx_plugin_mobile_api/waffle.py b/openedx_plugin_mobile_api/waffle.py index d267194..92eb79f 100644 --- a/openedx_plugin_mobile_api/waffle.py +++ b/openedx_plugin_mobile_api/waffle.py @@ -91,10 +91,8 @@ def waffle_init(): # # assumption: edX guys have not and will not subclass Switch log.warning( - "{django_app}: get_waffle_model() not found. Importing Switch \ - class directly from waffle.models".format( - django_app=WAFFLE_NAMESPACE - ) + "{django_app}: get_waffle_model() not found. Importing Switch " + " class directly from waffle.models".format(django_app=WAFFLE_NAMESPACE) ) from waffle.models import Switch @@ -106,10 +104,8 @@ class directly from waffle.models".format( if not is_ready(): log.warning( - "{django_app}: unable to verify initialization status of waffle \ - switches. Try running manage.py lms {django_app}_init".format( - django_app=WAFFLE_NAMESPACE - ) + "{django_app}: unable to verify initialization status of waffle " + " switches. Try running manage.py lms {django_app}_init".format(django_app=WAFFLE_NAMESPACE) ) return @@ -127,9 +123,10 @@ class directly from waffle.models".format( # - https://github.com/django-waffle/django-waffle/blob/master/waffle/models.py#L438 # - https://github.com/openedx/edx-toggles/blob/master/edx_toggles/toggles/internal/waffle/switch.py#L19 log.info( - "WaffleSwitch {switch_name} was previously initialized \ - {and_is_or_is_not} enabled.".format( - switch_name=switch_name, and_is_or_is_not="and is" if this_switch.active else "but is not" + "WaffleSwitch {switch_name} was previously initialized " + " {and_is_or_is_not} enabled.".format( + switch_name=switch_name, + and_is_or_is_not="and is" if this_switch.active else "but is not", ) ) else: diff --git a/setup.py b/setup.py index 4bc88bf..c31c073 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,10 @@ def load_readme() -> str: with io.open(os.path.join(HERE, "README.md"), "rt", encoding="utf8") as f: readme = f.read() # Replace img src for publication on pypi - return readme.replace("./doc/", "https://github.com/cookiecutter-openedx/cookiecutter-openedx-devops/raw/main/doc/") + return readme.replace( + "./doc/", + "https://github.com/cookiecutter-openedx/cookiecutter-openedx-devops/raw/main/doc/", + ) def load_about() -> Dict[str, str]: @@ -83,7 +86,7 @@ def is_requirement(line) -> bool: author="Lawrence McDaniel", author_email="lpm0073@gmail.com", url="https://github.com/cookiecutter-openedx/example-openedx-plugin", - download_url="https://github.com/cookiecutter-openedx/cookiecutter-openedx-devops.git", + download_url=("https://github.com/cookiecutter-openedx/cookiecutter-openedx-devops.git"), install_requires=load_requirements("requirements/common.in"), zip_safe=False, keywords="Django, Open edX, Plugin", @@ -95,7 +98,7 @@ def is_requirement(line) -> bool: "Framework :: Django :: 3.1", "Framework :: Django :: 3.2", "Intended Audience :: Developers", - "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", + "License :: OSI Approved :: GNU Affero General Public License v3 or later" " (AGPLv3+)", "Natural Language :: English", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", @@ -112,7 +115,7 @@ def is_requirement(line) -> bool: "lms.djangoapp": [ "openedx_plugin = openedx_plugin.apps:CustomPluginConfig", "openedx_plugin_api = openedx_plugin_api.apps:CustomPluginAPIConfig", - "openedx_plugin_mobile_api = openedx_plugin_mobile_api.apps:MobileApiConfig", + "openedx_plugin_mobile_api =" " openedx_plugin_mobile_api.apps:MobileApiConfig", ], "cms.djangoapp": [ "openedx_plugin_cms = openedx_plugin_cms.apps:CustomPluginCMSConfig", From 5e444c410e180ebaa0679a723653d72435c9cf53 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Thu, 30 Mar 2023 17:40:58 -0600 Subject: [PATCH 5/7] setup config for PyPi --- pyproject.toml | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 446077b..075d4df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,3 +14,60 @@ exclude = ''' | dist )/ ''' + +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta:__legacy__" + +#------------------------------------------------------------------------------ +# PyPi meta data +#------------------------------------------------------------------------------ +[project] +name = "openedx-plugin-example" +version = "0.1.1" +authors = [ + { name="Lawrence McDaniel", email="lpm0073@gmail.com" } +] +description = "A Django plugin to enhance feature set of base Open edX platform" +readme = "README.md" +requires-python = ">=3.8" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] +dependencies = [ + "Django>=3.2,<=3.3", + "validators", + "django-environ" +] + +keywords = ["Python", "Django", "Open edX", "Plugin", "REST API"] + +[project.urls] +Homepage = "https://github.com/cookiecutter-openedx/openedx-plugin-example" +"Bug Tracker" = "https://github.com/cookiecutter-openedx/openedx-plugin-example/issues" +Repository = "https://github.com/cookiecutter-openedx/openedx-plugin-example" + +#------------------------------------------------------------------------------ +# see: https://setuptools.pypa.io/en/latest/userguide/dependency_management.html +#------------------------------------------------------------------------------ +[project.optional-dependencies] +local = [ + "pre-commit", + "black", + "flake8", + "ipython" +] + +#------------------------------------------------------------------------------ +# see: https://setuptools.pypa.io/en/latest/userguide/entry_point.html +#------------------------------------------------------------------------------ +[project.entry-points."lms.djangoapp"] +memberpress_client = "memberpress_client.apps:MemberPressPluginConfig" +openedx_plugin = "openedx_plugin.apps:CustomPluginConfig" +openedx_plugin_api = "openedx_plugin_api.apps:CustomPluginAPIConfig" +openedx_plugin_mobile_api = "openedx_plugin_mobile_api.apps:MobileApiConfig" + +[project.entry-points."cms.djangoapp"] +openedx_plugin_cms = "openedx_plugin_cms.apps:CustomPluginCMSConfig" From e48ac71ed30c5251838e6e795796412ba6e0cf26 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Thu, 30 Mar 2023 17:55:39 -0600 Subject: [PATCH 6/7] set license --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 075d4df..4bce068 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,10 +30,11 @@ authors = [ ] description = "A Django plugin to enhance feature set of base Open edX platform" readme = "README.md" +license = "GPL-3.0-or-later" requires-python = ">=3.8" classifiers = [ "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", + "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Operating System :: OS Independent", ] dependencies = [ From 85c137f7391b6d55c94d700a4ada528a3ac9e6b6 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Thu, 30 Mar 2023 18:14:10 -0600 Subject: [PATCH 7/7] release notes and version bump to 0.1.3 --- CHANGELOG.md | 3 +++ openedx_plugin/version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a06831..e4f154f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - enhance setup.up setup() meta data - bump classifier from alpha to beta - refactor in order to make repo more condusive to uploading to PyPi +- version bumps to black, flake8 and their supporting plugins +- line entire code base for PEP 263 and B950 compliance +- setup pyproject.toml for PyPi publishing ## [0.1.2] (2022-3-29) diff --git a/openedx_plugin/version.py b/openedx_plugin/version.py index 48509da..8f1208b 100644 --- a/openedx_plugin/version.py +++ b/openedx_plugin/version.py @@ -7,4 +7,4 @@ usage: semantic version control for openedx_plugin """ -__version__ = "0.1.1" +__version__ = "0.1.3" diff --git a/pyproject.toml b/pyproject.toml index 4bce068..f15f2db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ build-backend = "setuptools.build_meta:__legacy__" #------------------------------------------------------------------------------ [project] name = "openedx-plugin-example" -version = "0.1.1" +version = "0.1.3" authors = [ { name="Lawrence McDaniel", email="lpm0073@gmail.com" } ]