commit c7f0c6a1c48ef5250fe29e8a7c1480ef41a458c7
Author: Niklas Elsbrock
Date: Sat Jul 3 17:31:10 2021 +0200
Initialisierung: Übertragung aus altem Repository
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..cb103a8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+/NateMan.egg-info/
+/build/
+/dist/
+/instance/
+/venv/
+
+# pycache-Verzeichnisse überall ignorieren
+__pycache__/
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f288702
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 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 General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is 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. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+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.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ 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 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. Use with the GNU Affero General Public License.
+
+ 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 Affero 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 special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU 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 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 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 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 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ 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 GPL, see
+ .
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..e474582
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,5 @@
+include wsgi.py
+graft nateman/resources
+graft nateman/static
+graft nateman/templates
+global-exclude *.pyc
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..a0f53a0
--- /dev/null
+++ b/README.md
@@ -0,0 +1,20 @@
+# NateMan
+
+NateMan (**Na**chschreib**te**rmin-**Man**ager) ist eine Webanwendung zur Koordination von Klausuren gymnasialer Oberstufen. Klausurpläne können aus verschiedenen Formaten (z.B. Kurs42, bald auch UNTIS) importiert oder direkt im Webinterface erstellt werden und sind anschließend öffentlich einsehbar. Über eigene Lehrerkonten können Klausuraufsichten nach einer Klausur Versäumnisse eintragen. Beratungslehrer und Oberstufenkoordinatoren können diese Bearbeitungen einsehen, bei Bedarf ändern und Atteste für Versäumnisse eintragen.
+
+
+
+## Funktionen
+* Import und Bearbeitung von Klausurlisten (aus Kurs42, bald auch UNTIS)
+* administrierbares Anmeldesystem für Lehrkräfte
+* Eintragung von Klausurversäumnissen und Attesten
+* Einsicht und Export (Excel) von Versäumnislisten
+* Klausurerinnerungen per E-Mail
+* öffentlich einsehbare Klausurpläne
+
+## Installation
+NateMan kann wie jede andere Flask-App installiert werden.
+
+Nach dem ersten Start wird automatisch eine ausführlich kommentierte Konfigurationsdatei `config.yml` angelegt. Hier müssen die Einträge `server-name` sowie `uses-ssl` entsprechend angepasst werden. Für die Nutzung des E-Mail-Versands müssen auch die Einträge unter `mail` geändert werden.
+
+Die erste Einrichtung erfolgt über den CLI-Befehl `nateman`. Um ein neues Lehrerkonto mit Administratorrechten anzulegen, führen Sie `nateman add-lehrer --admin ` aus. Mit diesem Konto können Sie sich anschließend im Webinterface anmelden.
diff --git a/logo-sources/icon-apple.svg b/logo-sources/icon-apple.svg
new file mode 100644
index 0000000..baf9917
--- /dev/null
+++ b/logo-sources/icon-apple.svg
@@ -0,0 +1,5 @@
+
+
+
+ N
+
diff --git a/logo-sources/logo.svg b/logo-sources/logo.svg
new file mode 100644
index 0000000..d42345b
--- /dev/null
+++ b/logo-sources/logo.svg
@@ -0,0 +1,5 @@
+
+
+
+ N
+
diff --git a/nateman/__init__.py b/nateman/__init__.py
new file mode 100644
index 0000000..a688a42
--- /dev/null
+++ b/nateman/__init__.py
@@ -0,0 +1,166 @@
+# NateMan – Nachschreibtermin-Manager
+# __init__.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Enthält die Initialisierungsfunktion der NateMan-Webapp.
+"""
+
+import locale
+import logging.handlers
+import os
+import sys
+from datetime import datetime
+
+import sqlalchemy
+from flask import abort, Flask, request, send_from_directory
+from flask.logging import default_handler
+from werkzeug.utils import find_modules, import_string
+
+from . import util
+from .config_manager import config_file_exists, create_config_file, config
+from .config_manager import read_config_file
+from .models import Klausur, Klausurteilnahme, Koopschule, Lehrer, Schueler, Stufe, db
+
+
+def create_app() -> Flask:
+ """Initialisiert die NateMan-Webapp"""
+
+ app: Flask = Flask(__name__, instance_relative_config=True)
+
+ # Sprache festlegen
+ locale.setlocale(locale.LC_ALL, "")
+
+ setup_logging(app)
+
+ # falls nötig, instance-Ordner anlegen
+ os.makedirs(app.instance_path, exist_ok=True)
+
+ load_config(app)
+
+ secret_key = read_or_generate_secret_key(app)
+
+ configure_jinja(app)
+
+ # Falls in der Konfiguration aktiviert, Datei-Logging einrichten
+ if config["logging"].get("syslog", False):
+ setup_syslog(app)
+
+ # Logging-Level ändern
+ app.logger.setLevel(config["logging"]["level"])
+
+ # Flask und Flask-SQLAlchemy konfigurieren
+ app.config.from_mapping(
+ SERVER_NAME=config["server-name"],
+ SECRET_KEY=secret_key,
+ PREFERRED_URL_SCHEME="https" if config["uses-ssl"] else "http",
+ SESSION_COOKIE_SECURE=config["uses-ssl"],
+ MAX_CONTENT_LENGTH=16 * 1024 * 1024, # 16 MiB upload limit
+ SQLALCHEMY_DATABASE_URI="sqlite:///" + os.path.join(app.instance_path, "nateman.sqlite3"),
+ SQLALCHEMY_TRACK_MODIFICATIONS=False
+ )
+
+ db.init_app(app)
+ db.create_all(app=app)
+
+ # Blueprints registrieren
+ register_blueprints(app)
+
+ return app
+
+
+def setup_logging(app: Flask):
+ stdout_handler = logging.StreamHandler(sys.stdout)
+ formatter = logging.Formatter(
+ fmt="[%(asctime)s | %(levelname)s]: %(message)s"
+ )
+ stdout_handler.setFormatter(formatter)
+ app.logger.removeHandler(default_handler)
+ app.logger.addHandler(stdout_handler)
+
+
+def load_config(app: Flask):
+ """
+ Liest die Konfigurationsdatei.
+ Falls keine vorhanden ist, erstellt eine und beendet anschließend NateMan.
+ """
+ if not config_file_exists(app):
+ app.logger.critical("Die Konfigurationsdatei konnte nicht gefunden werden, erstellt eine neue...")
+ config_path = create_config_file(app)
+ app.logger.critical(f"Da die Konfigurationsdatei nicht gefunden werden konnte, "
+ f"wurde eine neue erstellt ({config_path}). NateMan wird nun beendet.")
+ sys.exit(1)
+
+ # Konfigurationsdatei laden
+ read_config_file(app)
+
+
+def read_or_generate_secret_key(app: Flask) -> bytes:
+ """ Liest den Secret Key aus bzw. generiert ihn, falls noch keiner vorhanden ist. """
+ secret_key_path = os.path.join(app.instance_path, "SECRET_KEY")
+
+ if not os.path.isfile(secret_key_path):
+ with open(os.open(secret_key_path, os.O_WRONLY | os.O_CREAT, mode=0o600), "wb") as file:
+ secret_key = os.urandom(128)
+ file.write(secret_key)
+ else:
+ with open(secret_key_path, "rb") as file:
+ secret_key = file.read()
+
+ return secret_key
+
+
+def configure_jinja(app: Flask):
+ app.jinja_env.globals.update(
+ nateman_config=config,
+ util=util,
+ sqlalchemy=sqlalchemy,
+ datetime=datetime,
+ db=db,
+ Klausurteilnahme=Klausurteilnahme,
+ Stufe=Stufe,
+ Schueler=Schueler,
+ Lehrer=Lehrer,
+ Klausur=Klausur,
+ Koopschule=Koopschule
+ )
+ app.jinja_env.trim_blocks = True
+ app.jinja_env.lstrip_blocks = True
+ app.jinja_env.strip_trailing_newlines = False
+
+
+def setup_syslog(app: Flask):
+ """ Erstellt Logging-Handler zum loggen in Syslog. """
+ file_handler = logging.handlers.SysLogHandler(address="/dev/log")
+ file_formatter = logging.Formatter(fmt="nateman: [%(levelname)s] %(message)s")
+ file_handler.setFormatter(file_formatter)
+ app.logger.addHandler(file_handler)
+
+
+def register_blueprints(app: Flask):
+ """ Registriert die Flask-Blueprints """
+ from . import blueprints
+ from .blueprints import admin, auth, error, fileio, info, klausuren, schueler
+ from .blueprints.admin import lehrer as admin_lehrer
+ app.register_blueprint(blueprints.bp)
+ app.register_blueprint(admin.bp)
+ app.register_blueprint(admin_lehrer.bp, name="admin.lehrer")
+ app.register_blueprint(auth.bp)
+ app.register_blueprint(error.bp)
+ app.register_blueprint(fileio.bp)
+ app.register_blueprint(info.bp)
+ app.register_blueprint(klausuren.bp)
+ app.register_blueprint(schueler.bp)
diff --git a/nateman/assigner.py b/nateman/assigner.py
new file mode 100644
index 0000000..ca82ee6
--- /dev/null
+++ b/nateman/assigner.py
@@ -0,0 +1,186 @@
+# NateMan – Nachschreibtermin-Manager
+# assigner.py
+# Copyright © 2020 Johannes Bingel
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+# Zuordenen Methode
+from typing import List
+
+
+def iscoopLk(kurs: List):
+ for k in kurs:
+ if k.schueler.stammschule is not None:
+ return True
+ return False
+
+
+def zuordnen(k_schueler):
+ # initziert Variablen
+ termin_1_kurse: [int, int] = []
+ termin_2_kurse: [int, int] = []
+
+ probleme_kurse = []
+
+ termin_1_kurse_s = []
+ termin_2_kurse_s = []
+ probleme_kurse_s = []
+
+ if len(k_schueler) != 0:
+ s_list = [[k_schueler.pop(0)]]
+
+ # Ordnet die Schüler den ihren Kursen zu
+ i = 0
+
+ for s in k_schueler:
+ while i < len(s_list):
+ if s.klausur.id == s_list[i][0].klausur.id:
+ s_list[i].append(s)
+ break
+ i += 1
+ else:
+ s_list.append([s])
+ i = 0
+ del i
+
+ # Findet und speichert die Konflikte in ein Dictionary
+ h_list = []
+
+ dic = {}
+
+ i = 0
+ i2 = 0
+ i3 = 0
+ i4 = 0
+
+ while i < len(s_list):
+ while i2 < len(s_list[i]):
+ while i3 < len(s_list):
+ while i4 < len(s_list[i3]):
+ if s_list[i][i2].schueler == s_list[i3][i4].schueler and i != i3 and str(i3) not in h_list:
+ h_list.append(str(i3))
+ i4 += 1
+ i3 += 1
+ i4 = 0
+ i2 += 1
+ i3 = 0
+ if h_list:
+ dic[str(i)] = h_list
+ h_list = []
+ i += 1
+ i2 = 0
+
+ del i
+ del i2
+ del i3
+ del i4
+
+ if dic != {}:
+
+ # Fügt die LKs Termin 1 zu
+ i = 0
+
+ while i < len(s_list):
+ if iscoopLk(s_list[i]) and str(i) in dic:
+ termin_1_kurse.append(str(i))
+ i += 1
+
+ while i < len(s_list):
+ if s_list[i][0].klausur.kursname[-2] == "L" and str(i) not in termin_1_kurse and str(i) in dic:
+ termin_1_kurse.append(str(i))
+ i += 1
+
+ del i
+
+ # Ordnet die LKs Fest ein
+ i = 0
+
+ while i < len(termin_1_kurse):
+ if str(i) not in termin_2_kurse:
+ for kurs in dic[termin_1_kurse[i]]:
+ if not (kurs in termin_2_kurse):
+ termin_2_kurse.append(kurs)
+ i += 1
+ else:
+ termin_1_kurse.remove(str(i))
+
+ i2 = 0
+
+ if not termin_1_kurse:
+ for d in dic:
+ termin_1_kurse.append(d)
+ break
+
+ # Füllt die Termine
+ finished = False
+ while not finished:
+ while not (i >= len(termin_1_kurse) and i2 >= len(termin_2_kurse)):
+ if i < len(termin_1_kurse):
+ for kurs in dic[termin_1_kurse[i]]:
+ if kurs in termin_1_kurse[:i]:
+ probleme_kurse.append(termin_1_kurse.pop(i))
+ break
+ else:
+ for kurs in dic[termin_1_kurse[i]]:
+ if not (kurs in termin_2_kurse):
+ termin_2_kurse.append(kurs)
+ i += 1
+
+ if i2 < len(termin_2_kurse):
+ for kurs in dic[termin_2_kurse[i2]]:
+ if kurs in termin_2_kurse[:i2]:
+ probleme_kurse.append(termin_2_kurse.pop(i2))
+ break
+ else:
+ for kurs in dic[termin_2_kurse[i2]]:
+ if not (kurs in termin_1_kurse):
+ termin_1_kurse.append(kurs)
+ i2 += 1
+ probleme_kurse = list(set(probleme_kurse))
+
+ for kurs in dic:
+ if kurs not in termin_1_kurse and kurs not in termin_2_kurse \
+ and kurs not in probleme_kurse:
+ termin_2_kurse.append(kurs)
+ break
+ else:
+ finished = True
+
+ # Ordnet die nicht problematischen Kurse zu
+
+ i = 0
+ while i < len(s_list):
+ if str(i) not in termin_1_kurse and str(i) not in termin_2_kurse and str(i) not in probleme_kurse:
+ termin_1_kurse.append(str(i))
+ i += 1
+
+ for kurs in termin_1_kurse:
+ for s in s_list[int(kurs)]:
+ termin_1_kurse_s.append(s)
+
+ for kurs in termin_2_kurse:
+ for s in s_list[int(kurs)]:
+ termin_2_kurse_s.append(s)
+
+ for kurs in probleme_kurse:
+ for s in s_list[int(kurs)]:
+ probleme_kurse_s.append(s)
+
+ k_schueler.insert(0, s_list[0][0])
+
+ # Ruft die Methode rekursiv auf bis keine Problemkurse vorhanden sind
+ if not probleme_kurse_s:
+ return [termin_1_kurse_s, termin_2_kurse_s]
+ else:
+ return [termin_1_kurse_s] + [termin_2_kurse_s] + zuordnen(probleme_kurse_s)
diff --git a/nateman/blueprints/__init__.py b/nateman/blueprints/__init__.py
new file mode 100644
index 0000000..37f7f47
--- /dev/null
+++ b/nateman/blueprints/__init__.py
@@ -0,0 +1,33 @@
+# NateMan – Nachschreibtermin-Manager
+# blueprints/__init__.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Index-Blueprint
+"""
+
+from flask import Blueprint, g, redirect, url_for, render_template
+
+bp = Blueprint("index", __name__)
+
+
+@bp.route("/")
+def index():
+ """ Startseite (Pfad ``/``, leitet bei angemeldetem Lehrer auf Klausurseite um) """
+ if g.lehrer is not None:
+ return redirect(url_for("klausuren.mine"), code=303)
+ else:
+ return render_template("index/index.html.j2")
diff --git a/nateman/blueprints/admin/__init__.py b/nateman/blueprints/admin/__init__.py
new file mode 100644
index 0000000..c59afc9
--- /dev/null
+++ b/nateman/blueprints/admin/__init__.py
@@ -0,0 +1,69 @@
+# NateMan – Nachschreibtermin-Manager
+# blueprints/admin/__init__.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Administrations-Blueprint
+"""
+
+from flask import Blueprint, flash, g, redirect, render_template, request, url_for, current_app
+from sqlalchemy.exc import StatementError
+
+from ..auth import admin_required
+from ...models import db
+
+bp = Blueprint("admin", __name__, url_prefix="/admin")
+
+
+@bp.route("/")
+@admin_required
+def index():
+ """ enthält Links zur Administration (Seite *Administration*)"""
+ return render_template("admin/index.html.j2")
+
+
+@bp.route("/sql-access", methods=("GET", "POST"))
+@admin_required
+def sql_access():
+ """ SQL-Zugriffsseite """
+ reload_response = redirect(url_for(".sql_access"), code=303)
+
+ if request.method != "POST":
+ return render_template("admin/sql_access.html.j2", query="", result=None)
+
+ # ELSE
+
+ query = request.form["query"].strip()
+
+ if not query:
+ flash("Bitte geben Sie eine SQL-Abfrage ein.", "error")
+ return reload_response
+
+ # Query ausführen
+ try:
+ result = db.session.execute(query)
+ except StatementError as exc:
+ flash(f"Die SQL-Abfrage konnte nicht ausgeführt werden.\n\nFehlerbeschreibung:\n{exc.orig}", "error")
+ return render_template("admin/sql_access.html.j2", query=query, result=None)
+
+ if not result.returns_rows:
+ db.session.commit()
+
+ logged_query = query.replace('\r\n', ' ').replace('\n', ' ')
+ current_app.logger.info(f"{g.lehrer} hat eine SQL-Abfrage ausgeführt: {logged_query}")
+ flash("Die SQL-Abfrage wurde erfolgreich ausgeführt.", "success")
+
+ return render_template("admin/sql_access.html.j2", query=query, result=result)
diff --git a/nateman/blueprints/admin/lehrer.py b/nateman/blueprints/admin/lehrer.py
new file mode 100644
index 0000000..560056c
--- /dev/null
+++ b/nateman/blueprints/admin/lehrer.py
@@ -0,0 +1,206 @@
+# NateMan – Nachschreibtermin-Manager
+# blueprints/admin/lehrer.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Lehrerkonten-Administrations-Blueprint
+"""
+
+from flask import Blueprint, abort, current_app, flash, g, redirect, render_template, request, url_for
+
+from ..auth import admin_required
+from ... import util
+from ...models import Lehrer, Stufe, db
+
+bp = Blueprint("lehrer", __name__, url_prefix="/admin/lehrer")
+
+
+@bp.route("/")
+@admin_required
+def index():
+ """ Lehrerliste """
+ return render_template("admin/lehrer/index.html.j2")
+
+
+@bp.route("/", methods=("GET", "POST"))
+@admin_required
+def edit(lehrer_id):
+ """ Lehrerbearbeitung """
+ lehrer: Lehrer = Lehrer.query.filter_by(id=lehrer_id).first()
+
+ # HTTP 404 Fehler erzeugen, wenn kein Lehrer unter der ID gefunden wurde
+ if not lehrer:
+ abort(404)
+ return
+
+ if request.method != "POST":
+ return render_template("admin/lehrer/edit.html.j2", lehrer=lehrer)
+
+ # ELSE
+
+ action = request.form["action"]
+
+ # Benutzerdaten ändern
+ if action == "change-credentials":
+ new_kuerzel = request.form["new-kuerzel"].strip()
+ new_email = request.form["new-email"].strip() or None
+ new_password = request.form["new-password"]
+
+ new_beraet_name = request.form["new-beraet"]
+
+ new_is_admin = ("new-admin" in request.form)
+
+ error_msg = None
+
+ change_kuerzel = False
+ change_email = False
+ change_password = False
+ change_beraet = False
+ change_is_admin = False
+
+ # Neues Kürzel, falls angegeben und nicht das aktuelle Kürzel
+ if new_kuerzel and new_kuerzel != lehrer.kuerzel:
+ change_kuerzel = True
+ # existiert das Kürzel bereits?
+ if Lehrer.query.filter_by(kuerzel=new_kuerzel).count() != 0:
+ error_msg = "Das angegebene Kürzel ist bereits registriert."
+
+ # Neue E-Mail-Adresse, falls angegeben und nicht die aktuelle Adresse
+ if new_email != lehrer.email:
+ change_email = True
+ # ist die neue E-Mail-Adresse syntaktisch ungültig?
+ if new_email is not None and not util.EMAIL_ADDRESS_REGEX.match(new_email):
+ error_msg = "Bitte geben Sie eine gültige E-Mail-Adresse ein."
+
+ # Neues Passwort, falls angegeben
+ if new_password:
+ change_password = True
+ # ist das neue Passwort zu groß?
+ if not util.validate_bcrypt_password(new_password):
+ error_msg = "Das neue Passwort darf höchstens 72 Zeichen lang sein."
+
+ if new_beraet_name == "":
+ new_beraet = None
+ else:
+ new_beraet = Stufe.query.filter_by(name=new_beraet_name).first()
+ if new_beraet is None:
+ abort(400)
+ return
+
+ if new_beraet != lehrer.beraet:
+ change_beraet = True
+
+ # Administratorstatus ändern
+ if new_is_admin != lehrer.is_admin:
+ change_is_admin = True
+
+ # Änderungen vornehmen, falls kein Fehler aufgetreten ist
+ if error_msg is not None:
+ # Es ist ein Fehler aufgetreten
+ flash(error_msg, "error")
+ return redirect(url_for(".edit", lehrer_id=lehrer_id), code=303)
+
+ if not (change_kuerzel or change_email or change_password or change_beraet or change_is_admin):
+ flash("Es wurde nichts geändert.", "error")
+ return redirect(url_for(".edit", lehrer_id=lehrer_id), code=303)
+
+ if change_kuerzel:
+ old_kuerzel = lehrer.kuerzel
+ lehrer.kuerzel = new_kuerzel
+ current_app.logger.info(f"{g.lehrer} hat das Lehrerkürzel des Kontos mit der ID {lehrer.id}"
+ f" von {old_kuerzel} auf {new_kuerzel} geändert.")
+
+ if change_email:
+ # E-Mail-Adresse wird als confirmed markiert, wenn ein Admin sie ändert
+ lehrer.email = new_email
+ lehrer.confirmation_token = None
+ lehrer.is_confirmed = True
+ current_app.logger.info(f"{g.lehrer} hat die E-Mail-Adresse von {lehrer} auf {new_email} gesetzt.")
+
+ if change_password:
+ lehrer.set_password(new_password)
+ current_app.logger.info(f"{g.lehrer} hat das Passwort von {lehrer} geändert.")
+
+ if change_beraet:
+ lehrer.beraet = new_beraet
+ if new_beraet:
+ current_app.logger.info(f"{g.lehrer} hat {lehrer} als Beratungslehrer(in) für die {new_beraet.name} "
+ f"festgelegt.")
+ else:
+ current_app.logger.info(f"{g.lehrer} hat den Beratungslehrerstatus von {lehrer} entfernt.")
+
+ if change_is_admin:
+ lehrer.is_admin = new_is_admin
+ if new_is_admin:
+ current_app.logger.info(f"{g.lehrer} hat {lehrer} den Administratorstatus vergeben.")
+ else:
+ current_app.logger.info(f"{g.lehrer} hat {lehrer} den Administratorstatus entfernt.")
+
+ db.session.commit()
+ flash("Benutzerdaten erfolgreich geändert.", "success")
+ return redirect(url_for(".edit", lehrer_id=lehrer_id), code=303)
+
+ # Account löschen
+ elif action == "delete-account":
+ current_app.logger.info(f"{g.lehrer} hat das Konto {lehrer} gelöscht.")
+
+ db.session.delete(lehrer)
+ db.session.commit()
+ flash("Benutzerkonto erfolgreich gelöscht.", "success")
+
+ return redirect(url_for(".index"), code=303)
+
+ abort(400) # Bad Request, wenn ungültige action
+
+
+@bp.route("/add", methods=("GET", "POST"))
+@admin_required
+def add():
+ """ Lehrerhinzufügung """
+ if request.method != "POST":
+ return render_template("admin/lehrer/add.html.j2")
+
+ # ELSE
+
+ kuerzel = request.form["kuerzel"]
+ password = request.form["password"]
+ force_pwd_change = ("force-password-change" in request.form)
+
+ error_msg = None
+
+ # existiert das Kürzel bereits?
+ if Lehrer.query.filter_by(kuerzel=kuerzel).count() != 0:
+ error_msg = "Ein(e) Lehrer(in) mit diesem Kürzel existiert bereits."
+
+ # ist das neue Passwort zu groß?
+ elif not util.validate_bcrypt_password(password):
+ error_msg = "Das neue Passwort darf höchstens 72 Zeichen lang sein."
+
+ if error_msg:
+ flash(error_msg, "error")
+ return redirect(url_for(".add"), code=303)
+
+ new_lehrer = Lehrer(kuerzel=kuerzel)
+
+ new_lehrer.set_password(password, set_pwd_changed=not force_pwd_change)
+
+ db.session.add(new_lehrer)
+ db.session.commit()
+
+ flash("Lehrer(in) erfolgreich hinzugefügt.", "success")
+ current_app.logger.info(f"{g.lehrer} hat den/die Lehrer(in) {new_lehrer} hinzugefügt")
+
+ return redirect(url_for(".edit", lehrer_id=new_lehrer.id), code=303)
diff --git a/nateman/blueprints/auth.py b/nateman/blueprints/auth.py
new file mode 100644
index 0000000..52806da
--- /dev/null
+++ b/nateman/blueprints/auth.py
@@ -0,0 +1,477 @@
+# NateMan – Nachschreibtermin-Manager
+# blueprints/auth.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Authentifizierungs-Blueprint
+"""
+
+import functools
+import time
+from datetime import datetime, timedelta
+from smtplib import SMTPRecipientsRefused
+
+from flask import Blueprint, abort, current_app, flash, g, redirect, render_template, request, url_for, make_response
+
+from .. import emails, util
+from ..config_manager import config
+from ..models import Lehrer, db, Session
+
+bp = Blueprint("auth", __name__)
+
+SESSION_COOKIE_NAME = "login_session"
+
+
+@bp.before_app_request
+def load_logged_in_lehrer():
+ """
+ Lädt den angemeldeten Lehrer vor jeder HTTP-Anfrage in die g.lehrer-Variable.
+ """
+ session_key = request.cookies.get(SESSION_COOKIE_NAME)
+ session = Session.get(session_key)
+
+ g.session = session
+
+ if g.session is None:
+ g.lehrer = None
+ else:
+ g.lehrer = g.session.lehrer
+
+
+@bp.after_app_request
+def clear_rotten_session_cookie(response):
+ """
+ Löscht veraltete Session-Cookies.
+ """
+ if request.cookies.get(SESSION_COOKIE_NAME) and not g.lehrer:
+ response.delete_cookie(SESSION_COOKIE_NAME)
+
+ return response
+
+
+def login_required(view):
+ """
+ Dieser Decorator kann an Views angehängt werden, die einen angemeldeten Lehrer erfordern.
+ """
+
+ @functools.wraps(view)
+ def wrapped_view(**kwargs):
+
+ # Kein Lehrer angemeldet?
+ if g.lehrer is None:
+ flash("Bitte melden Sie sich an.", "error")
+ return redirect(url_for("auth.login", r=request.path), code=303)
+
+ # muss der Lehrer sein Passwort ändern?
+ if g.lehrer and not g.lehrer.pwd_changed:
+ return redirect(url_for("auth.password_change"), code=303)
+
+ return view(**kwargs)
+
+ return wrapped_view
+
+
+def beratungslehrer_required(view):
+ """
+ Dieser Decorator kann an Views angehängt werden,
+ die einen angemeldeten Beratungslehrer oder Administrator erfordern.
+ """
+
+ @functools.wraps(view)
+ def wrapped_view(**kwargs):
+
+ # Kein Lehrer angemeldet?
+ if g.lehrer is None:
+ flash("Bitte melden Sie sich an.", "error")
+ return redirect(url_for("auth.login", r=request.path), code=303)
+
+ # Lehrer kein Beratungslehrer oder Administrator?
+ if not g.lehrer.can_access():
+ abort(403)
+ return
+
+ # muss der Lehrer sein Passwort ändern?
+ if g.lehrer and not g.lehrer.pwd_changed:
+ return redirect(url_for("auth.password_change"), code=303)
+
+ return view(**kwargs)
+
+ return wrapped_view
+
+
+def admin_required(view):
+ """
+ Dieser Decorator kann an Views angehängt werden, die einen angemeldeten Administrator erfordern.
+ """
+
+ @functools.wraps(view)
+ def wrapped_view(**kwargs):
+
+ # Kein Lehrer angemeldet?
+ if g.lehrer is None:
+ flash("Bitte melden Sie sich an.", "error")
+ return redirect(url_for("auth.login", r=request.path), code=303)
+
+ # Lehrer kein Administrator?
+ if not g.lehrer.is_admin:
+ abort(403)
+ return
+
+ # muss der Lehrer sein Passwort ändern?
+ if g.lehrer and not g.lehrer.pwd_changed:
+ return redirect(url_for("auth.password_change"), code=303)
+
+ return view(**kwargs)
+
+ return wrapped_view
+
+
+@bp.route("/login", methods=("GET", "POST"))
+def login():
+ """ Anmeldung (Seite *Anmelden*)"""
+ if request.method != "POST":
+ return render_template("auth/login.html.j2")
+
+ # ELSE
+
+ request_start_time = time.process_time()
+
+ kuerzel = request.form["kuerzel"].strip()
+ password = request.form["password"]
+ remember_me = ("remember-me" in request.form)
+
+ error = False
+
+ lehrer = Lehrer.query.filter_by(kuerzel=kuerzel).first()
+
+ # existiert Lehrer nicht?
+ if lehrer is None:
+ error = True
+ current_app.logger.info(f"Fehlgeschlagener Anmeldeversuch von {request.remote_addr} "
+ f"(Ungültiges Kürzel '{kuerzel}')")
+
+ # ist das Passwort falsch?
+ elif not lehrer.check_password(password):
+ error = True
+ current_app.logger.info(f"Fehlgeschlagener Anmeldeversuch von {request.remote_addr} "
+ f"(Falsches Passwort für {lehrer.kuerzel})")
+
+ if error:
+ # Bei fehlgeschlagenem Anmeldeversuch 2 Sekunden vor Antwort warten
+ time.sleep(request_start_time - time.process_time() + 2)
+ flash("Ungültige Anmeldedaten.", "error")
+ return redirect(url_for(".login", r=request.args.get("r", None)), code=303)
+
+ # Kein Fehler -> Lehrer anmelden
+
+ current_app.logger.info(f"{lehrer} hat sich angemeldet.")
+
+ session_expiry_delta = timedelta(days=12) if remember_me else timedelta(hours=1)
+ session = Session.create(lehrer, session_expiry_delta)
+
+ if not lehrer.pwd_changed:
+ red = redirect(url_for(".password_change"), code=303)
+
+ else:
+ redirect_path = request.args.get("r", None)
+ # Wenn ein Weiterleitungspfad als GET-Parameter übergeben wurde
+ # (wie es z.B. der login_required-Wrapper macht, wenn kein Benutzer
+ # angemeldet ist), auf diesen Pfad weiterleiten, falls er mit einem
+ # Schrägstrich beginnt (also kein externer Link ist).
+ if redirect_path and len(redirect_path) > 0 and redirect_path[0] == "/":
+ red = redirect(redirect_path, code=303)
+ else:
+ red = redirect(url_for("klausuren.mine"), code=303)
+
+ db.session.commit()
+
+ resp = make_response(red)
+ resp.set_cookie(SESSION_COOKIE_NAME, session.key,
+ max_age=session_expiry_delta.total_seconds() if remember_me else None,
+ expires=session.expiry if remember_me else None, secure=config["uses-ssl"], httponly=True,
+ samesite="Strict")
+ return resp
+
+
+@bp.route("/logout")
+def logout():
+ """ Abmeldung (Seite *Abmelden*)"""
+ resp = make_response(redirect(url_for("auth.login"), code=303))
+ if g.lehrer:
+ current_app.logger.info(f"{g.lehrer} hat sich abgemeldet.")
+ resp.delete_cookie("login_session")
+ db.session.delete(g.session)
+ db.session.commit()
+
+ return resp
+
+
+@bp.route("/confirm-email")
+def confirm_email():
+ """ Emailbestätigung """
+ red = redirect(url_for(".login" if g.lehrer is None else "klausuren.mine"), code=303)
+
+ token = request.args.get("token", None)
+
+ if token is None:
+ flash("Ungültiger/veralteter Bestätigungslink.", "alert")
+ return red
+
+ lehrer = Lehrer.query.filter_by(confirmation_token=token).first()
+
+ if lehrer is None:
+ flash("Ungültiger/veralteter Bestätigungslink.", "alert")
+ return red
+
+ # ELSE
+
+ lehrer.confirmation_token = None
+ lehrer.is_confirmed = True
+ db.session.commit()
+
+ current_app.logger.info(f"{lehrer} hat die eigene E-Mail-Adresse ({lehrer.email}) bestätigt.")
+ flash("Die E-Mail-Adresse wurde erfolgreich bestätigt.", "success")
+
+ return red
+
+
+@bp.route("/password-change", methods=("GET", "POST"))
+def password_change():
+ """ Passwortänderung nach erstem Login """
+ # login_required kann hier nicht verwendet werden,
+ # da es ein verändertes Passwort erfordert
+ if not g.lehrer:
+ return redirect(url_for("auth.login"), code=303)
+
+ if g.lehrer.pwd_changed:
+ return redirect(url_for(".account"), code=303)
+
+ if request.method != "POST":
+ return render_template("auth/password-change.html.j2")
+
+ # ELSE
+
+ new_pass = request.form["new-password"]
+ new_pass_confirm = request.form["new-password-confirm"]
+
+ error_msg = None
+
+ if not new_pass or not new_pass_confirm:
+ error_msg = "Bitte geben Sie ein neues Passwort ein."
+
+ # ist das neue Passwort kürzer als 6 Zeichen?
+ if len(new_pass) < 6:
+ error_msg = "Das neue Passwort muss mindestens 6 Zeichen lang sein."
+ # ist das neue Passwort zu groß?
+ elif not util.validate_bcrypt_password(new_pass):
+ error_msg = "Das neue Passwort darf höchstens 72 Zeichen lang sein."
+ # stimmen die neuen Passwörter nicht überein?
+ elif new_pass != new_pass_confirm:
+ error_msg = "Die neuen Passwörter stimmen nicht überein."
+
+ # Änderungen vornehmen, falls kein Fehler aufgetreten ist
+ if error_msg:
+ # Es ist ein Fehler aufgetreten
+ flash(error_msg, "error")
+ return redirect(url_for(".account"), code=303)
+
+ g.lehrer.set_password(new_pass)
+ db.session.commit()
+
+ current_app.logger.info(f"{g.lehrer} hat das eigene Passwort geändert.")
+
+ return redirect(url_for("klausuren.mine"), code=303)
+
+
+@bp.route("/password-reset", methods=("GET", "POST"))
+def password_reset():
+ """ Passwortzurücksetzung (Seite *Passwort vergessen*)"""
+ red = redirect(url_for(".login" if g.lehrer is None else "klausuren.mine"), code=303)
+
+ token = request.args.get("token", None)
+
+ t_lehrer = None
+ if token is not None:
+ t_lehrer = Lehrer.query.filter_by(password_reset_token=token).first()
+
+ expired = False
+ if t_lehrer is not None:
+ expired = t_lehrer.password_reset_expiry < datetime.utcnow()
+ if expired:
+ t_lehrer.password_reset_token = None
+ t_lehrer.password_reset_expiry = None
+ db.session.commit()
+
+ if t_lehrer is None or expired:
+ flash("Ungültiger/veralteter Zurücksetzungslink.", "alert")
+ return red
+
+ if request.method == "POST":
+ if token is None:
+ # --- Antragstellung ---
+ lehrer_kuerzel = request.form["lehrer-kuerzel"]
+ email_address = request.form["email-address"]
+
+ lehrer = Lehrer.query.filter_by(kuerzel=lehrer_kuerzel, email=email_address).first()
+
+ if lehrer is None:
+ flash("Es gibt keine(n) Lehrer(in) mit den angegebenen Kriterien.", "error")
+ return redirect(url_for(".password_reset"), code=303)
+
+ if not lehrer.is_confirmed:
+ flash("Es gibt eine(n) Lehrer(in) mit den angegebenen Kriterien, allerdings ist dessen/deren "
+ "E-Mail-Adresse nicht bestätigt.\nWenden Sie sich an eine(n) Administrator(in).", "error")
+ return redirect(url_for(".password_reset"), code=303)
+
+ new_token = util.random_uri_safe_string(64)
+ lehrer.password_reset_token = new_token
+ lehrer.password_reset_expiry = datetime.utcnow() + timedelta(hours=1)
+
+ # Zurücksetzungsemail senden
+ try:
+ emails.send_password_reset_mail(lehrer.email, new_token)
+ except SMTPRecipientsRefused:
+ flash(f"Es konnte keine E-Mail an {lehrer.email} gesendet werden.\n"
+ f"Wahrscheinlich existiert diese Adresse nicht mehr.\n"
+ f"Wenden Sie sich an eine(n) Administrator(in).", "error")
+ return redirect(url_for(".password_reset"), code=303)
+
+ db.session.commit()
+
+ flash("Sie müssten nun eine E-Mail bekommen mit einem Link, über den Sie Ihr Passwort ändern können.\n"
+ "Der Link ist eine Stunde lang gültig.", "success")
+ current_app.logger.info(f"Für {lehrer} wurde eine Passwortzurücksetzung beantragt.")
+
+ else:
+ # --- Passwortänderung ---
+ new_pass = request.form["new-password"]
+ new_pass_confirm = request.form["new-password-confirm"]
+ error_msg = None
+ # ist das neue Passwort kürzer als 6 Zeichen?
+ if len(new_pass) < 6:
+ error_msg = "Das neue Passwort muss mindestens 6 Zeichen lang sein."
+ # ist das neue Passwort zu groß?
+ elif not util.validate_bcrypt_password(new_pass):
+ error_msg = "Das neue Passwort darf höchstens 72 Zeichen lang sein."
+ # stimmen die neuen Passwörter nicht überein?
+ elif new_pass != new_pass_confirm:
+ error_msg = "Die neuen Passwörter stimmen nicht überein."
+
+ if error_msg:
+ flash(error_msg, "error")
+ return redirect(url_for(".password_reset", token=token), code=303)
+
+ # ELSE
+
+ t_lehrer.password_reset_token = None
+ t_lehrer.set_password(new_pass)
+ db.session.commit()
+
+ current_app.logger.info(f"{t_lehrer} hat das eigene Passwort zurückgesetzt.")
+ flash("Das Passwort wurde erfolgreich zurückgesetzt.", "success")
+
+ return red
+
+ else:
+ if token is None:
+ # --- Formular zur Antragstellung ---
+ return render_template("auth/password-reset-send.html.j2")
+ else:
+ # --- Formular zur Passwortänderung ---
+ return render_template("auth/password-reset-do.html.j2")
+
+
+@bp.route("/account", methods=("GET", "POST"))
+@login_required
+def account():
+ """ Kontoeinstellungen (Seite *Mein Konto*) """
+ if request.method != "POST":
+ return render_template("auth/account.html.j2")
+
+ # ELSE
+
+ current_password = request.form["current-password"]
+ new_email = request.form["new-email"].strip() or None
+ new_pass = request.form["new-password"]
+ new_pass_confirm = request.form["new-password-confirm"]
+
+ error_msg = None
+
+ change_kuerzel = False
+ change_email = False
+ change_password = False
+
+ # ist das aktuelle Passwort falsch?
+ if not g.lehrer.check_password(current_password):
+ error_msg = "Falsches aktuelles Passwort."
+ else:
+ # Neue E-Mail-Adresse, falls angegeben und nicht die aktuelle Adresse
+ if new_email != g.lehrer.email:
+ change_email = True
+ # ist die neue E-Mail-Adresse syntaktisch ungültig?
+ if new_email is not None and not util.EMAIL_ADDRESS_REGEX.match(new_email):
+ error_msg = "Bitte geben Sie eine gültige E-Mail-Adresse ein."
+
+ # Neues Passwort, falls angegeben
+ if new_pass:
+ change_password = True
+ # ist das neue Passwort kürzer als 6 Zeichen?
+ if len(new_pass) < 6:
+ error_msg = "Das neue Passwort muss mindestens 6 Zeichen lang sein."
+ # ist das neue Passwort zu groß?
+ elif not util.validate_bcrypt_password(new_pass):
+ error_msg = "Das neue Passwort darf höchstens 72 Zeichen lang sein."
+ # stimmen die neuen Passwörter nicht überein?
+ elif new_pass != new_pass_confirm:
+ error_msg = "Die neuen Passwörter stimmen nicht überein."
+
+ # Änderungen vornehmen, falls kein Fehler aufgetreten ist
+ if error_msg:
+ # Es ist ein Fehler aufgetreten
+ flash(error_msg, "error")
+ return redirect(url_for(".account"), code=303)
+
+ # ELSE
+ if not change_kuerzel and not change_email and not change_password:
+ return redirect(url_for(".account"), code=303)
+
+ if change_email:
+ if new_email is not None:
+ token = util.random_uri_safe_string(32)
+ # Bestätigungsemail senden
+ try:
+ emails.send_confirmation_link_mail(new_email, token)
+ except SMTPRecipientsRefused:
+ flash(f"Wir konnten keine Bestätigungsemail an {new_email} senden. "
+ f"Wahrscheinlich existiert diese Adresse nicht.", "error")
+ return redirect(url_for(".account"), code=303)
+
+ g.lehrer.confirmation_token = token
+
+ old_email = g.lehrer.email
+ g.lehrer.email = new_email
+ g.lehrer.is_confirmed = new_email is None
+
+ current_app.logger.info(f"{g.lehrer} hat die eigene E-Mail-Adresse von {old_email} "
+ f"auf {g.lehrer.email} geändert.")
+
+ if change_password:
+ g.lehrer.set_password(new_pass)
+ current_app.logger.info(f"{g.lehrer} hat das eigene Passwort geändert.")
+
+ db.session.commit()
+ flash("Benutzerdaten erfolgreich geändert.", "success")
+ return redirect(url_for(".account"), code=303)
diff --git a/nateman/blueprints/error.py b/nateman/blueprints/error.py
new file mode 100644
index 0000000..a6b6adf
--- /dev/null
+++ b/nateman/blueprints/error.py
@@ -0,0 +1,48 @@
+# NateMan – Nachschreibtermin-Manager
+# blueprints/error.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Enthält ausschließlich Errorhandler.
+"""
+
+from flask import Blueprint, render_template
+
+bp = Blueprint("error", __name__)
+
+
+@bp.app_errorhandler(400)
+def error_400(error):
+ """400 - Ungültige Anfrage"""
+ return render_template("error/400.html.j2"), 400
+
+
+@bp.app_errorhandler(403)
+def error_403(error):
+ """403 - Verboten"""
+ return render_template("error/403.html.j2"), 403
+
+
+@bp.app_errorhandler(404)
+def error_404(error):
+ """404 - Seite nicht gefunden"""
+ return render_template("error/404.html.j2"), 404
+
+
+@bp.app_errorhandler(500)
+def error_500(error):
+ """500 - serverseitiger Fehler"""
+ return render_template("error/500.html.j2"), 500
diff --git a/nateman/blueprints/fileio.py b/nateman/blueprints/fileio.py
new file mode 100644
index 0000000..72a4791
--- /dev/null
+++ b/nateman/blueprints/fileio.py
@@ -0,0 +1,163 @@
+# NateMan – Nachschreibtermin-Manager
+# blueprints/fileio.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Export- und Import-Blueprint
+"""
+import os
+import tempfile
+from datetime import datetime
+
+from flask import abort, Blueprint, current_app, g, redirect, url_for, flash, request, render_template
+from openpyxl.utils.exceptions import InvalidFileException
+from pyexpat import ExpatError
+
+from .auth import beratungslehrer_required, admin_required
+from .. import exporter, util
+from ..importer import KlausurplanImportError, import_plan, excelimport, KoopSchuelerImportError
+from ..models import db, Stufe, Klausur, Schueler
+
+bp = Blueprint("fileio", __name__)
+
+
+@bp.route("/export")
+@beratungslehrer_required
+def export():
+ """ Export (Seite *Nachschreibplan exportieren*)"""
+ with tempfile.NamedTemporaryFile(prefix="nateman_export_") as fp:
+ exporter.excelexport(fp.name, g.lehrer.accessible_stufen())
+ # XLSX-Datei wird in ``filebytes`` geladen, damit die temporäre Datei gelöscht werden kann
+ fp.seek(0)
+ filebytes = fp.read()
+
+ download_name = "NateMan-Export " + datetime.now().strftime("%Y-%m-%d") + ".xlsx"
+ xlsx_mimetype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
+ response = current_app.response_class(filebytes, mimetype=xlsx_mimetype)
+ response.headers.set("Content-Disposition", "attachment", filename=download_name)
+
+ return response
+
+
+@bp.route("/import", methods=("GET", "POST"), endpoint="import")
+@admin_required
+def import_():
+ """ Import (Seite *Klausurpläne importieren*) """
+ if request.method != "POST":
+ return render_template("fileio/import.html.j2")
+
+ # ELSE
+
+ all_stufen = Stufe.query.all()
+
+ for stufe in all_stufen:
+ if "del_" + stufe.name in request.form:
+ if not g.lehrer.can_access(stufe):
+ abort(400)
+ return
+
+ _del_plan(stufe)
+ db.session.commit()
+
+ flash("Klausurplan erfolgreich gelöscht.", "success")
+ current_app.logger.info(f"{g.lehrer} hat den Klausurplan für die {stufe.name} gelöscht.")
+ return redirect(url_for(".import"), code=303)
+
+ new_lehrer_password = request.form["new-lehrer-password"]
+
+ error_msg = None
+ if not new_lehrer_password:
+ error_msg = "Bitte geben Sie das Passwort für neu registrierte Lehrer(innen) an."
+ elif not util.validate_bcrypt_password(new_lehrer_password):
+ error_msg = "Das Passwort für neue Lehrer(innen) darf nicht mehr als 72 Zeichen enthalten."
+ if error_msg is not None:
+ flash(error_msg, "error")
+ return redirect(url_for(".import"), code=303)
+
+ plan_given = []
+
+ for stufe in all_stufen:
+ plan = request.files.get("plan_" + stufe.name, None)
+
+ # Klausurplan importieren
+ if plan and plan.filename:
+ plan_given.append(stufe.name)
+
+ _del_plan(stufe)
+
+ try:
+ import_plan(plan, stufe, new_lehrer_password)
+ except (KeyError, ValueError, ExpatError, KlausurplanImportError) as exc:
+ db.session.rollback()
+
+ flash(f"Beim Importieren des Klausurplans für die {stufe.name} ist ein Fehler aufgetreten.\n"
+ f"Wahrscheinlich ist die Klausurplandatei ungültig oder es gibt einen Konflikt mit den "
+ f"bisherigen Daten.\n\nFehlerbeschreibung: {type(exc).__name__}\n{exc}", "error")
+
+ current_app.logger.warning(f"Beim Versuch von {g.lehrer}, einen Klausurplan zu importieren, "
+ f"ist ein Fehler aufgetreten.", exc_info=exc)
+ return redirect(url_for(".import"), code=303)
+
+ ks_file = request.files.get("koopschueler", None)
+ ks_file_given = False
+
+ # Koopschülerdatei importieren
+ ks_import_failures = []
+ if ks_file and ks_file.filename:
+ ks_file_given = True
+ _del_koopschueler()
+
+ filename_ext = os.path.splitext(ks_file.filename)[1]
+ with tempfile.NamedTemporaryFile(prefix="nateman_ks_import_", suffix=filename_ext) as fp:
+ ks_file.save(fp.name)
+
+ try:
+ ks_import_failures = excelimport(fp.name)
+ except (InvalidFileException, KoopSchuelerImportError) as exc:
+ db.session.rollback()
+
+ flash(f"Beim Importieren der Koopschülerliste ist ein Fehler aufgetreten.\n\n"
+ f"Fehlerbeschreibung: {type(exc).__name__}\n{exc}", "error")
+
+ current_app.logger.warning(f"Beim Versuch von {g.lehrer}, eine Koopschülerliste zu importieren, "
+ f"ist ein Fehler aufgetreten.", exc_info=exc)
+ return redirect(url_for(".import"), code=303)
+
+ if len(plan_given) == 0 and not ks_file_given:
+ flash("Es wurden keine Pläne angegeben.", "error")
+ else:
+ if len(ks_import_failures) == 0:
+ flash("Pläne importiert.", "success")
+ else:
+ flash("Pläne importiert.\n\nKoopschülerimport: Folgende SuS konnten nicht importiert werden:\n"
+ + "; ".join(f"{failure[0]}, {failure[1]}" for failure in ks_import_failures) + ".\n"
+ "Die restlichen KoopSuS wurden trotzdem importiert.", "warning")
+ current_app.logger.info(f"{g.lehrer} hat Pläne importiert.")
+ db.session.commit()
+
+ return redirect(url_for(".import"), code=303)
+
+
+def _del_plan(stufe: Stufe):
+ """Löscht alle Klausuren und Schüler der angegebenen Stufe"""
+ stufe.import_date = None
+ Klausur.query.filter_by(stufe=stufe).delete()
+ Schueler.query.filter_by(stufe=stufe).delete()
+
+
+def _del_koopschueler():
+ """Löscht alle Koopschüler"""
+ Schueler.query.filter(Schueler.stammschule != None).delete()
diff --git a/nateman/blueprints/info.py b/nateman/blueprints/info.py
new file mode 100644
index 0000000..9b65e25
--- /dev/null
+++ b/nateman/blueprints/info.py
@@ -0,0 +1,30 @@
+# NateMan – Nachschreibtermin-Manager
+# blueprints/info.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Informations-Blueprint
+"""
+
+from flask import Blueprint, render_template
+
+bp = Blueprint("info", __name__, url_prefix="/info")
+
+
+@bp.route("/licenses")
+def licenses():
+ """ Lizenzen """
+ return render_template("info/licenses.html.j2")
diff --git a/nateman/blueprints/klausuren.py b/nateman/blueprints/klausuren.py
new file mode 100644
index 0000000..80269c6
--- /dev/null
+++ b/nateman/blueprints/klausuren.py
@@ -0,0 +1,338 @@
+# NateMan – Nachschreibtermin-Manager
+# blueprints/klausuren.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Klausurlisten-Blueprint
+"""
+
+from datetime import datetime
+
+from flask import Blueprint, abort, current_app, flash, g, redirect, render_template, request, url_for, Response
+
+from .auth import login_required, beratungslehrer_required
+from ..config_manager import config
+from ..models import Klausur, Klausurteilnahme, Koopschule, Lehrer, Schueler, db, \
+ get_next_new_schueler_id, Stufe
+
+bp = Blueprint("klausuren", __name__, url_prefix="/klausuren")
+
+
+@bp.route("/")
+@login_required
+def mine():
+ """ Ansicht der eigenen Klausuren (Seite *Meine Klausuren*) """
+ klausur_query = Klausur.query.filter(Klausur.lehrer == g.lehrer).order_by(Klausur.date.desc())
+
+ klausuren_anstehend = klausur_query.filter(Klausur.date > datetime.now().date()).all()
+ klausuren_vergangen = klausur_query.filter(Klausur.date <= datetime.now().date()).all()
+
+ return render_template("klausuren/mine.html.j2", klausuren_anstehend=klausuren_anstehend,
+ klausuren_vergangen=klausuren_vergangen)
+
+
+@bp.route("//", endpoint="stufe")
+def stufe_(stufe_name):
+ """ Ansicht der Klausuren einer Stufe (Seite *Klausuren [Stufe]*) """
+ stufe = Stufe.query.filter_by(name=stufe_name).first()
+ if stufe is None:
+ abort(404)
+ return
+
+ dates_query = db.session.query(Klausur.date).filter_by(stufe=stufe).order_by(Klausur.date.desc())
+ dates_anstehend = [t.date for t in dates_query.filter(Klausur.date > datetime.now().date()).distinct()]
+ dates_vergangen = [t.date for t in dates_query.filter(Klausur.date <= datetime.now().date()).distinct()]
+
+ return render_template("klausuren/stufe.html.j2", stufe=stufe, dates_anstehend=dates_anstehend,
+ dates_vergangen=dates_vergangen)
+
+
+@bp.route("//add", methods=("GET", "POST"))
+@beratungslehrer_required
+def add(stufe_name):
+ """ Klausurhinzufügung """
+ reload_resp = redirect(url_for(".add", stufe_name=stufe_name), code=303)
+
+ stufe = Stufe.query.filter_by(name=stufe_name).first()
+ if stufe is None:
+ abort(404)
+ return
+
+ if not g.lehrer.can_access(stufe):
+ abort(403)
+ return
+
+ if request.method != "POST":
+ return render_template("klausuren/add.html.j2", stufe=stufe)
+
+ # ELSE
+
+ kursname = request.form["kursname"]
+ lehrer_id = request.form["lehrer"]
+ date_str = request.form["date"]
+ try:
+ startperiod = int(request.form["startperiod"])
+ endperiod = int(request.form["endperiod"])
+ except ValueError:
+ abort(400)
+ return
+
+ if startperiod < 0 or startperiod > endperiod or endperiod.bit_length() > 32:
+ flash("Ungültiger Zeitraum", "error")
+ return reload_resp
+
+ if not kursname:
+ flash("Bitte geben Sie einen Kursnamen an.", "error")
+ return reload_resp
+
+ try:
+ date = datetime.strptime(date_str, "%Y-%m-%d").date()
+ except ValueError:
+ abort(400)
+ return
+
+ lehrer = Lehrer.query.filter_by(id=lehrer_id).first()
+ if lehrer is None:
+ abort(400)
+ return
+
+ new_klausur = Klausur(kursname=kursname, date=date, startperiod=startperiod, endperiod=endperiod, stufe=stufe,
+ lehrer=lehrer)
+ db.session.add(new_klausur)
+ db.session.commit()
+
+ flash("Die Klausur wurde erfolgreich hinzugefügt.", "success")
+ current_app.logger.info(f"{g.lehrer} hat die Klausur {new_klausur} hinzugefügt.")
+ return redirect(url_for(".edit", klausur_id=new_klausur.id), code=303)
+
+
+@bp.route("/", methods=("GET", "POST"))
+@login_required
+def edit(klausur_id):
+ """ Klausurbearbeitung """
+ klausur = Klausur.query.filter_by(id=klausur_id).first()
+ if klausur is None:
+ abort(404)
+ return
+
+ if not g.lehrer.can_access(klausur.stufe) and klausur.lehrer != g.lehrer:
+ abort(403)
+ return
+
+ # ELSE
+ if request.method != "POST":
+ kt_list = Klausurteilnahme.query \
+ .filter_by(klausur=klausur) \
+ .join(Schueler) \
+ .order_by(Schueler.nachname, Schueler.vorname) \
+ .all()
+
+ not_in_klausur_list = Schueler.query \
+ .filter_by(stufe=klausur.stufe) \
+ .filter(Schueler.id.notin_(db.session.query(Klausurteilnahme.schueler_id).filter_by(klausur=klausur))) \
+ .order_by(Schueler.nachname, Schueler.vorname) \
+ .all()
+
+ return render_template("klausuren/edit.html.j2", klausur=klausur, kt_list=kt_list,
+ not_in_klausur_list=not_in_klausur_list)
+
+ # ELSE
+ reload_resp = redirect(url_for(".edit", klausur_id=klausur_id), code=303)
+
+ exit_resp: Response
+ if klausur.lehrer == g.lehrer:
+ exit_resp = redirect(url_for(".mine"), code=303)
+ else:
+ exit_resp = redirect(url_for(".stufe", stufe_name=klausur.stufe.name), code=303)
+
+ if klausur.edited and not g.lehrer.can_access(klausur.stufe):
+ abort(400)
+ return
+
+ action = request.form["action"]
+
+ if action == "edit":
+ lehrer_can_access = g.lehrer.can_access(klausur.stufe)
+
+ annotation = request.form["annotation"].strip()
+ flag_as_edited = ("flag-as-edited" in request.form)
+
+ klausur_laenge_str = request.form.get("laenge", None)
+ if lehrer_can_access and not klausur_laenge_str:
+ klausur_laenge = None
+ else:
+ try:
+ klausur_laenge = int(klausur_laenge_str)
+ except ValueError:
+ abort(400)
+ return
+
+ if klausur_laenge not in config["klausuren"]["klausurlaengen"]:
+ abort(400)
+ return
+
+ klausur.laenge = klausur_laenge
+
+ for kt in Klausurteilnahme.query.filter_by(klausur=klausur).all():
+ kt.versaeumt = (f"s_{kt.schueler.id}" in request.form)
+
+ if annotation:
+ if len(annotation) > config["klausuren"]["max-annotation-length"]:
+ abort(400)
+ return
+ klausur.annotation = annotation
+ else:
+ klausur.annotation = None
+
+ if lehrer_can_access:
+ klausur.edited = flag_as_edited
+ else:
+ klausur.edited = True
+
+ current_app.logger.info(f"{g.lehrer} hat die Klausur {klausur} bearbeitet.")
+ flash("Klausur erfolgreich bearbeitet.", "success")
+ db.session.commit()
+
+ return exit_resp
+
+ elif action == "edit-advanced":
+ if not g.lehrer.can_access(klausur.stufe):
+ abort(400)
+ return
+
+ new_lehrer_id = request.form["new-lehrer"]
+ new_date_str = request.form["new-date"]
+ try:
+ new_startperiod = int(request.form["new-startperiod"])
+ new_endperiod = int(request.form["new-endperiod"])
+ except ValueError:
+ abort(400)
+ return
+
+ if new_startperiod < 0 or new_startperiod > new_endperiod or new_endperiod.bit_length() > 32:
+ flash("Ungültiger Zeitraum", "error")
+ return reload_resp
+
+ try:
+ new_date = datetime.strptime(new_date_str, "%Y-%m-%d").date()
+ except ValueError:
+ abort(400)
+ return
+
+ new_lehrer = Lehrer.query.filter_by(id=new_lehrer_id).first()
+ if new_lehrer is None:
+ abort(400)
+ return
+
+ klausur.lehrer = new_lehrer
+ klausur.date = new_date
+ klausur.startperiod = new_startperiod
+ klausur.endperiod = new_endperiod
+
+ current_app.logger.info(f"{g.lehrer} hat die Klausur {klausur} erweitert bearbeitet.")
+ flash("Klausur erfolgreich bearbeitet.", "success")
+ db.session.commit()
+
+ return reload_resp
+
+ elif action == "delete":
+ if not g.lehrer.can_access(klausur.stufe):
+ abort(400)
+ return
+
+ current_app.logger.info(f"{g.lehrer} hat die Klausur {klausur} gelöscht.")
+ flash("Die Klausur wurde erfolgreich gelöscht.", "success")
+
+ db.session.delete(klausur)
+ db.session.commit()
+ return exit_resp
+
+ elif action == "add-schueler":
+ schueler_id = request.form.get("added-schueler", None)
+ add_to = request.form["add-to"]
+
+ if schueler_id is None:
+ flash("Bitte wählen Sie eine(n) Schüler(in) zum Hinzufügen aus.", "error")
+ return reload_resp
+
+ is_new = False
+ if schueler_id == "new-schueler":
+ is_new = True
+ new_schueler_nachname = request.form["new-schueler-nachname"].strip()
+ new_schueler_vorname = request.form["new-schueler-vorname"].strip()
+ new_schueler_stammschule_kuerzel = request.form.get("new-schueler-stammschule", None)
+
+ stammschule = None
+ if new_schueler_stammschule_kuerzel:
+ stammschule = Koopschule.query.filter_by(kuerzel=new_schueler_stammschule_kuerzel).first()
+
+ if stammschule is None:
+ abort(400)
+ return
+
+ if not new_schueler_nachname or not new_schueler_vorname:
+ flash("Bitte geben Sie einen vollständigen Namen für den/die neue(n) Schüler(in) an.", "error")
+ return reload_resp
+
+ schueler = Schueler(id=get_next_new_schueler_id(), nachname=new_schueler_nachname,
+ vorname=new_schueler_vorname, stufe=klausur.stufe,
+ stammschule=stammschule)
+ db.session.add(schueler)
+
+ else:
+ schueler = Schueler.query.filter_by(id=schueler_id).first()
+ if schueler is None:
+ abort(400)
+ return
+
+ if Klausurteilnahme.query.filter_by(klausur=klausur, schueler=schueler).first() is not None:
+ abort(400)
+ return
+
+ if add_to == "klausur":
+ klausuren = [klausur]
+ elif add_to == "kurs":
+ klausuren = Klausur.query.filter_by(stufe=klausur.stufe).filter_by(kursname=klausur.kursname).all()
+ else:
+ abort(400)
+ return
+
+ for k in klausuren:
+ kt_entity = Klausurteilnahme(klausur=k, schueler=schueler)
+ db.session.add(kt_entity)
+
+ current_app.logger.info(f"{g.lehrer} hat den/die{' neue(n)' if is_new else ''} Schüler(in) {schueler} "
+ f"zur Klausur {klausur} hinzugefügt.")
+
+ db.session.commit()
+ return reload_resp
+
+ elif action == "remove-schueler":
+ for kt in Klausurteilnahme.query.join(Klausur)\
+ .filter_by(stufe=klausur.stufe)\
+ .filter_by(kursname=klausur.kursname)\
+ .all():
+ if f"r_{kt.schueler.id}" in request.form:
+ db.session.delete(kt)
+ current_app.logger.info(f"{g.lehrer} hat den/die Schüler(in) {kt.schueler} aus der Klausur "
+ f"{kt.klausur} entfernt.")
+
+ db.session.commit()
+ return reload_resp
+
+ else:
+ # Bad Request, wenn ungültige action
+ abort(400)
diff --git a/nateman/blueprints/schueler.py b/nateman/blueprints/schueler.py
new file mode 100644
index 0000000..8e4c1e6
--- /dev/null
+++ b/nateman/blueprints/schueler.py
@@ -0,0 +1,61 @@
+# NateMan – Nachschreibtermin-Manager
+# blueprints/schueler.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Schüler-Blueprint
+"""
+from typing import Dict, List, Tuple
+
+from flask import Blueprint, current_app, flash, g, redirect, render_template, request, url_for
+
+from .auth import beratungslehrer_required
+from ..models import Klausurteilnahme, db, Schueler, Klausur, Stufe
+
+bp = Blueprint("schueler", __name__, url_prefix="/schueler")
+
+
+@bp.route("/versaeumnisse/", methods=("GET", "POST"))
+@beratungslehrer_required
+def versaeumnisse():
+ """ Versäumnisliste (Seite *Versäumnisse*) """
+ if request.method != "POST":
+ versaeumt_dict: Dict[Stufe, Tuple[List[Klausurteilnahme], List[Klausurteilnahme]]] = {}
+ for stufe in g.lehrer.accessible_stufen():
+ base_query = Klausurteilnahme.query.join(Schueler).join(Klausur) \
+ .filter(Klausurteilnahme.versaeumt) \
+ .filter(Klausur.stufe == stufe) \
+ .order_by(Schueler.nachname, Schueler.vorname)
+
+ versaeumt_dict[stufe] = (
+ base_query.filter(~Klausurteilnahme.nachgeschrieben).all(),
+ base_query.filter(Klausurteilnahme.nachgeschrieben).all(),
+ )
+
+ return render_template("schueler/versaeumnisse.html.j2", versaeumt_dict=versaeumt_dict)
+
+ # ELSE
+
+ for kt in Klausurteilnahme.query.filter_by(versaeumt=True).all():
+ if g.lehrer.can_access(kt.klausur.stufe):
+ kt.attestiert = (f"a_{kt.klausur.id}:{kt.schueler.id}" in request.form)
+ kt.nachgeschrieben = (f"n_{kt.klausur.id}:{kt.schueler.id}" in request.form)
+
+ current_app.logger.info(f"{g.lehrer} hat die Versäumnisliste bearbeitet.")
+ flash("Versäumnisliste erfolgreich bearbeitet.", "success")
+ db.session.commit()
+
+ return redirect(url_for(".versaeumnisse"), code=303)
diff --git a/nateman/commands.py b/nateman/commands.py
new file mode 100644
index 0000000..7881721
--- /dev/null
+++ b/nateman/commands.py
@@ -0,0 +1,260 @@
+# NateMan – Nachschreibtermin-Manager
+# commands.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Enthält Befehle zur Verwendung im Terminal (Command Line Interface).
+"""
+
+import click
+from flask.cli import with_appcontext
+
+from nateman.exporter import excelexport
+from nateman.importer import excelimport, KoopSchuelerImportError
+from . import emails, util, assigner
+from .models import Koopschule, Lehrer, Stufe, db, Session
+from .config_manager import config
+
+
+@click.group()
+def cli():
+ """Enthält Befehle zur Steuerung der NateMan-Webanwendung."""
+ pass
+
+
+@click.command("add-lehrer")
+@click.argument("kuerzel", type=click.STRING)
+@click.option("--password", type=click.STRING, default=None)
+@click.option("--admin", is_flag=True)
+@with_appcontext
+def add_lehrer_command(kuerzel, password, admin):
+ """Erstellt einen Lehreraccount."""
+
+ lehrer = Lehrer.query.filter_by(kuerzel=kuerzel).first()
+
+ if lehrer is not None:
+ click.echo("Fehler: Ein(e) Lehrer(in) mit diesem Kürzel ist bereits registriert.", err=True)
+ return 1
+
+ if not password:
+ password = click.prompt("Neues Passwort eingeben (unsichtbar)", hide_input=True)
+
+ if not util.validate_bcrypt_password(password):
+ click.echo("Fehler: Das Passwort darf höchstens 72 Bytes groß sein.", err=True)
+ return 1
+
+ new_lehrer = Lehrer(kuerzel=kuerzel, is_admin=admin)
+ new_lehrer.set_password(password)
+ db.session.add(new_lehrer)
+ db.session.commit()
+
+ click.echo("Lehrer(in) wurde erfolgreich registriert.")
+ return 0
+
+
+@click.command("add-stufe")
+@click.argument("names", type=click.STRING, nargs=-1)
+@with_appcontext
+def add_stufe_command(names):
+ """Fügt eine neue Stufe zur Datenbank hinzu."""
+
+ if len(names) == 0:
+ click.echo("Fehler: Bitte geben Sie mindestens eine Stufe an.", err=True)
+ return 1
+
+ for name in names:
+ if util.is_integer_string(name):
+ click.echo(f"Fehler: Stufenname darf keine Ganzzahl sein.", err=True)
+ return 1
+
+ stufe = Stufe.query.filter_by(name=name).first()
+
+ if stufe is not None:
+ click.echo(f"Fehler: Die Stufe {name} existiert bereits.", err=True)
+ return 1
+
+ new_stufe = Stufe(name=name)
+ db.session.add(new_stufe)
+
+ db.session.commit()
+
+ click.echo("Die Stufe(n) wurde(n) erfolgreich hinzugefügt.")
+ return 0
+
+
+@click.command("remove-stufe")
+@click.argument("name", type=click.STRING)
+@click.option("--yes", is_flag=True)
+@with_appcontext
+def remove_stufe_command(name, yes):
+ """Entfernt eine Stufe und alle mit ihr verknüpften Daten von der Datenbank."""
+
+ stufe = Stufe.query.filter_by(name=name).first()
+
+ if stufe is None:
+ click.echo("Fehler: Diese Stufe existiert nicht.", err=True)
+ return 1
+
+ if not yes:
+ if not click.confirm(f"Durch diesen Vorgang werden alle mit der Stufe {stufe.name} verknüpften Daten gelöscht. "
+ f"Fortfahren?"):
+ click.echo("Vorgang abgebrochen.")
+ return 0
+
+ db.session.delete(stufe)
+ db.session.commit()
+
+ click.echo("Die Stufe wurde erfolgreich entfernt.")
+ return 0
+
+
+@click.command("add-koopschule")
+@click.argument("kuerzel", type=click.STRING)
+@click.argument("name", type=click.STRING)
+@with_appcontext
+def add_koopschule_command(kuerzel, name):
+ """Fügt eine Koop-Schule zur Datenbank hinzu."""
+ koop_schule = Koopschule.query.filter_by(name=name).first()
+
+ if koop_schule is not None:
+ click.echo(f"Fehler: Eine Koop-Schule mit dem Kürzel {kuerzel} existiert bereits.", err=True)
+ return 1
+
+ new_koop_schule = Koopschule(kuerzel=kuerzel, name=name)
+ db.session.add(new_koop_schule)
+
+ db.session.commit()
+
+ click.echo("Die Koop-Schule wurde erfolgreich hinzugefügt.")
+ return 0
+
+
+@click.command("remove-koopschule")
+@click.argument("kuerzel", type=click.STRING)
+@with_appcontext
+def remove_koopschule_command(kuerzel):
+ """Entfernt eine Koop-Schule und alle mit ihr verknüpften Daten von der Datenbank."""
+
+ koop_schule = Koopschule.query.filter_by(kuerzel=kuerzel).first()
+
+ if koop_schule is None:
+ click.echo(f"Fehler: DEine Koop-Schule mit dem Kürzel {kuerzel} existiert nicht.", err=True)
+ return 1
+
+ db.session.delete(koop_schule)
+ db.session.commit()
+
+ click.echo("Die Koop-Schule wurde erfolgreich entfernt.")
+ return 0
+
+
+@click.command("make-admin")
+@click.argument("kuerzel")
+@with_appcontext
+def make_admin_command(kuerzel):
+ """Gibt einem/einer Lehrer(in) Administratorrechte."""
+
+ lehrer = Lehrer.query.filter_by(kuerzel=kuerzel).first()
+
+ if lehrer is None:
+ click.echo("Fehler: Das angegebene Kürzel ist nicht registriert.", err=True)
+ return 1
+
+ if lehrer.is_admin:
+ click.echo(kuerzel + " ist bereits Administrator.")
+ return 0
+
+ lehrer.is_admin = True
+ db.session.commit()
+ click.echo(kuerzel + " ist jetzt Administrator.")
+ return 0
+
+
+@click.command("take-admin")
+@click.argument("kuerzel")
+@with_appcontext
+def take_admin_command(kuerzel):
+ """Nimmt einem/einer Lehrer(in) seine/ihre Administratorrechte."""
+
+ lehrer = Lehrer.query.filter_by(kuerzel=kuerzel).first()
+
+ if lehrer is None:
+ click.echo("Fehler: Das angegebene Kürzel ist nicht registriert.", err=True)
+ return 1
+
+ if not lehrer.is_admin:
+ click.echo(kuerzel + " ist bereits kein Administrator.")
+ return 0
+
+ lehrer.is_admin = False
+ db.session.commit()
+ click.echo(kuerzel + " ist jetzt kein Administrator mehr.")
+ return 0
+
+
+@click.command("cleanup")
+@with_appcontext
+def cleanup_command():
+ """Entfernt abgelaufene Daten aus der NateMan-Datenbank."""
+ Session.cleanup()
+ Lehrer.password_reset_cleanup()
+ db.session.commit()
+ return 0
+
+
+@click.command("send-reminder-mails")
+@with_appcontext
+def send_reminder_mails_command():
+ """Sendet Erinnerungsemails an alle Lehrer(innen), die unbearbeitete vergangene Klausuren haben."""
+ emails.send_reminder_mails()
+ return 0
+
+
+@click.command("apply-email-format")
+@click.option("-f", "--format", "fmt", type=click.STRING, default=None)
+@click.option("-o", "--override", is_flag=True)
+@with_appcontext
+def apply_email_format_command(fmt, override):
+ """Wendet das E-Mail-Adressen-Format auf Lehrer an."""
+ fmt = fmt or config.get("email-address-format", None)
+ if fmt is None:
+ click.echo("Fehler: Ein Format ist weder konfiguriert, noch wurde eines angegeben.", err=True)
+ return 1
+
+ query = Lehrer.query if override else Lehrer.query.filter_by(email=None)
+ lehrer = query.all()
+ for l in lehrer:
+ l.set_default_email_address(fmt)
+
+ db.session.commit()
+
+ return 0
+
+
+def init_commands():
+ cli.add_command(add_lehrer_command)
+ cli.add_command(make_admin_command)
+ cli.add_command(take_admin_command)
+ cli.add_command(add_stufe_command)
+ cli.add_command(remove_stufe_command)
+ cli.add_command(add_koopschule_command)
+ cli.add_command(remove_koopschule_command)
+ cli.add_command(send_reminder_mails_command)
+ cli.add_command(apply_email_format_command)
+ cli.add_command(cleanup_command)
+
+
+init_commands()
diff --git a/nateman/config_manager.py b/nateman/config_manager.py
new file mode 100644
index 0000000..f554769
--- /dev/null
+++ b/nateman/config_manager.py
@@ -0,0 +1,56 @@
+# NateMan – Nachschreibtermin-Manager
+# config_manager.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Enthält Funktionen zum Laden/Erstellen der Konfigurationsdatei.
+"""
+
+import os
+from shutil import copyfile
+
+import yaml
+
+config: dict = {}
+
+
+def read_config_file(app):
+ """Liest die Konfigurationsdatei."""
+ with open(os.path.join(app.instance_path, "config.yml"), "r", encoding="utf-8") as yaml_file:
+ yamlobj = yaml.safe_load(yaml_file)
+ if not isinstance(yamlobj, dict):
+ raise RuntimeError(f"Invalid config file: yaml.load returned an object "
+ f"of type {type(yamlobj).__name__} instead of a dict")
+
+ config.clear()
+ config.update(yamlobj)
+
+
+def create_config_file(app) -> str:
+ """Initialisiert die Konfigurationsdatei und gibt den Pfad der neuen Datei zurück."""
+ new_file_path = os.path.join(app.instance_path, "config.yml")
+ copyfile(
+ os.path.join(app.root_path, "resources", "default-config.yml"),
+ new_file_path
+ )
+ return new_file_path
+
+
+def config_file_exists(app) -> bool:
+ """Überprüft, ob die Konfigurationsdatei existiert."""
+ return os.path.isfile(
+ os.path.join(app.instance_path, "config.yml")
+ )
diff --git a/nateman/emails.py b/nateman/emails.py
new file mode 100644
index 0000000..5e7f7ef
--- /dev/null
+++ b/nateman/emails.py
@@ -0,0 +1,152 @@
+# NateMan – Nachschreibtermin-Manager
+# emails.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Enthält Funktionen für den E-Mail-Versand.
+"""
+
+import smtplib
+from datetime import datetime
+from email.mime.text import MIMEText
+from typing import Optional, Union
+
+from flask import current_app, render_template
+from sqlalchemy.sql.elements import and_
+
+from .config_manager import config
+from .models import Klausur, Lehrer
+
+
+def _smtp_create() -> Union[smtplib.SMTP, smtplib.SMTP_SSL]:
+ """Erstellt die der Konfiguration entsprechende SMTP-Instanz und verbindet zum SMTP-Server."""
+ logger = current_app.logger
+ logger.debug("Stellt Verbindung zum SMTP-Server her...")
+
+ smtp_constr = smtplib.SMTP_SSL if config["mail"]["use-ssl"] else smtplib.SMTP
+ smtp = smtp_constr(config["mail"]["smtp"]["hostname"], config["mail"]["smtp"]["hostport"])
+
+ smtp.login(config["mail"]["smtp"]["user"], config["mail"]["smtp"]["password"])
+
+ logger.debug("Erfolgreich mit SMTP-Server verbunden.")
+
+ return smtp
+
+
+def _send_mail(address: str, subject: str, content: str, content_type="html", content_charset="utf-8",
+ smtp: Optional[smtplib.SMTP] = None) -> None:
+ """
+ Sendet eine E-Mail mit den in der NateMan-Konfiguration angegebenen SMTP-Daten.
+
+ :param address: Adresse, zu der die E-Mail gesendet werden soll
+ :param subject: Betreff der E-Mail
+ :param content: Inhalt der E-Mail
+ :param content_type: Inhaltstyp der E-Mail
+ :param content_charset: Zeichensatz des E-Mail-Inhalts
+ :param smtp: SMTP-Verbindung. Falls keine Verbindung angegeben wird, wird eine erstellt
+ (und nach dem E-Mail-Versand geschlossen).
+ """
+ logger = current_app.logger
+ sender_address = config["mail"]["sender-address"]
+
+ msg = MIMEText(content, content_type, content_charset)
+ msg["From"] = f"NateMan <{sender_address}>"
+ msg["Subject"] = subject
+
+ smtp_param = smtp is not None
+ if not smtp_param:
+ smtp = _smtp_create()
+
+ logger.debug(f"E-Mail wird an {address} versandt...")
+ try:
+ smtp.sendmail(sender_address, address, msg.as_string())
+ except smtplib.SMTPRecipientsRefused as exc:
+ if not smtp_param:
+ smtp.close()
+ logger.debug(f"E-Mail an {address} konnte nicht versandt werden "
+ f"(wahrscheinlich ungültige Adresse).", exc_info=exc)
+ raise
+ else:
+ logger.debug(f"E-Mail an {address} erfolgreich versandt.")
+
+ if not smtp_param:
+ smtp.close()
+
+
+def send_confirmation_link_mail(address: str, token: str) -> None:
+ """Sendet die Bestätigungsemail nach dem Festlegen der E-Mail-Adresse."""
+ content = render_template("email/confirmation.html.j2", token=token)
+ _send_mail(address, "NateMan: Bestätigung der E-Mail-Adresse", content)
+
+
+def send_password_reset_mail(address: str, token: str) -> None:
+ """Sendet die Passwortzurücksetzungsemail."""
+ content = render_template("email/password-reset.html.j2", token=token)
+ _send_mail(address, "NateMan: Passwortzurücksetzung", content)
+
+
+def send_reminder_mails() -> int:
+ """
+ Sendet Erinnerungsemails an alle Lehrer, die unbearbeitete vergangene Klausuren haben.
+
+ :return: Anzahl der E-Mails, die nicht versandt werden konnten
+ """
+ logger = current_app.logger
+ logger.info("Startet den Versand von Erinnerungsemails...")
+
+ # SMTP-Connect
+ smtp = _smtp_create()
+
+ fail_count = 0
+ for lehrer in Lehrer.query.all():
+ not_edited_list = Klausur.query \
+ .filter(and_(Klausur.date <= datetime.now().date(), Klausur.lehrer == lehrer, ~Klausur.edited)) \
+ .order_by(Klausur.date.desc()).all()
+
+ if len(not_edited_list) == 0:
+ fail_count += 1
+ continue
+
+ if lehrer.email is None:
+ fail_count += 1
+ logger.info(f"Erinnerungsemail an {lehrer} konnte nicht versandt werden, da für diesen Lehrer keine "
+ f"E-Mail-Adresse eingetragen ist.")
+ continue
+
+ if not lehrer.is_confirmed:
+ fail_count += 1
+ logger.info(f"Erinnerungsemail an {lehrer} konnte nicht versandt werden, da die E-Mail-Adresse dieses "
+ f"Lehrers ({lehrer.email}) nicht bestätigt ist.")
+ continue
+
+ content = render_template("email/reminder.html.j2", not_edited_list=not_edited_list)
+ try:
+ _send_mail(lehrer.email, "NateMan: zur Erinnerung", content, smtp=smtp)
+ except smtplib.SMTPRecipientsRefused as exc:
+ logger.info(f"Erinnerungsemail an {lehrer} mit der Adresse {lehrer.email} konnte nicht versandt werden "
+ f"(wahrscheinlich ungültige Adresse).", exc_info=exc)
+ else:
+ logger.info(f"Erinnerungsemail an {lehrer} erfolgreich versandt.")
+
+ smtp.close()
+
+ if fail_count == 0:
+ logger.info("Versand von Erinnerungsemails abgeschlossen.")
+ else:
+ logger.info(f"Versand von Erinnerungsemails abgeschlossen. "
+ f"{fail_count} E-Mail(s) konnten nicht versandt werden.")
+
+ return fail_count
diff --git a/nateman/exporter.py b/nateman/exporter.py
new file mode 100644
index 0000000..7f523bc
--- /dev/null
+++ b/nateman/exporter.py
@@ -0,0 +1,105 @@
+# NateMan – Nachschreibtermin-Manager
+# exporter.py
+# Copyright © 2020 Johannes Bingel
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from typing import Iterable, Optional
+
+from openpyxl import Workbook
+from openpyxl.styles import Font
+
+from nateman import assigner
+from .models import Klausur, Klausurteilnahme, Schueler, Stufe
+
+
+def excelexport(filepath: str, stufen: Optional[Iterable[Stufe]] = None):
+ # Intiziert die Exceldatei
+ workbook = Workbook()
+
+ # Holt sich alle Stufen falls keinen Angegeben sind
+ if stufen is None:
+ stufen = Stufe.query.all()
+
+ # exstellt für jede Stufe ein Excelsheet
+ for s in stufen:
+
+ # Holt sich alle vNachschreiben in eine List aus der Datenbank
+ k_schueler = Klausurteilnahme.query.join(Klausur).join(Schueler).filter(Klausurteilnahme.versaeumt) \
+ .filter(~Klausurteilnahme.nachgeschrieben).filter(Klausur.stufe == s) \
+ .order_by(Schueler.nachname, Schueler.vorname).all()
+
+ # Holt sich die Zuordnugsvoschläge
+ suggestions = assigner.zuordnen(k_schueler)
+
+ # Initialisiert das Excelsheet
+ workbook.create_sheet(s.name)
+ worksheet = workbook[s.name]
+
+ # Fügt die Schüle in die Exceltabelle ein.
+
+ if len(k_schueler) != 0:
+
+ worksheet.cell(1, 1, "Nr")
+ worksheet.cell(1, 2, "Name")
+ worksheet.cell(1, 3, "Vorname")
+ worksheet.cell(1, 4, "Kurs")
+ worksheet.cell(1, 5, "Lehrer")
+ worksheet.cell(1, 6, "Dauer [min]")
+ worksheet.cell(1, 7, "Attest")
+ if suggestions is None:
+ worksheet.cell(1, 8, "Bemerkung")
+ else:
+ worksheet.cell(1, 8, "Termin(Vorschlag)")
+ worksheet.cell(1, 9, "Bemerkung")
+
+ i = 0
+
+ while i < len(k_schueler):
+ worksheet.cell(i + 2, 1, i + 1)
+ worksheet.cell(i + 2, 2, k_schueler[i].schueler.nachname)
+ worksheet.cell(i + 2, 3, k_schueler[i].schueler.vorname)
+ worksheet.cell(i + 2, 4, k_schueler[i].klausur.kursname)
+ worksheet.cell(i + 2, 5, str(k_schueler[i].klausur.lehrer.kuerzel))
+ worksheet.cell(i + 2, 6, k_schueler[i].klausur.laenge)
+ if k_schueler[i].attestiert:
+ worksheet.cell(i + 2, 7, "Ja")
+ else:
+ worksheet.cell(i + 2, 7, "Nein")
+
+ nichtgefunden = True
+ if suggestions is not None:
+ for i2 in range(0, len(suggestions)):
+ if k_schueler[i] in suggestions[i2]:
+ worksheet.cell(i + 2, 8, i2 + 1)
+ nichtgefunden = False
+ if nichtgefunden:
+ worksheet.cell(i + 2, 8, "problem")
+ nichtgefunden = True
+ worksheet.cell(i + 2, 9, k_schueler[i].klausur.annotation)
+ else:
+ worksheet.cell(i + 2, 8, k_schueler[i].klausur.annotation)
+ i += 1
+
+ del i
+ del nichtgefunden
+
+ else:
+ bold = Font(bold=True)
+ worksheet.cell(1, 1, "Keine Schüler fehlen")
+ worksheet.cell(1, 1, ).font = bold
+
+ workbook.remove(workbook["Sheet"])
+ workbook.close()
+ workbook.save(filepath)
diff --git a/nateman/importer.py b/nateman/importer.py
new file mode 100644
index 0000000..8be375b
--- /dev/null
+++ b/nateman/importer.py
@@ -0,0 +1,218 @@
+# NateMan – Nachschreibtermin-Manager
+# importer.py
+# Copyright © 2020 Niklas Elsbrock und Johannes Bingel
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Enthält Funktionen zum Import von Daten.
+"""
+
+from datetime import datetime
+from typing import TextIO, SupportsInt, Union
+
+import bcrypt
+from openpyxl import load_workbook
+from sqlalchemy.sql import and_, exists
+from xml.dom import minidom
+
+from . import util
+from .config_manager import config
+from .models import Klausur, Klausurteilnahme, Lehrer, Schueler, Stufe, db, get_next_new_schueler_id, Koopschule
+
+
+class KlausurplanImportError(Exception):
+ """Beim Versuch, einen Klausurplan zu importieren aufgrund einer ungültigen Klausurdatei aufgetretener Fehler"""
+ pass
+
+
+class KoopSchuelerImportError(Exception):
+ """Beim Versuch, Koop-Schueler zu importieren aufgrund einer ungültigen Klausurdatei aufgetretener Fehler"""
+ pass
+
+
+def _nbit_int(x: Union[str, bytes, SupportsInt], base=10, maxbits=32):
+ result = int(x, base)
+ if result.bit_length() > maxbits:
+ raise ValueError(f"integer exceeds {maxbits}-bit limit")
+
+ return result
+
+
+def import_plan(xml_file: TextIO, stufe: Stufe, new_lehrer_pwd: str) -> None:
+ """
+ Importiert eine Klausurliste aus dem gegebenen XML-Klausurexport für die angegebene Stufe.
+ Registriert noch nicht registrierte Lehrer mit dem angegebenen Passwort.
+ von Niklas Elsbrock
+
+ :param xml_file: zu importierende XML-Datei
+ :param stufe: Stufe, für die die
+ :param new_lehrer_pwd: Passwort für neu registrierte Lehrerkonten
+ """
+ assert util.validate_bcrypt_password(new_lehrer_pwd)
+
+ # Importdatum setzen
+ stufe.import_date = datetime.now().date()
+
+ new_lehrer_pwd_hash = bcrypt.hashpw(new_lehrer_pwd.encode("utf-8"), bcrypt.gensalt())
+
+ xmldoc = minidom.parse(xml_file)
+
+ # Klausurschienen durchgehen
+ for termin in xmldoc.getElementsByTagName("KLAUSURSCHIENE"):
+
+ date = datetime.strptime(termin.attributes["Datum"].value, "%d.%m.%Y").date()
+ startperiod = _nbit_int(termin.attributes["VonStd"].value)
+ endperiod = _nbit_int(termin.attributes["BisStd"].value)
+
+ if startperiod < 0 or startperiod > endperiod:
+ raise KlausurplanImportError(f"Zu importierender Plan für die Stufe {stufe.name} enthält ungültigen "
+ f"Zeitraum (Termin: {util.format_date(date)}; VonStd: {startperiod} BisStd: "
+ f"{endperiod})")
+
+ if db.session.query(exists().where(and_(Klausur.date == date, Klausur.stufe == stufe))).scalar():
+ raise KlausurplanImportError(f"Zu importierender Plan für die {stufe.name} enthält zwei Klausurtermine "
+ f"(Klausurschienen) für dasselbe Datum.")
+
+ # Kurse dieser Schiene durchgehen
+ for kurs in termin.getElementsByTagName("KURS"):
+ kursname = kurs.attributes["Bez"].value
+ kurs_lehrerkuerzel = kurs.attributes["Lehrer"].value
+
+ # eventuell bereits registrierten Lehrer bekommen
+ kurs_lehrer_entity = Lehrer.query.filter_by(kuerzel=kurs_lehrerkuerzel).first()
+
+ # Falls der Lehrer noch nicht registriert ist, registrieren
+ if kurs_lehrer_entity is None:
+ kurs_lehrer_entity = Lehrer(kuerzel=kurs_lehrerkuerzel, is_confirmed=True, pwd_hash=new_lehrer_pwd_hash)
+ # Falls ein E-Mailadressenformat konfiguriert ist, dieses nutzen.
+ email_address_format = config.get("email-address-format", None)
+ if email_address_format is not None:
+ kurs_lehrer_entity.set_default_email_address(email_address_format)
+
+ db.session.add(kurs_lehrer_entity)
+
+ klausur_entity = Klausur(kursname=kursname, date=date, startperiod=startperiod, endperiod=endperiod,
+ stufe=stufe, lehrer=kurs_lehrer_entity)
+ db.session.add(klausur_entity)
+
+ # Schüler dieses Kurses durchgehen
+ for schueler in kurs.getElementsByTagName("SCHUELER"):
+ schueler_dbid = _nbit_int(schueler.attributes["DbIdnr"].value)
+
+ schueler_nachname = schueler.attributes["Name"].value.strip()
+ schueler_vorname = schueler.attributes["Vorname"].value.strip()
+
+ # eventuell bereits eingetragenen Schüler bekommen
+ schueler_entity = Schueler.query.filter_by(id=schueler_dbid).first()
+
+ # Falls der Schüler noch nicht eingetragen ist, eintragen
+ if schueler_entity is None:
+ schueler_entity = Schueler(id=schueler_dbid, nachname=schueler_nachname,
+ vorname=schueler_vorname, stufe=stufe)
+ db.session.add(schueler_entity)
+
+ else:
+ # Ist dieser Schüler bereits für eine andere Stufe eingetragen? -> Fehler
+ if schueler_entity.stufe != stufe:
+ raise KlausurplanImportError(f"Zu importierender Plan für die {stufe.name} enthält Schüler(in) "
+ f"({schueler_vorname} {schueler_nachname}, "
+ f"DbIdNr: {schueler_dbid}), der/die bereits für die "
+ f"{schueler_entity.stufe.name} eingetragen ist.")
+
+ # Ist derselbe Schüler bereits in dieser Klausur? -> Fehler
+ if db.session.query(exists().where(and_(Klausurteilnahme.schueler == schueler_entity,
+ Klausurteilnahme.klausur == klausur_entity))).scalar():
+ raise KlausurplanImportError(f"Zu importierender Plan für die {stufe.name} enthält selbe(n) "
+ f"Schüler(in) ({schueler_vorname} {schueler_nachname}, "
+ f"DbIdNr: {schueler_dbid}) mehrfach in "
+ f"derselben Klausur ({kursname}).")
+
+ # Falls der Schüler die Klausur mitschreibt, zur Klausur hinzufügen
+ if schueler.attributes["Klausurschreiber"].value == "j":
+ klausurteilnahme = Klausurteilnahme(klausur=klausur_entity, schueler=schueler_entity)
+ db.session.add(klausurteilnahme)
+
+
+# Von Johannes
+def excelimport(filepath: str):
+ # Initialisiert Startdaten
+ if Stufe.import_date is not None:
+ workbook = load_workbook(filepath)
+ worksheet = workbook["Datenblatt"]
+ schueler = []
+ exceptions = []
+
+ # Holt die Daten der Schüler aus der Exceltabelle
+ i = 10
+
+ while worksheet.cell(row=i, column=3).value is not None and worksheet.cell(row=i + 1,
+ column=3).value is not None:
+ if worksheet.cell(row=i, column=3).value is not None:
+ schueler.append([worksheet.cell(row=i, column=6).value, worksheet.cell(row=i, column=3).value,
+ worksheet.cell(row=i, column=4).value])
+ i += 1
+
+ # Spalten die Daten in ihre Bestandteile
+ i = 0
+ i2 = 0
+ i3 = 0
+
+ while i < len(schueler):
+ while i2 < len(schueler[i][0]):
+ if schueler[i][0][i2] == ",":
+ break
+ i2 += 1
+ while i3 < len(schueler[i][1]):
+ if schueler[i][1][i3] == " ":
+ break
+ i3 += 1
+ schueler[i] = [schueler[i][0][:i2], schueler[i][0][i2 + 2:], schueler[i][1][:i3], schueler[i][1][i3 + 2:-1],
+ schueler[i][2]]
+ i2 = 0
+ i3 = 0
+ i += 1
+
+ # s 0 Nachname, 1 Vorname, 2 Fach , 3 Lehrer, 4 KOOP_Schuhle
+ # Erstellt für jeden schüler einen Eintrag und prüft ob die Lks und Koopschulen existieren
+ for s in schueler:
+ if s[2] == "E":
+ s[2] = "E5"
+ klausuren = Klausur.query.join(Lehrer).filter(Lehrer.kuerzel == s[3]).all()
+ i = 0
+ while i < len(klausuren):
+ if klausuren[i].kursname[:-2] in ((str(s[2]) + suffix) for suffix in ("-L", " L")):
+ i += 1
+ else:
+ klausuren.pop(i)
+ if len(klausuren) > 0:
+ schueler_entity = Schueler(id=get_next_new_schueler_id(), nachname=s[0], vorname=s[1],
+ stufe=klausuren[0].stufe)
+ schule_entity = Koopschule.query.filter_by(kuerzel=s[4]).first()
+ if schule_entity is not None:
+ schueler_entity.stammschule = schule_entity
+ for klausur in klausuren:
+ teilnahme_entity = Klausurteilnahme(klausur=klausur, schueler=schueler_entity)
+ db.session.add(schueler_entity)
+ db.session.add(teilnahme_entity)
+ else:
+ raise KoopSchuelerImportError("Für den/die Schüler(in) " + s[0] + ", " + s[1]
+ + "konnte keine Koopschule mit dem Kürzel " + s[4]
+ + " gefunden werden.")
+ else:
+ exceptions.append(s)
+
+ return exceptions
+ else:
+ raise KoopSchuelerImportError("Für die Stufe ist noch kein Klausurplan importiert")
diff --git a/nateman/models.py b/nateman/models.py
new file mode 100644
index 0000000..3a97952
--- /dev/null
+++ b/nateman/models.py
@@ -0,0 +1,275 @@
+# NateMan – Nachschreibtermin-Manager
+# models.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Enthält die SQLAlchemy-Modelle.
+"""
+from datetime import datetime, timedelta
+from sqlite3 import Connection as Sqlite3_Connection
+from typing import Optional, Tuple, Union, AnyStr
+
+import bcrypt
+from flask_sqlalchemy import SQLAlchemy
+from sqlalchemy import CheckConstraint
+from sqlalchemy.engine import Engine
+from sqlalchemy.sql import func
+
+from . import util
+from .config_manager import config
+
+db: SQLAlchemy = SQLAlchemy()
+
+
+class Klausurteilnahme(db.Model):
+ klausur_id = db.Column(db.Integer, db.ForeignKey("klausur.id", onupdate="CASCADE", ondelete="CASCADE"),
+ primary_key=True)
+ schueler_id = db.Column(db.Integer, db.ForeignKey("schueler.id", onupdate="CASCADE", ondelete="CASCADE"),
+ primary_key=True)
+ versaeumt = db.Column(db.Boolean, default=False, nullable=False)
+ attestiert = db.Column(db.Boolean, default=False, nullable=False)
+ nachgeschrieben = db.Column(db.Boolean, default=False, nullable=False)
+
+ klausur = db.relationship("Klausur", lazy="joined")
+ schueler = db.relationship("Schueler", lazy="joined")
+
+
+class Stufe(db.Model):
+ name = db.Column(db.String(), primary_key=True)
+ import_date = db.Column(db.Date(), default=None)
+
+
+class Schueler(db.Model):
+ id = db.Column(db.Integer, primary_key=True, autoincrement=True)
+ nachname = db.Column(db.String(collation="NOCASE"), nullable=False)
+ vorname = db.Column(db.String(collation="NOCASE"), nullable=False)
+ stufe_name = db.Column(db.String(), db.ForeignKey("stufe.name", onupdate="CASCADE", ondelete="CASCADE"),
+ nullable=False)
+ stammschule_name = db.Column(db.String(),
+ db.ForeignKey("koopschule.kuerzel", onupdate="CASCADE", ondelete="CASCADE"))
+
+ stufe = db.relationship("Stufe", lazy="select")
+ stammschule = db.relationship("Koopschule", lazy="select")
+
+ def __str__(self):
+ return f"{self.nachname}, {self.vorname} ({self.stufe.name}, ID:{self.id})"
+
+
+class Lehrer(db.Model):
+ id = db.Column(db.Integer, primary_key=True, autoincrement=True)
+ kuerzel = db.Column(db.String(collation="NOCASE"), unique=True, nullable=False)
+ email = db.Column(db.String())
+ is_confirmed = db.Column(db.Boolean, default=False, nullable=False)
+ pwd_hash = db.Column(db.String(), nullable=False)
+ is_admin = db.Column(db.Boolean, default=False, nullable=False)
+ beraet_name = db.Column(db.String(), db.ForeignKey("stufe.name", onupdate="CASCADE", ondelete="SET NULL"))
+ pwd_changed = db.Column(db.Boolean, default=False, nullable=False)
+ confirmation_token = db.Column(db.String(), unique=True)
+ password_reset_token = db.Column(db.String(), unique=True)
+ password_reset_expiry = db.Column(db.DateTime)
+
+ beraet = db.relationship("Stufe", lazy="select")
+
+ @staticmethod
+ def password_reset_cleanup() -> None:
+ """
+ Entfernt alle abgelaufenen Passwortzurücksetzungsanfragen aus der Datenbank.
+ """
+ Lehrer.query.filter(Lehrer.password_reset_expiry < datetime.utcnow()) \
+ .update({Lehrer.password_reset_token: None, Lehrer.password_reset_expiry: None})
+
+ def __str__(self):
+ return f"{self.kuerzel} (ID:{self.id})"
+
+ def can_access(self, stufe: Optional[Stufe] = None) -> bool:
+ """
+ Überprüft, ob dieser Lehrer erweiterten Zugriff auf die angegebene Stufe hat
+ (d.h. ob er Administrator oder Beratungslehrer der angegebenen Stufe ist).
+
+ Wenn die Stufe ``None`` ist, wird überprüft, ob dieser Lehrer
+ Administrator oder Beratungslehrer irgendeiner Stufe ist.
+
+ :return: ``True`` falls ja, ``False`` falls nicht
+ """
+ if self.is_admin:
+ return True
+ # ELSE
+ if stufe is None:
+ return self.beraet is not None
+ # ELSE
+ return self.beraet == stufe
+
+ def accessible_stufen(self, names: bool = False) -> Union[Tuple[Stufe, ...], Tuple[AnyStr, ...]]:
+ """
+ :param names: Falls ``True``, werden die Namen der Stufen anstelle der Stufenobjekte zurückgegeben
+ :return: Tupel mit allen Stufen, auf die dieser Lehrer erweiterten Zugriff hat
+ """
+ stufen = Stufe.query.all()
+ if self.is_admin:
+ return tuple(stufen) if not names else tuple(s.name for s in stufen)
+ # ELSE
+ if self.beraet:
+ return (self.beraet,) if not names else (self.beraet.name,)
+ # ELSE
+ return ()
+
+ def set_password(self, new_password: str, set_pwd_changed=True) -> None:
+ """
+ Legt das neue Passwort des Lehrers fest.
+
+ :param new_password: neues Passwort
+ :param set_pwd_changed: legt fest, ob der ``pwd_changed``-Eintrag in der Datenbank angepasst werden soll
+ """
+ assert util.validate_bcrypt_password(new_password)
+ self.pwd_hash = bcrypt.hashpw(new_password.encode("utf-8"), bcrypt.gensalt())
+ if set_pwd_changed:
+ self.pwd_changed = True
+
+ def check_password(self, password) -> bool:
+ """
+ Vergleicht ``password`` mit dem Passwort des Lehrers.
+
+ :param password: zu überprüfendes Passwort
+ :return: ``True`` falls die Passwörter übereinstimmen, ``False`` falls nicht
+ """
+ return bcrypt.checkpw(password.encode("utf-8"), self.pwd_hash)
+
+ def set_default_email_address(self, fmt) -> bool:
+ email_address = fmt.replace("?", util.email_address_safe(self.kuerzel))
+ if util.EMAIL_ADDRESS_REGEX.match(email_address):
+ self.email = email_address
+ self.is_confirmed = True
+ return True
+
+ return False
+
+
+class Klausur(db.Model):
+ id = db.Column(db.Integer, primary_key=True, autoincrement=True)
+ kursname = db.Column(db.String(collation="NOCASE"), nullable=False)
+ date = db.Column(db.Date, nullable=False)
+ startperiod = db.Column(db.Integer, nullable=False)
+ endperiod = db.Column(db.Integer, nullable=False)
+ laenge = db.Column(db.Integer, default=None)
+ edited = db.Column(db.Boolean, default=False, nullable=False)
+ annotation = db.Column(db.String())
+ stufe_name = db.Column(db.String(), db.ForeignKey("stufe.name", onupdate="CASCADE", ondelete="CASCADE"),
+ nullable=False)
+ lehrer_id = db.Column(db.Integer, db.ForeignKey("lehrer.id", onupdate="CASCADE", ondelete="CASCADE"),
+ nullable=False)
+
+ stufe = db.relationship("Stufe", lazy="select")
+ lehrer = db.relationship("Lehrer", lazy="joined")
+
+ __table_args__ = (
+ CheckConstraint("startperiod >= 0"),
+ CheckConstraint("startperiod <= endperiod")
+ )
+
+ def __str__(self):
+ return f"{self.kursname}, {self.stufe.name} (ID:{self.id})"
+
+ def date_formatted(self) -> str:
+ """
+ :return: Klausurdatum als String im Format WW, DD.MM.YYYY (siehe util.format_date)
+ """
+ return util.format_date(self.date)
+
+ def is_bygone(self):
+ """
+ :return: ``True``, falls diese Klausur vergangen ist, ``False``, falls nicht
+ """
+ return self.date <= datetime.now().date()
+
+
+class Koopschule(db.Model):
+ kuerzel = db.Column(db.String(), primary_key=True)
+ name = db.Column(db.String())
+
+
+class Session(db.Model):
+ key = db.Column(db.String(), primary_key=True)
+ expiry = db.Column(db.DateTime, nullable=False)
+ lehrer_id = db.Column(db.Integer, db.ForeignKey("lehrer.id", onupdate="CASCADE", ondelete="CASCADE"),
+ nullable=False)
+
+ lehrer = db.relationship("Lehrer", lazy="joined")
+
+ @staticmethod
+ def get(key: str) -> Optional["Session"]:
+ """
+ Gibt die Sitzung zurück, die zum Key gehört oder ``None``,
+ falls keine Sitzung mit dem Key existiert oder die Sitzung abgelaufen ist.
+
+ :param key: Sitzungs-Key
+ :return: Sitzung
+ """
+ session = Session.query.filter_by(key=key).first()
+ if session is not None and session.expired():
+ return None
+
+ return session
+
+ @staticmethod
+ def create(lehrer: Lehrer, expiry_delta: timedelta) -> "Session":
+ """
+ Erstellt eine neue Sitzung für den Lehrer ``lehrer``.
+
+ :param lehrer: Lehrer, für den eine Sitzung erstellt werden soll
+ :param expiry_delta: Zeitraum, nach dem die Sitzung ablaufen soll
+ :return: neue Sitzung
+ """
+ new_session = Session(key=util.random_uri_safe_string(64), expiry=datetime.utcnow() + expiry_delta,
+ lehrer=lehrer)
+ db.session.add(new_session)
+ return new_session
+
+ @staticmethod
+ def cleanup() -> None:
+ """
+ Entfernt alle abgelaufenen Sitzungen aus der Datenbank.
+ """
+ Session.query.filter(Session.expiry < datetime.utcnow()).delete()
+
+ def expired(self) -> bool:
+ """
+ Überprüft, ob die Sitzung abgelaufen ist.
+ """
+ return self.expiry < datetime.utcnow()
+
+
+@db.event.listens_for(Engine, "connect")
+def set_sqlite_pragma(dbapi_connection, connection_record):
+ """
+ Falls SQLite verwendet wird, wird bei jedem Verbindungsaufbau zur Datenbank ``foreign_keys`` aktiviert, damit
+ Fremdschlüssel richtig funktionieren.
+ Von https://stackoverflow.com/questions/4477269.
+ """
+ if type(dbapi_connection) is Sqlite3_Connection:
+ cursor = dbapi_connection.cursor()
+ cursor.execute("PRAGMA foreign_keys=ON")
+ cursor.close()
+
+
+def get_next_new_schueler_id():
+ """
+ :return: ID, die der nächste manuell hinzugefügte Schüler haben soll
+ """
+ lowest_id = db.session.query(func.min(Schueler.id).label("min_id")).one().min_id
+ if lowest_id is None or lowest_id > -1:
+ return -1
+ # ELSE
+ return lowest_id - 1
diff --git a/nateman/resources/default-config.yml b/nateman/resources/default-config.yml
new file mode 100644
index 0000000..494e402
--- /dev/null
+++ b/nateman/resources/default-config.yml
@@ -0,0 +1,67 @@
+# Konfiguration der NateMan-Webanwendung.
+
+
+# Name, unter dem der Webserver normalerweise erreicht wird
+server-name: "nateman.example.com"
+
+# Benutzt der Webserver SSL (HTTPS)?
+uses-ssl: No
+
+# Passwort, das standardmäßig als Passwort für neu reistrierte Lehrer verwendet wird
+default-new-lehrer-password: ""
+
+# Format für E-Mail-Adressen neu hinzugefügter Lehrer.
+# Fragezeichen werden durch das jeweilige Kürzel des neuen Lehrers ersetzt.
+# Auskommentieren zum Deaktivieren.
+# Beispiel: email-address-format: "?@example.com"
+#email-address-format: ""
+
+
+schule:
+ # Name der Schule
+ name: "Max-Mustermann-Schule"
+ # URL zur Website der Schule
+ website-url: "https://example.com/"
+ # Optional: URL zum Schullogo.
+ # Optimal ist ein PNG-Bild mit maximal 100 Pixeln Höhe.
+ #logo-url
+ # Url zum Impressum
+ imprint-url: "https://example.com/impressum"
+ # Url zur Datenschutzerklärung
+ privacy-policy-url: "https://example.com/datenschutz"
+
+
+klausuren:
+ # Maximale Zeichenanzahl für Bemerkungen
+ max-annotation-length: 64
+ # Bei der Klausurbearbeitung auswählbare Klausurlängen.
+ # Bestehende Daten werden von einer Änderung nicht beeinflusst.
+ klausurlaengen:
+ - 45
+ - 60
+ - 135
+ - 180
+
+
+# Logging-Einstellungen
+logging:
+ # Logging-Level. Mögliche Werte: NOTSET, DEBUG, INFO, WARNING, ERROR, CRITICAL
+ level: "INFO"
+ # Legt fest, ob Lognachrichten zu syslog (/dev/log) gesendet werden sollen
+ syslog: No
+
+
+# Mailserver-Einstellungen
+mail:
+ # Addresse, von der von NateMan automatisch gesendete E-Mails ausgehen
+ sender-address: "nateman@example.com"
+ # Legt, ob SSL zur Verbindung zum SMTP-Server verwendet werden soll.
+ # Empfohlen, falls der SMTP-Server dies unterstützt.
+ use-ssl: Yes
+
+ # SMTP-Host- und Anmeldedaten
+ smtp:
+ hostname: "smtp.example.com"
+ hostport: 25
+ user: "nateman@example.com"
+ password: ""
diff --git a/nateman/static/font/fontawesome/LICENSE.txt b/nateman/static/font/fontawesome/LICENSE.txt
new file mode 100644
index 0000000..f31bef9
--- /dev/null
+++ b/nateman/static/font/fontawesome/LICENSE.txt
@@ -0,0 +1,34 @@
+Font Awesome Free License
+-------------------------
+
+Font Awesome Free is free, open source, and GPL friendly. You can use it for
+commercial projects, open source projects, or really almost whatever you want.
+Full Font Awesome Free license: https://fontawesome.com/license/free.
+
+# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
+In the Font Awesome Free download, the CC BY 4.0 license applies to all icons
+packaged as SVG and JS file types.
+
+# Fonts: SIL OFL 1.1 License (https://scripts.sil.org/OFL)
+In the Font Awesome Free download, the SIL OFL license applies to all icons
+packaged as web and desktop font files.
+
+# Code: MIT License (https://opensource.org/licenses/MIT)
+In the Font Awesome Free download, the MIT license applies to all non-font and
+non-icon files.
+
+# Attribution
+Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
+Awesome Free files already contain embedded comments with sufficient
+attribution, so you shouldn't need to do anything additional when using these
+files normally.
+
+We've kept attribution comments terse, so we ask that you do not actively work
+to remove them from files, especially code. They're a great way for folks to
+learn about Font Awesome.
+
+# Brand Icons
+All brand icons are trademarks of their respective owners. The use of these
+trademarks does not indicate endorsement of the trademark holder by Font
+Awesome, nor vice versa. **Please do not use brand logos for any purpose except
+to represent the company, product, or service to which they refer.**
diff --git a/nateman/static/font/fontawesome/fa-solid-900.eot b/nateman/static/font/fontawesome/fa-solid-900.eot
new file mode 100644
index 0000000..5318231
Binary files /dev/null and b/nateman/static/font/fontawesome/fa-solid-900.eot differ
diff --git a/nateman/static/font/fontawesome/fa-solid-900.svg b/nateman/static/font/fontawesome/fa-solid-900.svg
new file mode 100644
index 0000000..d94a259
--- /dev/null
+++ b/nateman/static/font/fontawesome/fa-solid-900.svg
@@ -0,0 +1,5000 @@
+
+
+
+
+
+Created by FontForge 20190801 at Thu Jun 18 14:52:21 2020
+ By Robert Madole
+Copyright (c) Font Awesome
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nateman/static/font/fontawesome/fa-solid-900.ttf b/nateman/static/font/fontawesome/fa-solid-900.ttf
new file mode 100644
index 0000000..8adeea2
Binary files /dev/null and b/nateman/static/font/fontawesome/fa-solid-900.ttf differ
diff --git a/nateman/static/font/fontawesome/fa-solid-900.woff b/nateman/static/font/fontawesome/fa-solid-900.woff
new file mode 100644
index 0000000..65f1d33
Binary files /dev/null and b/nateman/static/font/fontawesome/fa-solid-900.woff differ
diff --git a/nateman/static/font/fontawesome/fa-solid-900.woff2 b/nateman/static/font/fontawesome/fa-solid-900.woff2
new file mode 100644
index 0000000..b48ec6c
Binary files /dev/null and b/nateman/static/font/fontawesome/fa-solid-900.woff2 differ
diff --git a/nateman/static/font/lato/LatoLatin-Bold.eot b/nateman/static/font/lato/LatoLatin-Bold.eot
new file mode 100644
index 0000000..d90b47b
Binary files /dev/null and b/nateman/static/font/lato/LatoLatin-Bold.eot differ
diff --git a/nateman/static/font/lato/LatoLatin-Bold.ttf b/nateman/static/font/lato/LatoLatin-Bold.ttf
new file mode 100644
index 0000000..c598c24
Binary files /dev/null and b/nateman/static/font/lato/LatoLatin-Bold.ttf differ
diff --git a/nateman/static/font/lato/LatoLatin-Bold.woff b/nateman/static/font/lato/LatoLatin-Bold.woff
new file mode 100644
index 0000000..cdfcbe0
Binary files /dev/null and b/nateman/static/font/lato/LatoLatin-Bold.woff differ
diff --git a/nateman/static/font/lato/LatoLatin-Bold.woff2 b/nateman/static/font/lato/LatoLatin-Bold.woff2
new file mode 100644
index 0000000..2615c85
Binary files /dev/null and b/nateman/static/font/lato/LatoLatin-Bold.woff2 differ
diff --git a/nateman/static/font/lato/LatoLatin-Italic.eot b/nateman/static/font/lato/LatoLatin-Italic.eot
new file mode 100644
index 0000000..403b9a5
Binary files /dev/null and b/nateman/static/font/lato/LatoLatin-Italic.eot differ
diff --git a/nateman/static/font/lato/LatoLatin-Italic.ttf b/nateman/static/font/lato/LatoLatin-Italic.ttf
new file mode 100644
index 0000000..c61fc07
Binary files /dev/null and b/nateman/static/font/lato/LatoLatin-Italic.ttf differ
diff --git a/nateman/static/font/lato/LatoLatin-Italic.woff b/nateman/static/font/lato/LatoLatin-Italic.woff
new file mode 100644
index 0000000..d8cf84c
Binary files /dev/null and b/nateman/static/font/lato/LatoLatin-Italic.woff differ
diff --git a/nateman/static/font/lato/LatoLatin-Italic.woff2 b/nateman/static/font/lato/LatoLatin-Italic.woff2
new file mode 100644
index 0000000..aaa5a35
Binary files /dev/null and b/nateman/static/font/lato/LatoLatin-Italic.woff2 differ
diff --git a/nateman/static/font/lato/LatoLatin-Regular.eot b/nateman/static/font/lato/LatoLatin-Regular.eot
new file mode 100644
index 0000000..96a9035
Binary files /dev/null and b/nateman/static/font/lato/LatoLatin-Regular.eot differ
diff --git a/nateman/static/font/lato/LatoLatin-Regular.ttf b/nateman/static/font/lato/LatoLatin-Regular.ttf
new file mode 100644
index 0000000..bcc5778
Binary files /dev/null and b/nateman/static/font/lato/LatoLatin-Regular.ttf differ
diff --git a/nateman/static/font/lato/LatoLatin-Regular.woff b/nateman/static/font/lato/LatoLatin-Regular.woff
new file mode 100644
index 0000000..bf73a6d
Binary files /dev/null and b/nateman/static/font/lato/LatoLatin-Regular.woff differ
diff --git a/nateman/static/font/lato/LatoLatin-Regular.woff2 b/nateman/static/font/lato/LatoLatin-Regular.woff2
new file mode 100644
index 0000000..a4d084b
Binary files /dev/null and b/nateman/static/font/lato/LatoLatin-Regular.woff2 differ
diff --git a/nateman/static/font/lato/OFL.txt b/nateman/static/font/lato/OFL.txt
new file mode 100644
index 0000000..6d2c416
--- /dev/null
+++ b/nateman/static/font/lato/OFL.txt
@@ -0,0 +1,94 @@
+Copyright (c) 2010-2015, Łukasz Dziedzic (dziedzic@typoland.com),
+with Reserved Font Name Lato.
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/nateman/static/img/icon-apple.png b/nateman/static/img/icon-apple.png
new file mode 100644
index 0000000..7602ac8
Binary files /dev/null and b/nateman/static/img/icon-apple.png differ
diff --git a/nateman/static/img/logo.png b/nateman/static/img/logo.png
new file mode 100644
index 0000000..3055eaa
Binary files /dev/null and b/nateman/static/img/logo.png differ
diff --git a/nateman/static/img/nateman-erm.svg b/nateman/static/img/nateman-erm.svg
new file mode 100644
index 0000000..28acb5b
--- /dev/null
+++ b/nateman/static/img/nateman-erm.svg
@@ -0,0 +1,714 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Lehrer
+
+
+
+
+
+
+
+ id
+
+
+
+
+
+
+
+ kuerzel
+
+
+
+
+
+
+
+ email
+
+
+
+
+
+
+
+ is_confirmed
+
+
+
+
+
+
+
+ pwd_hash
+
+
+
+
+
+
+
+ is_admin
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ pwd_changed
+
+
+
+
+
+
+
+ confirmation_token
+
+
+
+
+
+
+
+ password_reset_token
+
+
+
+
+
+
+
+ password_reset_expiry
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Klausur
+
+
+
+
+
+
+
+ id
+
+
+
+
+
+
+
+ kursname
+
+
+
+
+
+
+
+ laenge
+
+
+
+
+
+
+
+ edited
+
+
+
+
+
+
+
+ Stufe
+
+
+
+
+
+
+
+ berät Lehrer.beraet_name
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ gehört zu Klausur.stufe_name
+
+
+
+
+
+
+
+
+
+
+
+
+
+ wird betreut Klausur.lehrer_id
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Schueler
+
+
+
+
+
+
+
+ nimmt Teil Klausurteilnahme . schueler_id , . klausur_id
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ versaeumt
+
+
+
+
+
+
+
+ attestiert
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ist in Schueler.stufe_name
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id
+
+
+
+
+
+
+
+ vorname
+
+
+
+
+
+
+
+ nachname
+
+
+
+
+
+
+
+ Koopschule
+
+
+
+
+
+
+
+ ist in Schueler .stammschule_name
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ kuerzel
+
+
+
+
+
+
+
+ name
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+
+ n
+
+
+
+
+
+ 1
+
+
+
+
+
+ n
+
+
+
+
+
+ 1
+
+
+
+
+
+ n
+
+
+
+
+
+ n
+
+
+
+
+
+ 1
+
+
+
+
+
+ n
+
+
+
+
+
+ m
+
+
+
+
+
+ n
+
+
+
+
+
+ 1
+
+
+
+
+
+
+
+ name
+
+
+
+
+
+
+
+ import_date
+
+
+
+
+
+
+
+
+
+
+
+
+
+ nachgeschrieben
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ date
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ startperiod
+
+
+
+
+
+
+
+ endperiod
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nateman/static/img/school-logo.png b/nateman/static/img/school-logo.png
new file mode 100644
index 0000000..9b7bd8e
Binary files /dev/null and b/nateman/static/img/school-logo.png differ
diff --git a/nateman/static/script.js b/nateman/static/script.js
new file mode 100644
index 0000000..c5976ab
--- /dev/null
+++ b/nateman/static/script.js
@@ -0,0 +1,33 @@
+// JavaScript des NateMan von Niklas Elsbrock
+
+// --- Flashnachrichten EventListener ---
+var flashNode;
+for (flashNode of document.getElementsByClassName('flash')) {
+ flashNode.onclick = function () {
+ this.style.display = 'none';
+ };
+
+ flashNode.onkeydown = function (event) {
+ if (event.keyCode === 13) {
+ this.style.display = 'none';
+ }
+ };
+}
+
+
+// --- Tabellenzeilen EventListener ---
+var trNode;
+var href;
+for (trNode of document.getElementsByTagName('tr')) {
+ if (trNode.getAttribute('data-href') !== null) {
+ trNode.onclick = function () {
+ window.location = this.getAttribute('data-href');
+ };
+
+ trNode.onkeydown = function (event) {
+ if (event.keyCode === 13) {
+ window.location = this.getAttribute('data-href');
+ }
+ };
+ }
+}
diff --git a/nateman/static/style.css b/nateman/static/style.css
new file mode 100644
index 0000000..f13c8c0
--- /dev/null
+++ b/nateman/static/style.css
@@ -0,0 +1,507 @@
+/* Cascading Style Sheet des NateMan von Niklas Elsbrock */
+
+:root {
+ --bg-primary: #ffffff;
+ --bg-secondary: #eeeeee;
+ --bg-tertiary: #dddddd;
+ --fg-main: #000000;
+ --fg-warn: #ff8000;
+ --fg-detail: #777777;
+ --bg-marked: #ffff00;
+ --header-bg: #87aa25;
+ --header-fg: #ffffff;
+ --navbar-bg: #143d59;
+ --navbar-fg: #ffffff;
+ --navbar-link-hover-bg: rgba(255, 255, 255, 0.25);
+ --footer-fg: #777777;
+ --footer-fg-detail: #cccccc;
+ --footer-bg: #eeeeee;
+
+ --navbar-width: 220px;
+ --navbar-padding-top: 18px;
+ --header-height: 80px;
+ --header-border-width: 2px;
+ --header-full-height: calc(var(--header-height) + var(--header-border-width));
+
+ --labeled-hr-color: #ff8000;
+}
+
+
+@font-face {
+ font-family: 'Lato';
+ src: local('Lato Regular'),
+ url('./font/lato/LatoLatin-Regular.eot') format('embedded-opentype'),
+ url('./font/lato/LatoLatin-Regular.woff2') format('woff2'),
+ url('./font/lato/LatoLatin-Regular.woff') format('woff'),
+ url('./font/lato/LatoLatin-Regular.ttf') format('truetype');
+}
+
+@font-face {
+ font-family: 'Lato';
+ font-style: italic;
+ src: local('Lato Italic'),
+ url('./font/lato/LatoLatin-Italic.eot') format('embedded-opentype'),
+ url('./font/lato/LatoLatin-Italic.woff2') format('woff2'),
+ url('./font/lato/LatoLatin-Italic.woff') format('woff'),
+ url('./font/lato/LatoLatin-Italic.ttf') format('truetype');
+}
+
+@font-face {
+ font-family: 'Lato';
+ font-weight: bold;
+ src: local('Lato Bold'),
+ url('./font/lato/LatoLatin-Bold.eot') format('embedded-opentype'),
+ url('./font/lato/LatoLatin-Bold.woff2') format('woff2'),
+ url('./font/lato/LatoLatin-Bold.woff') format('woff'),
+ url('./font/lato/LatoLatin-Bold.ttf') format('truetype');
+}
+
+@font-face {
+ font-family: 'Font Awesome 5 Free';
+ font-weight: 900;
+ font-display: block;
+ src: url('./font/fontawesome/fa-solid-900.eot') format('embedded-opentype'),
+ url('./font/fontawesome/fa-solid-900.woff2') format('woff2'),
+ url('./font/fontawesome/fa-solid-900.woff') format('woff'),
+ url('./font/fontawesome/fa-solid-900.ttf') format('truetype'),
+ url('./font/fontawesome/fa-solid-900.svg#svg_fontregular') format('svg');
+}
+
+
+html,
+body {
+ width: 100%;
+ height: 100%;
+ position: fixed;
+}
+
+
+body {
+ margin: 0;
+ padding: 0;
+ font-family: 'Lato', sans-serif;
+ font-size: 16px;
+ line-height: 1.25;
+ background-color: var(--bg-primary);
+ color: var(--fg-main);
+}
+
+
+header {
+ display: table;
+ height: var(--header-height);
+ width: 100%;
+ position: fixed;
+ top: 0;
+ left: 0;
+ z-index: 1;
+ background-color: var(--header-bg);
+ border-bottom: 2px solid #607a18;
+ overflow-y: hidden;
+ white-space: nowrap;
+ user-select: none;
+}
+
+header .header-text {
+ display: table-cell;
+ height: 100%;
+ width: 100%;
+ color: var(--header-fg);
+ text-decoration: none;
+ font-size: 40px;
+ font-weight: bold;
+ text-align: center;
+ vertical-align: middle;
+}
+
+#nateman-logo-container {
+ display: block;
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: var(--navbar-width);
+ height: var(--header-height);
+ text-align: center;
+}
+
+#nateman-logo {
+ --img-margin: 10px;
+ height: calc(var(--header-height) - 2 * var(--img-margin));
+ margin: var(--img-margin);
+}
+
+
+nav {
+ width: var(--navbar-width);
+ height: calc(100% - var(--header-full-height) - var(--navbar-padding-top));
+ margin-top: var(--header-full-height);
+ position: fixed;
+ top: 0;
+ left: 0;
+ background-color: var(--navbar-bg);
+ overflow-x: hidden;
+ overflow-y: auto;
+ padding-top: var(--navbar-padding-top);
+ user-select: none;
+}
+
+nav a {
+ display: block;
+ padding: 8px 16px;
+ text-decoration: none;
+ font-size: 16px;
+ color: var(--navbar-fg);
+}
+
+nav a:hover {
+ background-color: var(--navbar-link-hover-bg);
+ text-decoration: none;
+}
+
+nav a > span {
+ display: table-cell;
+}
+
+nav a::before {
+ display: table-cell;
+ content: attr(data-icon);
+ width: 27px;
+ vertical-align: middle;
+}
+
+nav hr {
+ border: var(--navbar-link-hover-bg) solid 3px;
+ border-radius: 3px;
+ margin: 10px;
+}
+
+
+#page-section {
+ background-color: var(--bg-primary);
+ height: calc(100% - var(--header-full-height));
+ margin-left: var(--navbar-width);
+ margin-top: var(--header-full-height);
+ overflow-x: auto;
+ overflow-y: scroll;
+}
+
+#page {
+ display: flex;
+ flex-direction: column;
+ min-width: min-content;
+ min-height: 100%;
+}
+
+main {
+ flex: 1;
+ padding: 18px 25px 30px 25px;
+}
+
+main p {
+ text-align: justify;
+}
+
+
+footer {
+ display: table;
+ padding: 8px 10px;
+ color: var(--footer-fg);
+ font-size: 14px;
+ background-color: var(--footer-bg);
+ border-top: var(--footer-fg) solid 1px;
+}
+
+.footer-left,
+.footer-right {
+ display: table-cell;
+}
+
+.footer-left {
+ padding-right: 8px;
+ border-right: var(--footer-fg-detail) solid 1px;
+ vertical-align: middle;
+}
+
+#school-logo {
+ height: 35px;
+ vertical-align: middle;
+}
+
+.footer-right {
+ width: 100%;
+ padding-left: 8px;
+}
+
+
+#flash-container {
+ position: absolute;
+ width: 400px;
+ bottom: 0px;
+ right: 0px;
+ margin: 0px 27px 65px 0px;
+ display: flex;
+ flex-wrap: wrap-reverse;
+}
+
+.flash,
+.flash:hover {
+ text-decoration: none;
+ width: inherit;
+ margin-top: 10px;
+ padding: 10px;
+ border: 1px solid;
+ border-radius: 5px;
+ cursor: pointer;
+ transition: 0.2s;
+}
+
+.flash-success {
+ background-color: rgba(0, 255, 0, 0.5);
+ border-color: #008000 !important;
+}
+
+.flash-success:hover {
+ background-color: rgba(0, 255, 0, 0.7);
+}
+
+.flash-warning {
+ background-color: rgba(255, 255, 0, 0.5);
+ border-color: #808000 !important;
+}
+
+.flash-warning:hover {
+ background-color: rgba(255, 255, 0, 0.7);
+}
+
+.flash-error {
+ background-color: rgba(255, 0, 0, 0.5);
+ border-color: #800000 !important;
+}
+
+.flash-error:hover {
+ background-color: rgba(255, 0, 0, 0.6);
+}
+
+
+.table-aligned {
+ display: table;
+ box-sizing: border-box;
+ margin: -2px;
+}
+
+.table-aligned > div {
+ display: table-row;
+ box-sizing: content-box;
+}
+
+.table-aligned > div > div {
+ display: table-cell;
+ padding: 2px;
+}
+
+.table-aligned > div > div > input[type=text],
+.table-aligned > div > div > input[type=password],
+.table-aligned > div > div > input[type=email],
+.table-aligned > div > div > input[type=date],
+.table-aligned > div > div > select {
+ box-sizing: border-box;
+ width: 100%;
+}
+
+
+table {
+ border: 2px solid var(--fg-main);
+ border-collapse: collapse;
+}
+
+table tr.clickable {
+ cursor: pointer;
+}
+
+table tr.clickable:hover,
+table tr.clickable:focus {
+ background-color: var(--bg-tertiary);
+ outline: none;
+}
+
+table tbody tr:nth-child(odd) {
+ background-color: var(--bg-primary);
+}
+
+table tbody tr:nth-child(even) {
+ background-color: var(--bg-secondary);
+}
+
+table th,
+table td {
+ border-top: 1px solid var(--fg-main);
+ border-right: 1px dotted var(--fg-main);
+ border-bottom: 1px solid var(--fg-main);
+ border-left: 1px dotted var(--fg-main);
+ padding: 4px 6px;
+}
+
+table th {
+ background-color: var(--bg-tertiary);
+ border-bottom: 2px solid var(--fg-main);
+}
+
+
+[data-icon]::before {
+ font-family: 'Font Awesome 5 Free';
+ font-style: normal;
+ font-weight: normal;
+ content: attr(data-icon) '\00A0';
+}
+
+
+p {
+ margin: 0.5em 0;
+}
+
+h1, h2, h3, h4, h5, h6 {
+ margin: 1.2em 0 0.4em 0;
+}
+
+.page-heading {
+ margin: 0.8em 0 0.4em 0;
+}
+
+
+a {
+ color: inherit;
+ text-decoration: underline dotted;
+}
+
+a:hover {
+ text-decoration: underline solid;
+}
+
+
+a.scroll-anchor {
+ visibility: hidden;
+ color: #999999;
+ text-decoration: none;
+}
+
+a.scroll-anchor::before {
+ font-family: 'Font Awesome 5 Free';
+ font-weight: normal;
+ content: '\f0c1';
+}
+
+:hover > a.scroll-anchor {
+ visibility: inherit;
+}
+
+a.scroll-anchor:hover {
+ color: #555555;
+}
+
+
+.warn {
+ color: var(--fg-warn);
+}
+
+.warn::before {
+ content: '\f071\00A0';
+}
+
+.detail {
+ color: var(--fg-detail);
+}
+
+.description {
+ font-style: italic;
+}
+
+.negative-status {
+ color: #bb0000;
+ font-weight: bold;
+}
+
+.negative-status::before {
+ content: '\f00d\00A0';
+}
+
+.positive-status {
+ color: #00bb00;
+}
+
+.positive-status::before {
+ content: '\f00c\00A0';
+}
+
+.warn::before,
+.negative-status::before,
+.positive-status::before {
+ font-family: 'Font Awesome 5 Free';
+ font-weight: normal;
+}
+
+.marked {
+ border-radius: 3px;
+ background-color: var(--bg-marked);
+}
+
+.monospace {
+ font-family: 'Consolas', monospace;
+}
+
+
+hr,
+.labeled-hr::after {
+ border: var(--bg-secondary) solid 3px;
+ border-radius: 3px;
+ margin: 25px 0;
+}
+
+.labeled-hr {
+ display: flex;
+ margin: 20px 0;
+ color: var(--labeled-hr-color);
+ font-weight: bold;
+ white-space: nowrap;
+}
+
+.labeled-hr::after {
+ content: '';
+ width: 100%;
+ height: 0;
+ border-color: var(--labeled-hr-color);
+ margin: 7px 15px;
+}
+
+button.plain,
+input[type=submit].plain {
+ background: none;
+ border: none;
+ padding: 0;
+ font-family: inherit;
+ font-size: inherit;
+ font-weight: inherit;
+ line-height: inherit;
+ cursor: pointer;
+}
+
+button[disabled].plain,
+input[type=submit][disabled].plain {
+ cursor: default;
+}
+
+fieldset {
+ border: none;
+ margin: 0;
+ padding: 0;
+}
+
+input.small {
+ width: 40px;
+}
+
+
+@media only screen and (max-width: 1100px) {
+ .header-text .optional {
+ display: none;
+ }
+}
diff --git a/nateman/templates/admin/index.html.j2 b/nateman/templates/admin/index.html.j2
new file mode 100644
index 0000000..b7aaada
--- /dev/null
+++ b/nateman/templates/admin/index.html.j2
@@ -0,0 +1,28 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/admin/index.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Administration{% endblock %}
+{% block header %}Administration{% endblock %}
+
+{% block content %}
+Lehrerkonten
+SQL-Zugriff
+{% endblock %}
diff --git a/nateman/templates/admin/lehrer/add.html.j2 b/nateman/templates/admin/lehrer/add.html.j2
new file mode 100644
index 0000000..b7a26a6
--- /dev/null
+++ b/nateman/templates/admin/lehrer/add.html.j2
@@ -0,0 +1,45 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/admin/lehrer/add.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Lehrer(in) hinzufügen{% endblock %}
+{% block header %}Lehrer(in) hinzufügen{% endblock %}
+
+{% block content %}
+
+{% endblock %}
diff --git a/nateman/templates/admin/lehrer/edit.html.j2 b/nateman/templates/admin/lehrer/edit.html.j2
new file mode 100644
index 0000000..83d4b96
--- /dev/null
+++ b/nateman/templates/admin/lehrer/edit.html.j2
@@ -0,0 +1,90 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/admin/lehrer/edit.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Lehrer(in): {{ lehrer.kuerzel }}{% endblock %}
+{% block header %}Lehrer(in): {{ lehrer.kuerzel }}{% endblock %}
+
+{# lehrer #}
+{% set stufen_list = Stufe.query.all() %}
+
+{% block js_head %}
+ var delete_warn = "Durch das Löschen eines Lehrerkontos werden alle Klausuren,\ndie dem gelöschten Konto zugeordnet "
+ + "sind, unwiderruflich gelöscht.\nWollen Sie wirklich fortfahren?"
+{% endblock %}
+
+{% block content %}
+
+
+
+
+
+{% endblock %}
diff --git a/nateman/templates/admin/lehrer/index.html.j2 b/nateman/templates/admin/lehrer/index.html.j2
new file mode 100644
index 0000000..6994a2e
--- /dev/null
+++ b/nateman/templates/admin/lehrer/index.html.j2
@@ -0,0 +1,69 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/admin/lehrer/index.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Lehrerkonten{% endblock %}
+{% block header %}Lehrerkonten{% endblock %}
+
+{% set lehrer_list = Lehrer.query.order_by(Lehrer.kuerzel).all() %}
+
+{% block content %}
+Lehrer(in) hinzufügen
+
+Klicken Sie eine Zeile aus der folgenden Übersicht an, um ein bestehendes Benutzerkonto zu bearbeiten.
+
+
+
+
+ Kürzel
+ E-Mail-Adresse
+ Admin
+ Beratungslehrer(in)
+ Passwort gesetzt
+
+
+
+ {% for l in lehrer_list %}
+
+ {{ l.kuerzel }}
+
+ {% if l.email is not none %}
+ {{ l.email }}
+ {% if l.is_confirmed %}
+
+ {% else %}
+
+ {% endif %}
+ {% else %}
+ (keine)
+ {% endif %}
+
+ {{ 'ja' if l.is_admin else 'nein' }}
+ {{ l.beraet.name if l.beraet is not none else '(keine Stufe) ' }}
+ {% if l.pwd_changed %}
+ ja
+ {% else %}
+ nein
+ {% endif %}
+
+ {% endfor %}
+
+
+{% endblock %}
diff --git a/nateman/templates/admin/sql_access.html.j2 b/nateman/templates/admin/sql_access.html.j2
new file mode 100644
index 0000000..b746def
--- /dev/null
+++ b/nateman/templates/admin/sql_access.html.j2
@@ -0,0 +1,83 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/admin/sql_access.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}SQL-Zugriff{% endblock %}
+{% block header %}SQL-Zugriff{% endblock %}
+
+{# result: Ergebnis einer SQL-Abfrage als sqlalchemy.engine.ResultProxy #}
+
+{% block content %}
+
+ Diese Seite erlaubt direkten Zugriff auf die SQL-Datenbank von NateMan durch die Eingabe von SQL-Abfragen.
+
+ Bei falscher Anwendung können Daten unwiderruflich verloren gehen.
+ Außerdem kann es bei der Veränderung bestimmter Daten zu unerwarteten Fehlern in der NateMan-Anwendung kommen.
+ Benutzen Sie diese Seite nur, wenn Sie wissen, was Sie tun.
+
+
+
+
+ {% set nateman_erm_url = url_for('static', filename='img/nateman-erm.svg') %}
+
+
+
+
+
+
+
+{% if result is not none and result.returns_rows %}
+ {% set result_rows = result.fetchall() %}
+
+ Ergebnis ({{ result_rows|length }} Zeilen):
+
+
+
+
+ {% for col_name in result.keys() %}
+ {{ col_name }}
+ {% endfor %}
+
+
+
+
+ {% for row in result_rows %}
+
+ {% for value in row._mapping.values() %}
+ {% if value is none %}
+ NULL
+ {% else %}
+ {{ value }}
+ {% endif %}
+ {% endfor %}
+
+ {% endfor %}
+
+
+{% endif %}
+{% endblock %}
diff --git a/nateman/templates/auth/account.html.j2 b/nateman/templates/auth/account.html.j2
new file mode 100644
index 0000000..30c38e2
--- /dev/null
+++ b/nateman/templates/auth/account.html.j2
@@ -0,0 +1,67 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/auth/account.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Benutzereinstellungen{% endblock %}
+{% block header %}Benutzereinstellungen{% endblock %}
+
+{% block content %}
+
+
+
+
Aktuelles Passwort:
+
+
+
+
+
+
E-Mail-Adresse:
+
+
+
+ {% if g.lehrer.email is not none %}
+
+ {% if g.lehrer.is_confirmed %}
+
+ {% else %}
+ nicht bestätigt
+ {% endif %}
+
+ {% endif %}
+
+
+
Neues Passwort:
+
+
+
+
+
+
+
+
+
+{% endblock %}
diff --git a/nateman/templates/auth/login.html.j2 b/nateman/templates/auth/login.html.j2
new file mode 100644
index 0000000..bbe32df
--- /dev/null
+++ b/nateman/templates/auth/login.html.j2
@@ -0,0 +1,48 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/auth/login.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Anmelden{% endblock %}
+{% block header %}Anmelden{% endblock %}
+
+{% block content %}
+
+
+
+
+
+
+
Angemeldet bleiben:
+
+
+
+
+
+
+ Passwort vergessen
+
+
+{% endblock %}
diff --git a/nateman/templates/auth/password-change.html.j2 b/nateman/templates/auth/password-change.html.j2
new file mode 100644
index 0000000..7ee1112
--- /dev/null
+++ b/nateman/templates/auth/password-change.html.j2
@@ -0,0 +1,48 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/auth/password-change.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Neues Passwort{% endblock %}
+{% block header %}Neues Passwort{% endblock %}
+
+{% block content %}
+Bitte geben Sie ein neues Passwort für Ihr Benutzerkonto ein.
+
+
+
+
+
Neues Passwort:
+
+
+
+
+
+
+
+
+
+{% endblock %}
diff --git a/nateman/templates/auth/password-reset-do.html.j2 b/nateman/templates/auth/password-reset-do.html.j2
new file mode 100644
index 0000000..21aa160
--- /dev/null
+++ b/nateman/templates/auth/password-reset-do.html.j2
@@ -0,0 +1,46 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/auth/password-reset-do.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Passwort zurücksetzen{% endblock %}
+{% block header %}Passwort zurücksetzen{% endblock %}
+
+{% block content %}
+
+
+
+
Neues Passwort:
+
+
+
+
+
+
+
+
+
+{% endblock %}
diff --git a/nateman/templates/auth/password-reset-send.html.j2 b/nateman/templates/auth/password-reset-send.html.j2
new file mode 100644
index 0000000..edb5ae9
--- /dev/null
+++ b/nateman/templates/auth/password-reset-send.html.j2
@@ -0,0 +1,43 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/auth/password-reset-send.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Passwort zurücksetzen{% endblock %}
+{% block header %}Passwort zurücksetzen{% endblock %}
+
+{% block content %}
+
+
+
+
+
+
+{% endblock %}
diff --git a/nateman/templates/base.html.j2 b/nateman/templates/base.html.j2
new file mode 100644
index 0000000..f807e49
--- /dev/null
+++ b/nateman/templates/base.html.j2
@@ -0,0 +1,203 @@
+
+
+{# von Niklas Elsbrock #}
+
+
+{% macro zeitraum(klausur) -%}
+ {{- klausur.startperiod }}.
+ {%- if klausur.startperiod != klausur.endperiod -%}
+ –{{ klausur.endperiod }}.
+ {%- endif %}
+{%- endmacro %}
+
+
+
+
+
+
+
+ {% block title %}{% endblock %} – NateMan
+
+
+
+
+
+
+
+
+ {% block head %}{% endblock %}
+
+
+
+
+
+
+
+
+
+ {% if g.lehrer is not none %}
+
+
+ Angemeldet als {{ g.lehrer.kuerzel }}
+ Abmelden
+
+
+ {% else %}
+
+ Anmelden
+
+
+
+ Passwort vergessen
+
+ {% endif %}
+
+
+ {% if g.lehrer is not none and g.lehrer.pwd_changed %}
+
+ Meine Klausuren
+
+ {% endif %}
+
+ {% if g.lehrer is none or g.lehrer.pwd_changed %}
+ {% for stufe in Stufe.query.all() %}
+
+ Klausuren {{ stufe.name }}
+
+ {% endfor %}
+ {% endif %}
+
+ {% if g.lehrer is not none and g.lehrer.pwd_changed %}
+ {% if g.lehrer.can_access() %}
+
+ Versäumnisse
+
+
+ {%
+ if Klausurteilnahme.query.join(Klausur)
+ .filter(Klausurteilnahme.versaeumt)
+ .filter(Klausurteilnahme.nachgeschrieben == false)
+ .filter(Klausur.stufe_name.in_(g.lehrer.accessible_stufen(names=True)))
+ .count() != 0
+ %}
+
+
+ Nachschreibplan exportieren
+
+ {% elif g.lehrer.is_admin %}
+
+ {% endif %}
+
+ {% if g.lehrer.is_admin %}
+
+ Klausurpläne importieren
+
+ {% endif %}
+ {% endif %}
+
+
+
+ Mein Konto
+
+
+ {% if g.lehrer.is_admin %}
+
+ Administration
+
+ {% endif %}
+ {% endif %}
+
+
+
+ {% for message in get_flashed_messages(with_categories=True) %}
+ {% if message[0] != 'alert' %}
+
+ {{ message[1] | replace('\n', ' ') }}
+
+ {% endif %}
+ {% endfor %}
+
+
+
+
+
+
+
+ JavaScript ist in Ihrem Browser deaktiviert bzw. nicht unterstützt.
+ Diese Seite benötigt JavaScript, um richtig zu funktionieren.
+
+
+ {% if g.lehrer and g.lehrer.pwd_changed %}
+ {% if g.lehrer.email is none %}
+ {#
+ #}Sie haben keine E-Mail-Adresse festgelegt.
+ Festlegen
+
+ {% elif not g.lehrer.is_confirmed %}
+ Sie haben Ihre E-Mail-Adresse noch nicht bestätigt.
+ {% endif %}
+ {% endif %}
+ {% block header %}{% endblock %}
+ {% block content %}{% endblock %}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nateman/templates/email/base.html.j2 b/nateman/templates/email/base.html.j2
new file mode 100644
index 0000000..1c3f4ef
--- /dev/null
+++ b/nateman/templates/email/base.html.j2
@@ -0,0 +1,37 @@
+
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/email/base.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+
+
+
+
+
+
+
+ {% block header %}{% endblock %}
+ {% block content %}{% endblock %}
+
+
+ Diese E-Mail wurde automatisch versandt. Eine Antwort ist nicht nötig.
+
+
+
+
diff --git a/nateman/templates/email/confirmation.html.j2 b/nateman/templates/email/confirmation.html.j2
new file mode 100644
index 0000000..9737116
--- /dev/null
+++ b/nateman/templates/email/confirmation.html.j2
@@ -0,0 +1,30 @@
+{% extends 'email/base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/email/confirmation.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block header %}Bestätigung Ihrer E-Mail-Adresse für NateMan{% endblock %}
+
+
+{% block content %}
+
+ Um die E-Mail-Adresse für Ihr Benutzerkonto beim Nachschreibtermin-Manager zu
+ bestätigen, klicken Sie hier .
+
+{% endblock %}
diff --git a/nateman/templates/email/password-reset.html.j2 b/nateman/templates/email/password-reset.html.j2
new file mode 100644
index 0000000..1c6f720
--- /dev/null
+++ b/nateman/templates/email/password-reset.html.j2
@@ -0,0 +1,31 @@
+{% extends 'email/base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/email/password-reset.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block header %}Passwortzurücksetzung{% endblock %}
+
+
+{% block content %}
+
+ Für Ihr Benutzerkonto beim Nachschreibtermin-Manager wurde eine Passwortzurücksetzung beantragt.
+ Sie können Ihr Passwort hier ändern.
+ Der Link ist eine Stunde lang gültig.
+
+{% endblock %}
diff --git a/nateman/templates/email/reminder.html.j2 b/nateman/templates/email/reminder.html.j2
new file mode 100644
index 0000000..1ca83d8
--- /dev/null
+++ b/nateman/templates/email/reminder.html.j2
@@ -0,0 +1,43 @@
+{% extends 'email/base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/email/reminder.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block header %}Zur Erinnerung{% endblock %}
+
+
+{% block content %}
+
+ Folgende Klausuren müssen noch bearbeitet werden:
+
+
+
+
+ Klicken Sie hier ,
+ um alle Klausuren von Ihnen zu sehen.
+
+{% endblock %}
diff --git a/nateman/templates/error/400.html.j2 b/nateman/templates/error/400.html.j2
new file mode 100644
index 0000000..7c4ed48
--- /dev/null
+++ b/nateman/templates/error/400.html.j2
@@ -0,0 +1,33 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/error/400.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Fehler{% endblock %}
+{% block header %}Fehler{% endblock %}
+
+{% block content %}
+Ihr Browser hat eine ungültige Anfrage gesendet.
+
+ Dies kann passieren, wenn Sie versuchen Daten zu verändern,
+ die in der Zwischenzeit von anderer Stelle verändert bzw. entfernt wurden.
+ Versuchen Sie, die gerade ausgeführte Aktion zu wiederholen.
+
+400 BAD REQUEST
+{% endblock %}
diff --git a/nateman/templates/error/403.html.j2 b/nateman/templates/error/403.html.j2
new file mode 100644
index 0000000..c4d5c45
--- /dev/null
+++ b/nateman/templates/error/403.html.j2
@@ -0,0 +1,28 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/error/403.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Kein Zugriff{% endblock %}
+{% block header %}Kein Zugriff{% endblock %}
+
+{% block content %}
+Auf diese Seite haben Sie keinen Zugriff.
+403 FORBIDDEN
+{% endblock %}
diff --git a/nateman/templates/error/404.html.j2 b/nateman/templates/error/404.html.j2
new file mode 100644
index 0000000..e8fdcf5
--- /dev/null
+++ b/nateman/templates/error/404.html.j2
@@ -0,0 +1,28 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/error/404.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Fehler{% endblock %}
+{% block header %}Fehler{% endblock %}
+
+{% block content %}
+Diese Seite existiert nicht.
+404 NOT FOUND
+{% endblock %}
diff --git a/nateman/templates/error/500.html.j2 b/nateman/templates/error/500.html.j2
new file mode 100644
index 0000000..8123bfd
--- /dev/null
+++ b/nateman/templates/error/500.html.j2
@@ -0,0 +1,28 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/error/500.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Serverfehler{% endblock %}
+{% block header %}Hoppala!{% endblock %}
+
+{% block content %}
+Es ist ein serverseitiger Fehler aufgetreten.
+500 INTERNAL SERVER ERROR
+{% endblock %}
diff --git a/nateman/templates/fileio/import.html.j2 b/nateman/templates/fileio/import.html.j2
new file mode 100644
index 0000000..f04e04d
--- /dev/null
+++ b/nateman/templates/fileio/import.html.j2
@@ -0,0 +1,88 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/fileio/import.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Klausurpläne importieren{% endblock %}
+{% block header %}Klausurpläne importieren{% endblock %}
+
+{% set stufen_list = Stufe.query.all() %}
+
+{% block js_head %}
+ var plan_delete_warn = "Durch das Löschen eines Plans werden alle importierten sowie nachträglich hinzugefügten\n"
+ + "Daten der Stufe (Klausurtermine, Klausuren, Schüler(innen)) unwiderruflich gelöscht.\n"
+ + "Lehrerkonten bleiben unberührt.\n\nWollen Sie wirklich fortfahren?";
+
+ var import_warn = "Durch das Importieren von Klausurplänen werden bestehende importierte sowie nachträglich "
+ + "hinzugefügte\nDaten (Klausurtermine, Klausuren, Schüler(innen)) aller Stufen, für die neue Pläne "
+ + "importiert wurden, unwiderruflich gelöscht.\nBestehende Lehrerkonten bleiben unberührt.\n\n"
+ + "Durch das Importieren von Koopschüler(inne)n werden alle bestehenden Koopschüler(innen) "
+ + "gelöscht.\n\nWollen Sie wirklich fortfahren?";
+{% endblock %}
+
+{% block js_body_end %}
+ document.getElementById("import-button").onclick = function () {
+ if (!confirm(import_warn)) {
+ return false;
+ }
+ this.disabled = true;
+ this.value = 'Bitte warten...';
+ this.form.submit();
+ return true;
+ }
+{% endblock %}
+
+{% block content %}
+
+
+ {% for stufe in stufen_list %}
+
+
Plan für {{ stufe.name }}:
+
+
+
+
+
+ {% if stufe.import_date is none %}
+ nicht importiert
+ {% else %}
+ importiert am {{ stufe.import_date.strftime("%d.%m.%Y") }}
+ {% endif %}
+
+
+ {% endfor %}
+
+
+
+ Koopschüler(innen)liste:
+
+
+
+
+
+ Passwort für neu registrierte Lehrer(innen):
+
+
+
+
+
+
+{% endblock %}
diff --git a/nateman/templates/index/index.html.j2 b/nateman/templates/index/index.html.j2
new file mode 100644
index 0000000..71ff309
--- /dev/null
+++ b/nateman/templates/index/index.html.j2
@@ -0,0 +1,35 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/index/index.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Startseite{% endblock %}
+{% block header %}Startseite{% endblock %}
+
+{% block content %}
+
+ Sie befinden sich auf der Startseite des Nachschreibtermin-Managers.
+ Von hier aus können Sie die Klausurpläne für die Stufen
+ {% for stufe in Stufe.query.all() -%}
+ {%- if not loop.first -%}{%- if loop.last %} und {% else -%}, {% endif -%}{%- endif -%}
+ {{ stufe.name }}
+ {%- endfor %}
+ einsehen oder sich als Lehrer anmelden .
+
+{% endblock %}
diff --git a/nateman/templates/info/licenses.html.j2 b/nateman/templates/info/licenses.html.j2
new file mode 100644
index 0000000..02b2313
--- /dev/null
+++ b/nateman/templates/info/licenses.html.j2
@@ -0,0 +1,38 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/info/licenses.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Lizenzen{% endblock %}
+{% block header %}Lizenzen{% endblock %}
+
+{% block content %}
+Schriftart: Lato
+
+ Copyright (c) 2010-2015, Łukasz Dziedzic (dziedzic@typoland.com), with Reserved Font Name Lato.
+ Licensed under the SIL Open Font License, Version 1.1 .
+
+
+Symbole (Icons): Font Awesome Free
+
+ Font Awesome Free 5.13.1 by @fontawesome - https://fontawesome.com
+ License - https://fontawesome.com/license/free
+ (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
+
+{% endblock %}
diff --git a/nateman/templates/klausuren/add.html.j2 b/nateman/templates/klausuren/add.html.j2
new file mode 100644
index 0000000..4f94d4c
--- /dev/null
+++ b/nateman/templates/klausuren/add.html.j2
@@ -0,0 +1,78 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/klausuren/add.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Klausur hinzufügen{% endblock %}
+{% block header %}Klausur hinzufügen{% endblock %}
+
+{% block js_body_end %}
+ var startperiod_input = document.getElementById('startperiod-input');
+ var endperiod_input = document.getElementById('endperiod-input');
+
+ startperiod_input.onchange = function () {
+ endperiod_input.min = parseInt(startperiod_input.value);
+ }
+
+ // beim Laden der Seite einmal ausführen
+ startperiod_input.onchange();
+{% endblock %}
+
+{% block content %}
+
+
+
+
Stufe:
+
{{ stufe.name }}
+
+
+
+
Kurslehrer(in):
+
+
+ Bitte auswählen
+ {% for l in Lehrer.query.order_by(Lehrer.kuerzel).all() %}
+ {{ l.kuerzel }}
+ {% endfor %}
+
+
+
+
+
+
+
+
+
+{% endblock %}
diff --git a/nateman/templates/klausuren/edit.html.j2 b/nateman/templates/klausuren/edit.html.j2
new file mode 100644
index 0000000..8642f47
--- /dev/null
+++ b/nateman/templates/klausuren/edit.html.j2
@@ -0,0 +1,348 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/klausuren/edit.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}
+ Klausur: {{ klausur.kursname }}
+ ({{ klausur.date_formatted() }}; {{ klausur.lehrer.kuerzel }}, {{ klausur.stufe.name }})
+{% endblock %}
+{% block header %}
+ Klausur: {{ klausur.kursname }}
+ ({{ klausur.date_formatted() }}; {{ klausur.lehrer.kuerzel }}, {{ klausur.stufe.name }})
+{% endblock %}
+
+{# klausur #}
+{# kt_list: Liste aller Klausurteilnahmen dieser Klausur #}
+{# not_in_klausur_list: Liste aller Schüler dieser Stufe, die nicht in dieser Klausur sind #}
+{% set lehrer_can_access = g.lehrer.can_access(klausur.stufe) %}
+{% set is_bygone = klausur.is_bygone() %}
+{% set no_edit = (klausur.edited or not is_bygone) and not lehrer_can_access %}
+
+
+{% block js_body_end %}
+ var schuelerCBs = document.getElementsByClassName("schueler-cb");
+
+ for (scb of schuelerCBs) {
+ scb.onchange = function () {
+ if (this.checked) {
+ this.parentNode.classList.add("marked");
+ } else {
+ this.parentNode.classList.remove("marked");
+ }
+ }
+
+ // beim Laden der Seite einmal ausführen
+ scb.onchange();
+ }
+
+ {% if not no_edit %}
+
+ var noneVersaeumtCB = document.getElementById("none-versaeumt");
+
+ noneVersaeumtCB.onchange = function () {
+ for (scb of schuelerCBs) {
+ scb.disabled = this.checked;
+ if (this.checked) {
+ scb.checked = false;
+ scb.onchange();
+ }
+ }
+ };
+
+ // beim Laden der Seite einmal ausführen
+ noneVersaeumtCB.onchange();
+
+ {% if lehrer_can_access %}
+ var laengeSelect = document.getElementById("laenge-select");
+ var flagAsEditedCb = document.getElementById("flag-as-edited-cb");
+ flagAsEditedCb.onchange = function () {
+ laengeSelect.required = this.checked;
+ }
+
+ // beim Laden der Seite einmal ausführen
+ flagAsEditedCb.onchange();
+ {% endif %}
+
+ var editSubmit = document.getElementById("edit-submit");
+ editSubmit.onclick = function () {
+ if (!noneVersaeumtCB.checked) {
+ var ok = false;
+ for (scb of schuelerCBs) {
+ if (scb.checked) {
+ ok = true;
+ break;
+ }
+ }
+
+ if (!ok {% if lehrer_can_access %} && flagAsEditedCb.checked {% endif %}) {
+ alert("Bitte wählen Sie etwas aus.");
+ return false;
+ }
+ }
+
+ {% if not lehrer_can_access %}
+ return confirm("Wollen Sie wirklich speichern?\nSie können die Klausur danach nicht mehr bearbeiten.");
+ {% else %}
+ return true;
+ {% endif %}
+ };
+
+
+ var selectNode = document.getElementById("added-schueler");
+ var addNewKoopSchuelerFormNode = document.getElementById("add-new-schueler-form");
+ var nksNachnameInputNode = document.getElementById("new-schueler-nachname-input");
+ var nksVornameInputNode = document.getElementById("new-schueler-vorname-input");
+
+ selectNode.onchange = function() {
+ if (selectNode.value === "new-schueler") {
+ addNewKoopSchuelerFormNode.style.display = "";
+ nksNachnameInputNode.required = true;
+ nksVornameInputNode.required = true;
+ } else {
+ addNewKoopSchuelerFormNode.style.display = "none";
+ nksNachnameInputNode.required = false;
+ nksVornameInputNode.required = false;
+ }
+ };
+
+ // beim Laden der Seite einmal ausführen
+ selectNode.onchange();
+ {% endif %}
+
+ {% if lehrer_can_access %}
+ var new_startperiod_input = document.getElementById('new-startperiod-input');
+ var new_endperiod_input = document.getElementById('new-endperiod-input');
+
+ new_startperiod_input.onchange = function () {
+ new_endperiod_input.min = parseInt(new_startperiod_input.value);
+ }
+
+ // beim Laden der Seite einmal ausführen
+ new_startperiod_input.onchange();
+ {% endif %}
+{% endblock %}
+
+
+{% block content %}
+
+{% if not is_bygone %}
+ Diese Klausur hat noch nicht stattgefunden.
+{% endif %}
+
+{% if klausur.edited %}
+ Diese Klausur wurde bereits bearbeitet.
+{% endif %}
+
+
+ {{ zeitraum(klausur) }} Stunde;
+ {{ Klausurteilnahme.query.filter_by(klausur_id=klausur.id).count() }} Schüler(innen)
+
+
+
+
+
+
+ Länge der Klausur:
+
+ Bitte auswählen
+ {% for l in nateman_config['klausuren']['klausurlaengen'] %}
+ {{ l }} Minuten
+ {% endfor %}
+
+
+
+
+ {% if not no_edit %}
+
+ Setzen Sie entweder ein Häkchen dafür, dass kein(e) Schüler(in) die Klausur versäumt hat
+ oder setzen Sie ein Häkchen bei allen Schüler(inne)n, die die Klausur versäumt haben.
+ Gehört ein(e) Schüler(in) nicht mehr zum Kurs, entfernen Sie diese(n) durch Anklicken von 'x'.
+ Klicken Sie anschließend auf 'Speichern'.
+
+ {% endif %}
+
+
+
+
+ kein(e) Schüler(in) hat versäumt
+
+
+
+ {% for kt in kt_list %}
+
+
+ {{ kt.schueler.nachname }}, {{ kt.schueler.vorname }}
+
+ ({% if kt.schueler.stammschule is not none %}{{ kt.schueler.stammschule.name }},
+ {% endif %}{{ kt.schueler.id }})
+
+
+
+
+ {% endfor %}
+
+
+
+ Bemerkung:
+
+
+
+ {% if lehrer_can_access %}
+
+
+
+ als bearbeitet markieren
+
+
+ {% endif %}
+
+
+
+
+
+
+
+
+{% if not no_edit %}
+
+
+
+
+
+
+ Fügen Sie eine(n) Schüler(in) hinzu, falls der/die Schüler(in) nicht bereits
+ automatisch in der obigen Liste aufgeführt sein sollte.
+ Nach dem Hinzufügen kann der/die Schüler(in) als versäumend markiert werden.
+
+
+ Schüler(in) hinzufügen:
+
+ Bitte auswählen
+ Neue(n) Schüler(in) hinzufügen...
+ {% for schueler in not_in_klausur_list %}
+ {{ schueler.nachname }}, {{ schueler.vorname }}
+ ({% if schueler.stammschule is not none %}{{ schueler.stammschule.name }}, {% endif %}{{ schueler.id }})
+
+ {% endfor %}
+
+
+
+
+
+
+ Hinzufügen zu dieser Klausur
+ Hinzufügen zu allen Klausuren dieses Kurses
+
+
+
+
+
+ {% if lehrer_can_access %}
+
+ Erweiterte Einstellungen
+
+
+
+
+
+
Kurslehrer(in):
+
+
+ {% for l in Lehrer.query.order_by(Lehrer.kuerzel).all() %}
+ {{ l.kuerzel }}
+ {% endfor %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% endif %}
+
+{% endif %}
+{% endblock %}
diff --git a/nateman/templates/klausuren/mine.html.j2 b/nateman/templates/klausuren/mine.html.j2
new file mode 100644
index 0000000..6db4cdc
--- /dev/null
+++ b/nateman/templates/klausuren/mine.html.j2
@@ -0,0 +1,91 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/klausuren/mine.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Meine Klausuren{% endblock %}
+{% block header %}Meine Klausuren{% endblock %}
+
+{# klausuren_anstehend #}
+{# klausuren_vergangen #}
+
+{% block content %}
+
+vergangen:
+
+{% if klausuren_vergangen|length == 0 %}
+ keine
+{% else %}
+
+
+
+ Datum
+ Stufe
+ Kurs
+ Zeitraum
+ bearbeitet
+
+
+
+ {% for kv in klausuren_vergangen %}
+
+ {{ kv.date_formatted() }}
+ {{ kv.stufe.name }}
+ {{ kv.kursname }}
+ {{ zeitraum(kv) }} Std.
+ {% if kv.edited %}
+ ja
+ {% else %}
+ nein
+ {% endif %}
+
+ {% endfor %}
+
+
+{% endif %}
+
+
+anstehend:
+
+{% if klausuren_anstehend|length == 0 %}
+ keine
+{% else %}
+
+
+
+ Datum
+ Stufe
+ Kurs
+ Zeitraum
+
+
+
+ {% for ka in klausuren_anstehend %}
+
+ {{ ka.date_formatted() }}
+ {{ ka.stufe.name }}
+ {{ ka.kursname }}
+ {{ zeitraum(ka) }} Std.
+
+ {% endfor %}
+
+
+{% endif %}
+
+{% endblock %}
diff --git a/nateman/templates/klausuren/stufe.html.j2 b/nateman/templates/klausuren/stufe.html.j2
new file mode 100644
index 0000000..f51c6d2
--- /dev/null
+++ b/nateman/templates/klausuren/stufe.html.j2
@@ -0,0 +1,113 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/klausuren/stufe.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Klausuren {{ stufe.name }}{% endblock %}
+{% block header %}Klausuren {{ stufe.name }}{% endblock %}
+
+{# stufe #}
+{# dates_anstehend #}
+{# dates_vergangen #}
+{% set lehrer_can_access = g.lehrer is not none and g.lehrer.can_access(stufe) %}
+{% set klausur_count = dates_anstehend | length + dates_vergangen | length %}
+{% set beratungslehrer_list = Lehrer.query.filter_by(beraet=stufe).all() %}
+
+{% block content %}
+
+
+ Beratungslehrer(innen):
+ {% if beratungslehrer_list|length == 0 %}
+ keine
+ {% else %}
+ {% for l in beratungslehrer_list %}
+ {{ l.kuerzel }}{% if l.email is not none %} <{{ l.email }} >{% endif %}{% if not loop.last %},{% endif %}
+ {% endfor %}
+ {% endif %}
+
+
+{% if lehrer_can_access %}
+ Klausur hinzufügen
+{% endif %}
+
+{% if klausur_count != 0 %}
+ zu heute springen
+{% endif %}
+
+{% if klausur_count == 0 %}
+ keine
+{% else %}
+ {% for dates_list in (dates_anstehend, dates_vergangen) %}
+ {% if loop.index0 == 1 %}
+ heute ({{ util.format_date(datetime.now()) }})
+ {% endif %}
+
+ {% for date in dates_list %}
+ {% set date_klausur_list = Klausur.query.filter_by(stufe=stufe, date=date).all() %}
+ {% set date_iso = date.strftime('%Y-%m-%d') %}
+
+
+
+ {{ util.format_date(date) }}:
+
+
+
+
+
+
+
+ Lehrer(in)
+ Kurs
+ Zeitraum
+ {% if lehrer_can_access %}
+ bearbeitet
+ Bemerkung
+ {% endif %}
+
+
+
+ {% for k in date_klausur_list %}
+
+ {{ k.lehrer.kuerzel }}
+ {{ k.kursname }}
+ {{ zeitraum(k) }} Std.
+ {% if lehrer_can_access %}
+ {% if k.edited %}
+ ja
+ {% else %}
+ nein
+ {% endif %}
+
+ {% if k.annotation is not none %}
+ {{ k.annotation }}
+ {% else %}
+ keine
+ {% endif %}
+ {% endif %}
+
+ {% endfor %}
+
+
+ {% endfor %}
+ {% endfor %}
+{% endif %}
+
+{% endblock %}
diff --git a/nateman/templates/schueler/versaeumnisse.html.j2 b/nateman/templates/schueler/versaeumnisse.html.j2
new file mode 100644
index 0000000..7c2cdf5
--- /dev/null
+++ b/nateman/templates/schueler/versaeumnisse.html.j2
@@ -0,0 +1,94 @@
+{% extends 'base.html.j2' %}
+
+{#
+ NateMan – Nachschreibtermin-Manager
+ templates/schueler/versaeumnisse.html.j2
+ Copyright © 2020 Niklas Elsbrock
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Versäumnisse{% endblock %}
+{% block header %}Versäumnisse{% endblock %}
+
+{#
+ versaeumt_dict: Dictinonary mit jeweils eimem Tupel aus zwei Listen aller nicht nachgeschriebenen bzw.
+ nachgeschriebenen versäumten Klausurteilnahmen pro Stufe, auf die der angemeldete Lehrer Zugriff hat
+#}
+
+{% block content %}
+
+
+ {% for stufe, versaeumt_listen in versaeumt_dict.items() %}
+ {{ stufe.name }}
+
+ {% for versaeumt_list in versaeumt_listen %}
+
+ {% if loop.first %}
+ noch nicht nachgeschrieben:
+ {% else %}
+ bereits nachgeschrieben:
+ {% endif %}
+
+ {% if versaeumt_list|length == 0 %}
+ keine
+ {% else %}
+
+ {% endif %}
+ {% endfor %}
+
+ {% endfor %}
+
+
+
+
+{% endblock %}
diff --git a/nateman/util.py b/nateman/util.py
new file mode 100644
index 0000000..3d6a35a
--- /dev/null
+++ b/nateman/util.py
@@ -0,0 +1,104 @@
+# NateMan – Nachschreibtermin-Manager
+# util.py
+# Copyright © 2020 Niklas Elsbrock
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""
+Enthält nützliche, von NateMan unabhängige Funktionen.
+"""
+
+import random
+import re
+
+from datetime import date
+
+EMAIL_ADDRESS_REGEX = re.compile(r"^[a-zA-Z0-9!#$%&‘*+–/=?^_`{|}~](\.?[a-zA-Z0-9!#$%&‘*+–/=?^_`{|}~])*"
+ r"@[a-zA-Z0-9-](\.?[a-zA-Z0-9-])*$")
+
+_RUASS_TRANSLATION = {ord("ä"): "ae", ord("Ä"): "Ae",
+ ord("ö"): "oe", ord("Ö"): "Oe",
+ ord("ü"): "ue", ord("Ü"): "Ue",
+ ord("ß"): "ss", ord("ẞ"): "Ss"}
+""" Übersetzungstabelle für replace_umlauts_and_sharp_s """
+
+
+def email_address_safe(s: str) -> str:
+ """
+ Ersetzt die Buchstaben ä, ö, ü und ß (als Klein- oder Großbuchstabe) im String s durch die entsprechende
+ Zeichenfolge ohne Umlaute bzw. Eszett und wandelt alle Buchstaben in Kleinbuchstaben um.
+ von Niklas Elsbrock.
+ """
+ return s.translate({
+ ord("ä"): "ae", ord("Ä"): "Ae",
+ ord("ö"): "oe", ord("Ö"): "Oe",
+ ord("ü"): "ue", ord("Ü"): "Ue",
+ ord("ß"): "ss", ord("ẞ"): "Ss"
+ }).lower()
+
+
+_URI_SAFE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
+""" Zeichensatz für :func:`random_uri_safe_string` """
+
+_SYSTEM_RANDOM = random.SystemRandom()
+
+
+def random_uri_safe_string(length: int) -> str:
+ """
+ Generiert einen zufälligen String der Länge ``length`` aus URI-freundlichen Zeichen
+ (Buchstaben, Bindestrich, Unterstrich).
+ von Niklas Elsbrock.
+
+ :param length: Länge des zu generierenden Strings
+ :return: generierter String
+ """
+ return "".join(_SYSTEM_RANDOM.choice(_URI_SAFE_CHARS) for _ in range(length))
+
+
+def validate_bcrypt_password(password: str) -> bool:
+ """
+ Überprüft, ob der übergebene String ``password`` als Passwort verwendet werden kann
+ (d.h. ob das Passwort höchstens 72 Bytes groß ist).
+ von Niklas Elsbrock.
+
+ :param password: zu validierender String
+ :return: ``True`` falls ja, ``False`` falls nein
+ """
+ return len(password.encode("utf-8")) <= 72
+
+
+def format_date(date_: date) -> str:
+ """
+ Formatiert ein Datumsobjekt nach dem deutschen Datumsformat, inklusive Wochentagkürzel (WW, DD.MM.YYYY).
+ von Niklas Elsbrock.
+
+ :param date_: zu formatierendes Datum
+ :return: formatiertes Datum als String
+ """
+ return date_.strftime("%a, %d.%m.%Y")
+
+
+def is_integer_string(s: str) -> bool:
+ """
+ Überprüft, ob der String ``s`` in einen Integer umgewandelt werden kann
+
+ :param s: zu überprüfender String
+ :return: ``True`` falls ja, ``False`` falls nein
+ """
+ try:
+ int(s)
+ except ValueError:
+ return False
+ else:
+ return True
diff --git a/screenshots/klausurliste.png b/screenshots/klausurliste.png
new file mode 100644
index 0000000..ee20b88
Binary files /dev/null and b/screenshots/klausurliste.png differ
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..b0e03db
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,25 @@
+"""
+Setupskript.
+von Niklas Elsbrock
+"""
+
+from setuptools import find_packages, setup
+
+setup(
+ name="NateMan",
+ version="1.2.0",
+ author="Niklas Elsbrock, Johannes Bingel",
+ packages=find_packages(),
+ include_package_data=True,
+ zip_safe=False,
+ python_requires="~=3.6",
+ install_requires=[
+ "Flask",
+ "Flask-SQLAlchemy>=2.0.0",
+ "Click",
+ "PyYAML",
+ "bcrypt",
+ "openpyxl"
+ ],
+ entry_points={"console_scripts": ["nateman = nateman.commands:cli"]}
+)
diff --git a/wsgi.py b/wsgi.py
new file mode 100644
index 0000000..8aa589f
--- /dev/null
+++ b/wsgi.py
@@ -0,0 +1,12 @@
+"""
+WSGI-Schnittstelle. Startet NateMan.
+von Niklas Elsbrock
+"""
+
+from nateman import create_app
+
+
+if __name__ == "__main__":
+ create_app().run()
+else:
+ app = create_app()