postorius-1.2.4/ 0000775 0001750 0001750 00000000000 13427706007 014713 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/COPYING 0000664 0001750 0001750 00000104513 13413660001 015736 0 ustar maxking maxking 0000000 0000000 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
.
postorius-1.2.4/MANIFEST.in 0000664 0001750 0001750 00000000606 13413660001 016437 0 ustar maxking maxking 0000000 0000000 include COPYING
include *.rst
recursive-include src/postorius *.py *.html *.js *.rst *.txt
prune src/postorius/doc/_build
graft src/postorius/static
include src/postorius/doc/Makefile
include tox.ini
recursive-include example_project *.py *.cfg *.rst *.txt
exclude example_project/settings_local.py
prune example_project/venv
prune example_project/static
graft src/postorius/tests/fixtures
postorius-1.2.4/PKG-INFO 0000664 0001750 0001750 00000005700 13427706007 016012 0 ustar maxking maxking 0000000 0000000 Metadata-Version: 1.2
Name: postorius
Version: 1.2.4
Summary: A web user interface for GNU Mailman
Home-page: https://gitlab.com/mailman/postorius
Maintainer: The Mailman GSOC Coders
License: GPLv3
Description: ===================================
Postorius - web ui for GNU Mailman
===================================
.. image:: https://gitlab.com/mailman/postorius/badges/master/build.svg
:target: https://gitlab.com/mailman/postorius/commits/master
.. image:: https://readthedocs.org/projects/postorius/badge
:target: https://postorius.readthedocs.io
.. image:: https://gitlab.com/mailman/postorius/badges/master/coverage.svg?job=coverage
:target: https://mailman.gitlab.io/postorius
.. image:: http://img.shields.io/pypi/v/postorius.svg
:target: https://pypi.python.org/pypi/postorius
.. image:: http://img.shields.io/pypi/dm/postorius.svg
:target: https://pypi.python.org/pypi/postorius
Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
The Postorius Django app provides a web user interface to
access GNU Mailman.
Postorius is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, version 3 of the License.
Postorius 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 Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with mailman.client. If not, see .
Requirements
============
Postorius requires Python 3.5 or newer and mailmanclient, the official Python
bindings for GNU Mailman.
The minimum Django version is 1.11.
Postorius needs a running version of GNU Mailman version 3.2
Installation
============
To install GNU Mailman Suite follow the instructions in the documentation:
http://docs.mailman3.org/
Acknowledgements
================
Many thanks go out to Anna Senarclens de Grancy and Benedict Stein for
developing the initial versions of this Django app during the Google Summer of
Code 2010 and 2011.
Keywords: email mailman django
Platform: UNKNOWN
Classifier: Framework :: Django
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Topic :: Communications :: Email :: Mailing List Servers
Classifier: Programming Language :: Python :: 3
postorius-1.2.4/README.rst 0000664 0001750 0001750 00000003715 13427701763 016414 0 ustar maxking maxking 0000000 0000000 ===================================
Postorius - web ui for GNU Mailman
===================================
.. image:: https://gitlab.com/mailman/postorius/badges/master/build.svg
:target: https://gitlab.com/mailman/postorius/commits/master
.. image:: https://readthedocs.org/projects/postorius/badge
:target: https://postorius.readthedocs.io
.. image:: https://gitlab.com/mailman/postorius/badges/master/coverage.svg?job=coverage
:target: https://mailman.gitlab.io/postorius
.. image:: http://img.shields.io/pypi/v/postorius.svg
:target: https://pypi.python.org/pypi/postorius
.. image:: http://img.shields.io/pypi/dm/postorius.svg
:target: https://pypi.python.org/pypi/postorius
Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
The Postorius Django app provides a web user interface to
access GNU Mailman.
Postorius is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, version 3 of the License.
Postorius 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 Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with mailman.client. If not, see .
Requirements
============
Postorius requires Python 3.5 or newer and mailmanclient, the official Python
bindings for GNU Mailman.
The minimum Django version is 1.11.
Postorius needs a running version of GNU Mailman version 3.2
Installation
============
To install GNU Mailman Suite follow the instructions in the documentation:
http://docs.mailman3.org/
Acknowledgements
================
Many thanks go out to Anna Senarclens de Grancy and Benedict Stein for
developing the initial versions of this Django app during the Google Summer of
Code 2010 and 2011.
postorius-1.2.4/example_project/ 0000775 0001750 0001750 00000000000 13427706007 020074 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/example_project/README.rst 0000664 0001750 0001750 00000002111 13413660001 021542 0 ustar maxking maxking 0000000 0000000 ===============================
Running the example application
===============================
Assuming you use virtualenv, follow these steps to download and run the
postorius example application in this directory:
::
$ git clone https://gitlab.com/mailman/postorius.git
$ cd postorius/example_project
$ virtualenv venv
$ . venv/bin/activate
$ pip install -r requirements.txt
Now we need to create the database tables and an admin user.
Run the following and when prompted to create a
superuser choose yes and follow the instructions:
::
$ python manage.py migrate
$ python manage.py createsuperuser
Now you need to run the Django development server:
::
$ python manage.py runserver
You should then be able to open your browser on http://127.0.0.1:8000 and see
postorius running.
If you are using the example_application for development, you have to install
postorius and mailmanclient another way. Be sure to have the virtualenv
activated and from the base directory of the respective repositories
you should run:
::
$ python setup.py develop
postorius-1.2.4/example_project/__init__.py 0000664 0001750 0001750 00000000000 13413660001 022157 0 ustar maxking maxking 0000000 0000000 postorius-1.2.4/example_project/mailman.cfg 0000664 0001750 0001750 00000000503 13413660001 022155 0 ustar maxking maxking 0000000 0000000 # Example Mailman config file suitable for testing
[devmode]
enabled: yes
testing: yes
recipient: you@yourdomain.com
[mta]
smtp_port: 9025
lmtp_port: 9024
incoming: mailman.testing.mta.FakeMTA
[webservice]
port: 9001
[archiver.mhonarc]
enable: yes
[archiver.mail_archive]
enable: yes
[archiver.prototype]
enable: yes
postorius-1.2.4/example_project/manage.py 0000775 0001750 0001750 00000001742 13414502172 021676 0 ustar maxking maxking 0000000 0000000 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
postorius-1.2.4/example_project/settings.py 0000664 0001750 0001750 00000020041 13414502172 022274 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
"""
Django settings for postorius project.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '$!-7^wl#wiifjbh)5@f7ji%x!vp7s1vzbvwt26hxv$idixq0u0'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ADMINS = (
#('Admin', 'webmaster@example.com'),
)
SITE_ID = 1
ALLOWED_HOSTS = []
# Mailman API credentials
MAILMAN_REST_API_URL = 'http://localhost:8001'
MAILMAN_REST_API_USER = 'restadmin'
MAILMAN_REST_API_PASS = 'restpass'
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'postorius',
'django_mailman3',
'django_gravatar',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.openid',
'django_mailman3.lib.auth.fedora',
'allauth.socialaccount.providers.github',
'allauth.socialaccount.providers.gitlab',
'allauth.socialaccount.providers.google',
# 'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.twitter',
'allauth.socialaccount.providers.stackexchange',
)
MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'postorius.middleware.PostoriusMiddleware',
)
# Set `postorius.urls` as main url config if Postorius
# is the only app you want to serve.
ROOT_URLCONF = 'urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.template.context_processors.csrf',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django_mailman3.context_processors.common',
'postorius.context_processors.postorius',
],
},
},
]
WSGI_APPLICATION = 'wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'postorius.db'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'
LOGIN_URL = 'account_login'
LOGIN_REDIRECT_URL = 'list_index'
LOGOUT_URL = 'account_logout'
# From Address for emails sent to users
DEFAULT_FROM_EMAIL = 'postorius@localhost.local'
# From Address for emails sent to admins
SERVER_EMAIL = 'root@localhost.local'
# Compatibility with Bootstrap 3
from django.contrib.messages import constants as messages
MESSAGE_TAGS = {
messages.ERROR: 'danger'
}
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)
# Django Allauth
ACCOUNT_AUTHENTICATION_METHOD = "username_email"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
ACCOUNT_UNIQUE_EMAIL = True
SOCIALACCOUNT_PROVIDERS = {
'openid': {
'SERVERS': [
dict(id='yahoo',
name='Yahoo',
openid_url='http://me.yahoo.com'),
],
},
'google': {
'SCOPE': ['profile', 'email'],
'AUTH_PARAMS': {'access_type': 'online'},
},
'facebook': {
'METHOD': 'oauth2',
'SCOPE': ['email'],
'FIELDS': [
'email',
'name',
'first_name',
'last_name',
'locale',
'timezone',
],
'VERSION': 'v2.4',
},
}
# These can be set to override the defaults but are not mandatory:
# EMAIL_CONFIRMATION_TEMPLATE = 'postorius/address_confirmation_message.txt'
# EMAIL_CONFIRMATION_SUBJECT = 'Confirmation needed'
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
'file':{
'level': 'INFO',
#'class': 'logging.handlers.RotatingFileHandler',
'class': 'logging.handlers.WatchedFileHandler',
'filename': os.path.join(BASE_DIR, 'logs', 'postorius.log'),
'formatter': 'verbose',
},
},
'loggers': {
'django': {
'handlers': ['console', 'file'],
'level': 'INFO',
},
'django.request': {
'handlers': ['console', 'file'],
'level': 'ERROR',
},
'postorius': {
'handlers': ['console', 'file'],
'level': 'INFO',
},
},
'formatters': {
'simple': {
'format': '%(levelname)s: %(message)s'
},
'verbose': {
'format': '%(levelname)s %(asctime)s %(process)d %(name)s %(message)s'
},
},
}
POSTORIUS_TEMPLATE_BASE_URL = "http://localhost:8000"
try:
from settings_local import *
except ImportError:
pass
postorius-1.2.4/example_project/test_settings.py 0000664 0001750 0001750 00000003222 13414502172 023335 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
"""
Django test settings for postorius project.
"""
from settings import *
TESTING = True
# Mailman API credentials for testing
MAILMAN_REST_API_URL = 'http://localhost:9001'
MAILMAN_REST_API_USER = 'restadmin'
MAILMAN_REST_API_PASS = 'restpass'
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'verbose',
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': 'INFO',
},
'django.request': {
'handlers': ['console'],
'level': 'ERROR',
},
'postorius': {
'handlers': ['console'],
'level': 'INFO',
},
},
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(process)d %(name)s %(message)s'
},
},
}
postorius-1.2.4/example_project/urls.py 0000664 0001750 0001750 00000003103 13414502172 021421 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
from django.conf.urls import include, url
from django.contrib import admin
from django.http import Http404
from django.urls import reverse_lazy
from django.views.generic import RedirectView
from django.views.defaults import server_error
def not_found(request):
"""A test view to return 404 error to test 400.html"""
raise Http404('Page not Found.')
urlpatterns = [
url(r'^$', RedirectView.as_view(
url=reverse_lazy('list_index'),
permanent=True)),
url(r'^postorius/', include('postorius.urls')),
url(r'', include('django_mailman3.urls')),
url(r'^accounts/', include('allauth.urls')),
# Add some testing routes to test 400/500 error pages without having to
# introduce errors.
url(r'500/$', server_error),
url(r'400/$', not_found),
# Django admin
url(r'^admin/', admin.site.urls),
]
postorius-1.2.4/example_project/wsgi.py 0000775 0001750 0001750 00000000573 13413660001 021413 0 ustar maxking maxking 0000000 0000000 """
WSGI config for meh project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
application = get_wsgi_application()
postorius-1.2.4/setup.cfg 0000664 0001750 0001750 00000000126 13427706007 016533 0 ustar maxking maxking 0000000 0000000 [build_sphinx]
source_dir = src/postorius/doc/
[egg_info]
tag_build =
tag_date = 0
postorius-1.2.4/setup.py 0000664 0001750 0001750 00000004035 13415037302 016417 0 ustar maxking maxking 0000000 0000000 # Copyright (C) 2012-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# Postorius 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 Lesser General Public License
# for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Postorius. If not, see .
import re
import sys
from setuptools import setup, find_packages
# Calculate the version number without importing the postorius package.
with open('src/postorius/__init__.py') as fp:
for line in fp:
mo = re.match("__version__ = '(?P[^']+?)'", line)
if mo:
__version__ = mo.group('version')
break
else:
print('No version number found')
sys.exit(1)
setup(
name="postorius",
version=__version__,
description="A web user interface for GNU Mailman",
long_description=open('README.rst').read(),
maintainer="The Mailman GSOC Coders",
license='GPLv3',
keywords='email mailman django',
url=" https://gitlab.com/mailman/postorius",
classifiers=[
"Framework :: Django",
"Development Status :: 4 - Beta",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Topic :: Communications :: Email :: Mailing List Servers",
"Programming Language :: Python :: 3",
],
packages=find_packages('src'),
package_dir={'': 'src'},
include_package_data=True,
install_requires=[
'Django>=1.11,<2.2',
'django-mailman3>=1.2.0a1',
'mailmanclient>=3.2.1'
],
tests_require=[
"mock",
"vcrpy",
"beautifulsoup4",
],
)
postorius-1.2.4/src/ 0000775 0001750 0001750 00000000000 13427706007 015502 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/ 0000775 0001750 0001750 00000000000 13427706007 017551 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/__init__.py 0000664 0001750 0001750 00000001475 13427701745 021675 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
__version__ = '1.2.4'
default_app_config = 'postorius.apps.PostoriusConfig'
postorius-1.2.4/src/postorius/apps.py 0000664 0001750 0001750 00000001555 13414502172 021065 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2016-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
from django.apps import AppConfig
class PostoriusConfig(AppConfig):
name = 'postorius'
verbose_name = "Postorius"
postorius-1.2.4/src/postorius/auth/ 0000775 0001750 0001750 00000000000 13427706007 020512 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/auth/__init__.py 0000664 0001750 0001750 00000000000 13413660001 022575 0 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/auth/decorators.py 0000664 0001750 0001750 00000004765 13414502172 023236 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
"""Postorius view decorators."""
from django.core.exceptions import PermissionDenied
from postorius.auth.utils import set_list_access_props
def list_owner_required(fn):
"""Check if the logged in user is the list owner of the given list.
Assumes that the request object is the first arg and that list_id
is present in kwargs.
"""
def wrapper(*args, **kwargs):
user = args[0].user
list_id = kwargs['list_id']
if not user.is_authenticated:
raise PermissionDenied
if user.is_superuser:
return fn(*args, **kwargs)
set_list_access_props(user, list_id)
if user.is_list_owner:
return fn(*args, **kwargs)
else:
raise PermissionDenied
return wrapper
def list_moderator_required(fn):
"""Check if the logged in user is a moderator of the given list.
Assumes that the request object is the first arg and that list_id
is present in kwargs.
"""
def wrapper(*args, **kwargs):
user = args[0].user
list_id = kwargs['list_id']
if not user.is_authenticated:
raise PermissionDenied
if user.is_superuser:
return fn(*args, **kwargs)
set_list_access_props(user, list_id)
if user.is_list_owner or user.is_list_moderator:
return fn(*args, **kwargs)
else:
raise PermissionDenied
return wrapper
def superuser_required(fn):
"""Make sure that the logged in user is a superuser or otherwise raise
PermissionDenied.
Assumes the request object to be the first arg."""
def wrapper(*args, **kwargs):
user = args[0].user
if not user.is_superuser:
raise PermissionDenied
return fn(*args, **kwargs)
return wrapper
postorius-1.2.4/src/postorius/auth/mixins.py 0000664 0001750 0001750 00000004372 13414502172 022372 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2018-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
#
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
from postorius.auth.utils import set_domain_access_props, set_list_access_props
class ListOwnerMixin(LoginRequiredMixin, UserPassesTestMixin):
"""Mixin to allow access to only List owners."""
raise_exception = True
def test_func(self):
user = self.request.user
mlist_id = self.kwargs['list_id']
if user.is_superuser:
return True
set_list_access_props(user, mlist_id)
return user.is_list_owner
class ListModeratorMixin(LoginRequiredMixin, UserPassesTestMixin):
"""Mixin to allow access to only List Moderators."""
raise_exception = True
def test_func(self):
user = self.request.user
mlist_id = self.kwargs['list_id']
if user.is_superuser:
return True
set_list_access_props(user, mlist_id)
return user.is_list_owner or user.is_list_moderator
class DomainOwnerMixin(LoginRequiredMixin, UserPassesTestMixin):
"""Mixin to allow access to only Domain Owner."""
raise_exception = True
def test_func(self):
user = self.request.user
domain = self.kwargs['domain']
if user.is_superuser:
return True
set_domain_access_props(user, domain)
return user.is_domain_owner
class SuperUserRequiredMixin(LoginRequiredMixin, UserPassesTestMixin):
"""Mixin to allow access to only Django Superusers."""
def test_func(self):
return self.request.user.is_superuser
postorius-1.2.4/src/postorius/auth/utils.py 0000664 0001750 0001750 00000006357 13414502172 022230 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
"""
Authentication and authorization-related utilities.
"""
from allauth.account.models import EmailAddress
from django.utils import six
from postorius.models import Domain, List
def user_is_in_list_roster(user, mailing_list, roster):
"""Checks if a user is in a MailingList roster.
:param user: User to check access permissions for.
:type user: django.contrib.auth.model.User
:param mailing_list: MailingList to check permissions for.
:type mailing_list: postorius.models.List
:param roster: Access permissions required.
:type roster: str
"""
if not user.is_authenticated:
return False
addresses = set(EmailAddress.objects.filter(
user=user, verified=True).values_list("email", flat=True))
roster_addresses = set(
[member.email for member in getattr(mailing_list, roster)]
)
if addresses & roster_addresses:
return True # At least one address is in the roster
return False
def set_list_access_props(user, mlist):
"""Update user's access permissions of a MailingList.
:param user: The user to check permissions for.
:type user: django.contrib.auth.model.User
:param mlist: MailingList to check permissions for.
:type mlist: postorius.models.List
"""
if isinstance(mlist, six.string_types):
mlist = List.objects.get_or_404(mlist)
if not hasattr(user, 'is_list_owner'):
user.is_list_owner = user_is_in_list_roster(
user, mlist, "owners")
if not hasattr(user, 'is_list_moderator'):
user.is_list_moderator = user_is_in_list_roster(
user, mlist, "moderators")
def set_domain_access_props(user, domain):
"""Update user's access permissions for a domain.
:param user: The user to check permissions for.
:type user: django.contrib.auth.model.User
:param domain: Domain to check permissions for.
:type domain: postorius.models.Domain
"""
# TODO: This is very slow as it involves first iterating over every domain
# owner and then each of their addresses. Create an API in Core to
# facilitate this.
if isinstance(domain, six.string_types):
domain = Domain.objects.get_or_404(domain)
owner_addresses = []
for owner in domain.owners:
owner_addresses.extend(owner.addresses)
owner_addresses = set([each.email for each in owner_addresses])
user_addresses = set(EmailAddress.objects.filter(
user=user, verified=True).values_list("email", flat=True))
user.is_domain_owner = owner_addresses & user_addresses
postorius-1.2.4/src/postorius/context_processors.py 0000664 0001750 0001750 00000001704 13414502172 024064 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2012-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
import logging
from postorius import __version__
logger = logging.getLogger(__name__)
def postorius(request):
"""Add template variables to context.
"""
return dict(POSTORIUS_VERSION=__version__)
postorius-1.2.4/src/postorius/doc/ 0000775 0001750 0001750 00000000000 13427706007 020316 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/doc/Makefile 0000664 0001750 0001750 00000010776 13413660001 021755 0 ustar maxking maxking 0000000 0000000 # Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
help:
@echo "Please use \`make ' where is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/mailmanweb.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/mailmanweb.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/mailmanweb"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/mailmanweb"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
make -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
postorius-1.2.4/src/postorius/doc/__init__.py 0000664 0001750 0001750 00000000000 13413660001 022401 0 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/doc/conf.py 0000664 0001750 0001750 00000020635 13413660001 021607 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
#
# Postorius documentation build configuration file, created by
# sphinx-quickstart on Wed Aug 17 15:43:10 2011.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
# add dummy settings environment variable so sphinx can import from Postorius.
os.environ['DJANGO_SETTINGS_MODULE'] = 'postorius.doc.settings'
# import the source code directory into Python Path for use with Auto Module
APP_ROOT = os.path.dirname(__file__)
sys.path.insert(0, os.path.split(APP_ROOT)[0])
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
#extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo',
# 'sphinx.ext.coverage', 'sphinx.ext.viewcode']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = 'Postorius'
copyright = '2012, The Free Software Foundation'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.0'
# The full version, including alpha/beta/rc tags.
release = '1.0.2'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output --------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# " v documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'postoriusdoc'
# -- Options for LaTeX output -------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual])
latex_documents = [
('index', 'postoriusweb.tex', 'Postorius Documentation',
'Mailman Coders', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output -------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'postorius', 'Postorius Documentation',
['Mailman Coders'], 1)
]
# -- Options for Epub output --------------------------------------------------
# Bibliographic Dublin Core info.
epub_title = 'postorius'
epub_author = 'Mailman Coders'
epub_publisher = 'Mailman Coders'
epub_copyright = '2012, The Free Software Foundation'
# The language of the text. It defaults to the language option
# or en if the language is not set.
#epub_language = ''
# The scheme of the identifier. Typical schemes are ISBN or URL.
#epub_scheme = ''
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#epub_identifier = ''
# A unique identification for the text.
#epub_uid = ''
# HTML files that should be inserted before the pages created by sphinx.
# The format is a list of tuples containing the path and title.
#epub_pre_files = []
# HTML files shat should be inserted after the pages created by sphinx.
# The format is a list of tuples containing the path and title.
#epub_post_files = []
# A list of files that should not be packed into the epub file.
#epub_exclude_files = []
# The depth of the table of contents in toc.ncx.
#epub_tocdepth = 3
# Allow duplicate toc entries.
#epub_tocdup = True
postorius-1.2.4/src/postorius/doc/deployment.rst 0000664 0001750 0001750 00000006341 13413660001 023220 0 ustar maxking maxking 0000000 0000000 ============
Deployment
============
Postorius support Python 3.5+ and Django 1.11+.
.. note::
This guide covers deployment options of Postorius.
Nginx with uwsgi
================
.. note::
Please refer to nginx and uwsgi documentation for explanation of the shown
snippets.
Below is an example uwsgi configuration file:
::
[uwsgi]
chdir = /srv/django/mailman
module = example_project.wsgi
virtualenv = /srv/django/mailman/env
master = true
processes = 4
socket = /run/uwsgi/mailman.sock
#chmod-socket = 666
vacuum = true
plugin = python2
uid = http
gid = http
And a nginx server section to with it:
::
upstream mailman {
server unix:///run/uwsgi/mailman.sock;
}
server {
listen 80;
# TODO Replace with your domain
server_name lists.example.com;
return 301 https://$server_name$request_uri;
}
## Config for server secured with https
server {
listen 443;
# TODO Replace with your domain
server_name lists.example.com;
ssl on;
# TODO Replace with your crt and key
ssl_certificate /etc/nginx/keys/lists.example.com.crt;
ssl_certificate_key /etc/nginx/keys/lists.example.com.key;
ssl_session_timeout 5m;
ssl_ciphers 'AES128+EECDH:AES128+EDH';
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
location /static {
# TODO Adjust to your static location
alias /srv/django/mailman/public/static;
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass mailman;
include /etc/nginx/uwsgi_params; # the uwsgi_params file you installed
}
}
Apache with mod_wsgi
====================
.. note::
This guide assumes that you know how to setup a VirtualHost with Apache.
If you are using SQLite, the ``.db`` file as well as its folder need to be
writable by the web server.
These settings need to be added to your Apache VirtualHost:
::
Alias /static /srv/django/mailman/public/static
Order deny,allow
Allow from all
WSGIScriptAlias / /srv/django/mailman/srv/postorius.wsgi
Order deny,allow
Allow from all
The first Alias serves the static files (CSS, JS, Images, etc.). The
WSGIScriptAlias serves the Django application. The paths need to be changed
depending on which location you have your postorius project in.
Final setup instructions
========================
We're almost ready. But you need to create translations and collect the static
files from Postorius (which resides somewhere on your pythonpath) to be able to
serve them from the site directory. All you have to do is to change into the
postorius project directory and run:
::
$ mkdir locale
$ python manage.py compilemessages
$ python manage.py collectstatic
After reloading the webserver Postorius should be running!
postorius-1.2.4/src/postorius/doc/development.rst 0000664 0001750 0001750 00000012255 13413660001 023363 0 ustar maxking maxking 0000000 0000000 ===========
Development
===========
This is a short guide to help you get started with Postorius development.
Development Workflow
====================
The source code is hosted on GitLab_, which means that we are using
Git for version control.
.. _GitLab: https://gitlab.com/mailman/postorius
Changes are not made directly in the project's master branch, but in
feature-related personal branches, which get reviewed and then merged into
the master branch. There is a contribution guide here_, that mentions the basics
about contributing to any mailman project.
.. _here: http://wiki.list.org/DEV/HowToContributeGit
An ideal workflow would be like this:
1. File a bug to suggest a new feature or report a bug (or just pick one of
the existing bugs).
2. Create a new branch with your code changes.
3. Make a "merge request" to get your code reviewed and merged.
First Contributions / Coverage Reports
======================================
If you don't know how you can contribute,
writing tests is a good way to get you started.
You can start by exploring the existing `test coverage`_
and finding code that's not covered ie. not tested.
.. _`test coverage`: https://mailman.gitlab.io/postorius/index.html
Installing and running the tests
================================
After checkout you can run the tests using ``tox``:
::
$ tox
By default this will test against a couple of different environments.
If you want to only run the tests in a specific environment or a single
module, you can specify this using the ``-e`` option and/or a double
dash:
::
# List all currently configured envs:
$ tox -l
py27-django18
py27-django19
# Test Django 1.8 on Python2.7 only:
$ tox -e py27-django18
# Run only tests in ``test_address_activation``:
$ tox -- postorius.tests.test_address_activation
# You get the idea...
$ tox -e py27-django18 -- postorius.tests.test_address_activation
All test modules reside in the ``postorius/src/postorius/tests``
directory. Please have a look at the existing examples.
Mocking calls to Mailman's REST API
===================================
A lot of Postorius' code involves calls to Mailman's REST API (through
the mailman.client library). Running these tests against a real instance
of Mailman would be bad practice and slow, so ``vcrpy`` *cassettes* are
used instead (see the `vcrpy Documentation`_ for details). These files
contain pre-recorded HTTP responses.
.. _`vcrpy Documentation`: https://github.com/kevin1024/vcrpy
If you write new tests, it's advisable to add a separate fixture file
for each test case, so the cached responses don't interfere with other
tests. The cassette files are stored in the
``tests/fixtures/vcr_cassettes`` directory. Check out the existing test
cases for examples.
In order to record new API responses for your test case, you need to
first start the mailman core, with the API server listening on port
9001. You can use the ``example_project/mailman.cfg`` file from the
Postorius source.
.. note::
Make sure, you use a fresh mailman.db file.
Once the core is running, you can record the new cassette file defined
in your test case by running tox with the `record` test env:
::
# This will only record the cassette files defined in my_new_test_module:
$ tox -e record -- postorius.tests.my_new_test_module
# This will re-record all cassette files:
$ tox -e record
View Auth
=========
Three of Django's default User roles are relvant for Postorius:
- Superuser: Can do everything.
- AnonymousUser: Can view list index and info pages.
- Authenticated users: Can view list index and info pages. Can (un)subscribe
from lists.
Apart from these default roles, there are two others relevant in Postorius:
- List owners: Can change list settings, moderate messages and delete their
lists.
- List moderators: Can moderate messages.
There are a number of decorators to protect views from unauthorized users.
- ``@user_passes_test(lambda u: u.is_superuser)`` (redirects to login form)
- ``@login_required`` (redirects to login form)
- ``@list_owner_required`` (returns 403 if logged-in user isn't the
list's owner)
- ``@list_moderator_required`` (returns 403 if logged-in user isn't the
list's moderator)
Accessing the Mailman API
=========================
Postorius uses mailmanclient to connect to Mailman's REST API. In order to
directly use the client, ``cd`` to the ``example_project`` folder and execute
``python manage.py mmclient``. This will open a python shell (IPython, if
that's available) and provide you with a client object connected to to your
local Mailman API server (it uses the credentials from your settings.py).
A quick example:
::
$ python manage.py mmclient
>>> client
>>> print(client.system['mailman_version'])
GNU Mailman 3.0.0b2+ (Here Again)
>>> mailman_dev = client.get_list('mailman-developers@python.org')
>>> print(mailman_dev.settings)
{u'description': u'Mailman development',
u'default_nonmember_action': u'hold', ...}
For detailed information how to use mailmanclient, check out its documentation_.
.. _documentation: http://docs.mailman3.org/projects/mailmanclient/en/latest/using.html
postorius-1.2.4/src/postorius/doc/index.rst 0000664 0001750 0001750 00000000243 13427701763 022162 0 ustar maxking maxking 0000000 0000000 .. include:: ../../../README.rst
Table of Contents
-----------------
.. toctree::
:maxdepth: 1
setup.rst
development.rst
deployment.rst
news.rst
postorius-1.2.4/src/postorius/doc/news.rst 0000664 0001750 0001750 00000022303 13427702102 022014 0 ustar maxking maxking 0000000 0000000 ================
News / Changelog
================
The Postorius Django app provides a web user interface to
access GNU Mailman.
Postorius is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, version 3 of the License.
Postorius 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 Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Postorius. If not, see .
1.2.4
=====
(2019-02-09)
* Add support for ``explicit_header_only`` in list settings.
(See !369)
1.2.3
=====
(2019-01-19)
* Expose ``max_num_recipients`` in list settings. (Closes #297)
* Add support for Non-member management in Postorius. (Closes #265)
* `Members` tab in Mailing List settings page is now called `Users`.
(Closes #309)
* Show pending subscription requests are only pending for Moderator.
(Closes #314)
1.2.2
=====
(2018-08-30)
* Add support for Python 3.7 with Django 2.0+
* Index page only shows related lists for signed-in users with option to
filter based on role.
* Expose respond_to_post_requests in Postorius. (Closes #223)
1.2.1
=====
(2018-07-11)
* A Django migration was missing from version 1.2.0. This is now added.
1.2
===
(2018-07-10)
* Postorius now runs only on Python 3.4+ and supports Django 1.8 and 1.11+
* Added the ability to set and edit ``alias_domain`` to the ``domains`` forms.
* List Create form now allows selecting the ``style``. A ``style`` is how a new
mailing list is configured.
* Minimum supported Mailman Core version is now 3.2.0. This is because the
``styles`` attribute for MailingList resource is exposed in 3.2, which
contains all the default ``styles`` supported by Core and their human readable
description.
* Account subscription page now lists all the memberships with their respective
roles. This avoids repeated API calls for the way data was displayed
before. (Closes #205)
* Postorius now supports only Django 1.11+.
* Duplicate MailingList names doesn't return a 500 error page and instead adds
an error to the New MailingList form. (Fixes #237)
* Pending subscription requests page is now paginated. (See !298)
* Add owners/moderators form now allows specifying a Display Name, along with
their email. (Fixes #254)
* Members views now show total number of members at the top. (See !315)
* Fixed a bug where GET on views that only expect a POST would cause 500 server
errors instead of 405 method not allowed. (Fixes #185)
* Member preferences form can now be saved without having to change all the
fields. (Fixes #178)
* Fixed a bug where the 'Delete' button to remove list owners didn't work due to
wrong URL being rendered in the templates. (Fixes #274)
* Require Explicit Destination is added to the Message Acceptance form.
(Closes #277)
* Delete Domain page now shows some extra warning information about all the
mailing lists that would be deleted after deleting the Domain. (See !250)
* Superusers can now view Mailman Core's current version and REST API version
being used under 'System Information' menu in the top navigation bar. (See !325)
* Fixed a bug where 500 error template wouldn't render properly due to missing
context variables in views that render that templates (See !334)
* Postorius now allows adding and editing templates for email headers, footers
and some of the automatic responses sent out by Mailman. (See !327)
1.1.2
=====
(2017-12-27)
* Added a new ``reset_passwords`` command that resets _all_ user's passwords
inside of Core. This password is different from the one Postorius
maintains. The Postorius password is the one used for logging users in.
* Postorius now sets the 'Display Name' of the user in Core correctly. This
fixes a security vulnerability where user's display_name would be set as their
Core's password.
1.1.1
=====
(2017-11-17)
* Improved testing and internal bug fixes.
* Preserve formatting of Mailing List description in the summary view.
* Site's Name isn't capitalized anymore in the navigation bar.
* html5shiv and response.js libraries are now included, instead of loading from a CDN.
1.1.0 -- "Welcome to This World"
================================
(2017-05-26)
* Added DMARC mitigation settings
* Switch to Allauth auth library
* Preference page improvements
* Moderation page improvements
* Django support up to Django 1.11
* Added form to edit header matches
* Domain edit form improvements
* All pipelines recognized in alter messages form
* Use django-mailman3 to share common code with HyperKitty
* Various bug fixes, code cleanup, and performance improvements
1.0.3
=====
(2016-02-03)
* Fix security issue
1.0.2
=====
(2015-11-14)
* Bug fix release
1.0.1
=====
(2015-04-28)
* Help texts Small visual alignment fix; removed unnecessary links to
separate help pages.
* Import fix in fieldset_forms module (Django1.6 only)
1.0.0 -- "Frizzle Fry"
======================
(2015-04-17)
* French translation. Provided by Guillaume Libersat
* Addedd an improved test harness using WebTest. Contributed by Aurélien Bompard.
* Show error message in login view. Contributed by Aurélien Bompard (LP: 1094829).
* Fix adding the a list owner on list creation. Contributed by Aurélien Bompard (LP: 1175967).
* Fix untranslatable template strings. Contributed by Sumana Harihareswara (LP: 1157947).
* Fix wrong labels in metrics template. Contributed by Sumana Harihareswara (LP: 1409033).
* URLs now contain the list-id instead of the fqdn_listname. Contributed by Abhilash Raj (LP: 1201150).
* Fix small bug moderator/owner forms on list members page. Contributed by Pranjal Yadav (LP: 1308219).
* Fix broken translation string on the login page. Contributed by Pranjal Yadav.
* Show held message details in a modal window. Contributed by Abhilash Raj (LP: 1004049).
* Rework of internal testing
* Mozilla Persona integration: switch from django-social-auto to django-browserid: Contributed by Abhilash Raj.
* Fix manage.py mmclient command for non-IPython shells. Contributed by Ankush Sharma (LP: 1428169).
* Added archiver options: Site-wide enabled archivers can not be enabled
on a per-list basis through the web UI.
* Added functionality to choose or switch subscription addresses. Contributed by Abhilash Raj.
* Added subscription moderation, pre_verification/_confirmation.
* Several style changes.
1.0 beta 1 -- "Year of the Parrot"
==================================
(2014-04-22)
* fixed pip install (missing MANIFEST) (LP: 1307624). Contributed by Aurélien Bompard
* list owners: edit member preferences
* users: add multiple email addresses
* list info: show only subscribe or unsubscribe button. Contributed by Bhargav Golla
* remove members/owners/moderator. Contributed by Abhilash Raj
1.0 alpha 2 -- "Is It Luck?"
============================
(2014-03-15)
* dev setup fix for Django 1.4 contributed by Rohan Jain
* missing csrf tokens in templates contributed by Richard Wackerbarth (LP: 996658)
* moderation: fixed typo in success message call
* installation documentation for Apache/mod_wsgi
* moved project files to separate branch
* show error message if connection to Mailman API fails
* added list members view
* added developer documentation
* added test helper utils
* all code now conform to PEP8
* themes: removed obsolete MAILMAN_THEME settings from templates, contexts, file structure; contributed by Richard Wackerbarth (LP: 1043258)
* added access control for list owners and moderators
* added a mailmanclient shell to use as a `manage.py` command (`python manage.py mmclient`)
* use "url from future" template tag in all templates. Contributed by Richard Wackerbarth.
* added "new user" form. Contributed by George Chatzisofroniou.
* added user subscription page
* added decorator to allow login via http basic auth (to allow non-browser clients to use API views)
* added api view for list index
* several changes regarding style and navigation structure
* updated to jQuery 1.8. Contributed by Richard Wackerbarth.
* added a favicon. Contributed by Richard Wackerbarth.
* renamed some menu items. Contributed by Richard Wackerbarth.
* changed static file inclusion. Contributed by Richard Wackerbarth.
* added delete domain feature.
* url conf refactoring. Contributed by Richard Wackerbarth.
* added user deletion feature. Contributed by Varun Sharma.
1.0 alpha 1 -- "Space Farm"
===========================
(2012-03-23)
Many thanks go out to Anna Senarclens de Grancy and Benedict Stein for
developing the initial versions of this Django app during the Google Summer of
Code 2010 and 2011.
* add/remove/edit mailing lists
* edit list settings
* show all mailing lists on server
* subscribe/unsubscribe/mass subscribe mailing lists
* add/remove domains
* show basic list info and metrics
* login using django user account or using BrowserID
* show basic user profile
* accept/discard/reject/defer messages
* Implementation of Django Messages contributed by Benedict Stein (LP: #920084)
* Dependency check in setup.py contributed by Daniel Mizyrycki
* Proper processing of acceptable aliases in list settings form contributed by
Daniel Mizyrycki
postorius-1.2.4/src/postorius/doc/settings.py 0000775 0001750 0001750 00000001572 13414502172 022531 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
"""This is just an empty settings file to make Sphinx able to export
the DJANGO_SETTINGS_MODULE env variable before building the docs."""
postorius-1.2.4/src/postorius/doc/setup.rst 0000664 0001750 0001750 00000005077 13413660001 022205 0 ustar maxking maxking 0000000 0000000 ============
Installation
============
.. note::
This installation guide covers Postorius, the web user interface for
GNU Mailman 3. To install GNU Mailman follow the instructions in the `documentation`_.
.. _documentation: http://docs.mailman3.org/en/latest/
Install Postorius
=================
Postorius supports Python 3.5+ and Django 1.11+.
Latest release
--------------
If you just want to install the latest release of Postorius, install it from
PyPi:
::
$ pip install postorius
Latest dev version
------------------
If you want to always be up to date with the latest development version, you
should install Postorius using git:
::
$ git clone https://gitlab.com/mailman/postorius.git
$ cd postorius
$ python setup.py develop
.. note::
This note only pertains to development installs and should not be used when
doing production installs.
When setting up or running your local dev environment, you may run into some
errors. You may want to consider installing mailman modules from source as
changes may not yet be published to PyPI. Example usage below:
::
$ pip uninstall mailmanclient
$ pip install git+https://gitlab.com/mailman/mailmanclient.git
Setup your django project
=========================
Since you have now installed the necessary packages to run Postorius, it's
time to setup your Django site.
You can find an example project in ``example_project`` in the root of
``postorius'`` git repository.
Change the database setting in ``example_project/settings.py`` to
your preferred database, if you want something other than SQlite.
.. note::
Detailed information on how to use different database engines can be found
in the `Django documentation`_.
.. _Django documentation: https://docs.djangoproject.com/en/1.9/ref/settings/#databases
Third, prepare the database:
::
$ cd example_project
$ python manage.py migrate
This will create the ``.db file`` (if you ar using SQLite) and will setup all the
necessary db tables.
To create a superuser which will act as an admin account for Postorius, run the
following commands::
$ cd example_project
$ python manage.py createsuperuser
Running the development server
==============================
The quickest way to run Postorius is to just start the development server:
::
$ cd example_project
$ python manage.py runserver
.. warning::
You should use the development server only locally. While it's possible to
make your site publicly available using the dev server, you should never
do that in a production environment.
postorius-1.2.4/src/postorius/forms/ 0000775 0001750 0001750 00000000000 13427706007 020677 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/forms/__init__.py 0000664 0001750 0001750 00000002005 13414502172 022776 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2017-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
#
from postorius.forms.domain_forms import * # noqa
from postorius.forms.fields import * # noqa
from postorius.forms.member_forms import * # noqa
from postorius.forms.list_forms import * # noqa
from postorius.forms.user_forms import * # noqa
postorius-1.2.4/src/postorius/forms/domain_forms.py 0000664 0001750 0001750 00000006731 13414502172 023726 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2012-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
from django import forms
from django.core.validators import validate_email
from django.core.exceptions import ValidationError
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.contrib.sites.models import Site
from postorius.forms.fields import SiteModelChoiceField
def _get_web_host_help():
# Using a function is necessary, otherwise reverse() will be called before
# URLConfs are loaded.
return (_(
'The domain from which you want the web UI to be served from. '
'This can be same or different from the Mail Host. '
'You can edit the list of available web hosts here.'
) % reverse("admin:sites_site_changelist"))
class DomainForm(forms.Form):
"""
Form to add a domain.
"""
mail_host = forms.CharField(
label=_('Mail Host'),
error_messages={'required': _('Please enter a domain name'),
'invalid': _('Please enter a valid domain name.')},
required=True,
help_text=_(
'The domain for your mailing lists. For example when you want '
'lists like testing@example.com, enter example.com here.'),
)
description = forms.CharField(
label=_('Description'),
required=False)
alias_domain = forms.CharField(
label=_('Alias Domain'),
error_messages={
'invalid': _('Please enter a valid domain name or nothing.')},
required=False,
help_text=_('Normally empty. Used only for unusual Postfix configs.'),
)
site = SiteModelChoiceField(
label=_('Web Host'),
error_messages={'required': _('Please enter a domain name'),
'invalid': _('Please enter a valid domain name.')},
required=True,
queryset=Site.objects.order_by("name").all(),
initial=lambda: Site.objects.get_current(),
help_text=_get_web_host_help,
)
def clean_mail_host(self):
mail_host = self.cleaned_data['mail_host']
try:
validate_email('mail@' + mail_host)
except ValidationError:
raise forms.ValidationError(_("Please enter a valid domain name"))
return mail_host
def clean_alias_domain(self):
alias_domain = self.cleaned_data['alias_domain']
if alias_domain != '':
try:
validate_email('mail@' + alias_domain)
except ValidationError:
raise forms.ValidationError(
_("Please enter a valid domain name or nothing."))
return alias_domain
class DomainEditForm(DomainForm):
"""
Form to edit domains
separte from the DomainForm, so that the mail_host can't be changed.
"""
mail_host = None
postorius-1.2.4/src/postorius/forms/fields.py 0000664 0001750 0001750 00000004610 13427702667 022530 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2017-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
#
from django import forms
from django.utils.encoding import smart_text
from django.utils.translation import ugettext_lazy as _
class ListOfStringsField(forms.Field):
widget = forms.widgets.Textarea
def prepare_value(self, value):
if isinstance(value, list):
value = '\n'.join(value)
return value
def to_python(self, value):
"Returns a list of Unicode object."
if value in self.empty_values:
return []
result = []
for line in value.splitlines():
line = line.strip()
if not line:
continue
result.append(smart_text(line))
return result
class NullBooleanRadioSelect(forms.RadioSelect):
"""
This is necessary to detect that such a field has not been changed.
"""
def value_from_datadict(self, data, files, name):
value = data.get(name, None)
return {'2': True,
True: True,
'True': True,
'3': False,
'False': False,
False: False}.get(value, None)
class SiteModelChoiceField(forms.ModelChoiceField):
def label_from_instance(self, obj):
return "%s (%s)" % (obj.name, obj.domain)
class MultipleChoiceForm(forms.Form):
class MultipleChoiceField(forms.MultipleChoiceField):
def validate(self, value):
pass
choices = MultipleChoiceField(
widget=forms.CheckboxSelectMultiple,
)
def clean_choices(self):
if len(self.cleaned_data['choices']) < 1:
raise forms.ValidationError(_('Make at least one selection'))
return self.cleaned_data['choices']
postorius-1.2.4/src/postorius/forms/list_forms.py 0000664 0001750 0001750 00000102036 13427701763 023440 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2017-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
#
import re
from django import forms
from django.core.validators import validate_email
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django_mailman3.lib.mailman import get_mailman_client
from postorius.forms.fields import ListOfStringsField
ACTION_CHOICES = (
("hold", _("Hold for moderation")),
("reject", _("Reject (with notification)")),
("discard", _("Discard (no notification)")),
("accept", _("Accept immediately (bypass other rules)")),
("defer", _("Default processing")),
)
EMPTY_STRING = ''
class ListNew(forms.Form):
"""
Form fields to add a new list. Languages are hard coded which should
be replaced by a REST lookup of available languages.
"""
listname = forms.CharField(
label=_('List Name'),
required=True,
error_messages={'required': _('Please enter a name for your list.'),
'invalid': _('Please enter a valid list name.')})
mail_host = forms.ChoiceField()
list_owner = forms.EmailField(
label=_('Initial list owner address'),
error_messages={
'required': _("Please enter the list owner's email address.")},
required=True)
advertised = forms.ChoiceField(
widget=forms.RadioSelect(),
label=_('Advertise this list?'),
error_messages={
'required': _("Please choose a list type.")},
required=True,
choices=(
(True, _("Advertise this list in list index")),
(False, _("Hide this list in list index"))))
list_style = forms.ChoiceField()
description = forms.CharField(
label=_('Description'),
required=False)
def __init__(self, domain_choices, style_choices, *args, **kwargs):
super(ListNew, self).__init__(*args, **kwargs)
self.fields["mail_host"] = forms.ChoiceField(
widget=forms.Select(),
label=_('Mail Host'),
required=True,
choices=domain_choices,
error_messages={'required': _("Choose an existing Domain."),
'invalid': _("Choose a valid Mail Host")})
self.fields["list_style"] = forms.ChoiceField(
widget=forms.Select(),
label=_('List Style'),
required=True,
choices=style_choices,
error_messages={'required': _("Choose a List Style."),
'invalid': _("Choose a valid List Style.")})
if len(domain_choices) < 2:
self.fields["mail_host"].help_text = _(
"Site admin has not created any domains")
# if len(choices) < 2:
# help_text=_("No domains available: " +
# "The site admin must create new domains " +
# "before you will be able to create a list")
def clean_listname(self):
try:
validate_email(self.cleaned_data['listname'] + '@example.net')
except ValidationError:
# TODO (maxking): Error should atleast point to what is a valid
# listname. It may not always be obvious which characters aren't
# allowed in a listname.
raise forms.ValidationError(_("Please enter a valid listname"))
return self.cleaned_data['listname']
class Meta:
"""
Class to handle the automatic insertion of fieldsets and divs.
To use it: add a list for each wished fieldset. The first item in
the list should be the wished name of the fieldset, the following
the fields that should be included in the fieldset.
"""
layout = [["List Details",
"listname",
"mail_host",
"list_style",
"list_owner",
"description",
"advertised"], ]
class ListSubscribe(forms.Form):
"""Form fields to join an existing list.
"""
email = forms.ChoiceField(
label=_('Your email address'),
validators=[validate_email],
widget=forms.Select(),
error_messages={
'required': _('Please enter an email address.'),
'invalid': _('Please enter a valid email address.')})
display_name = forms.CharField(
label=_('Your name (optional)'), required=False)
def __init__(self, user_emails, *args, **kwargs):
super(ListSubscribe, self).__init__(*args, **kwargs)
self.fields['email'].choices = ((address, address)
for address in user_emails)
class ListAnonymousSubscribe(forms.Form):
"""Form fields to join an existing list as an anonymous user.
"""
email = forms.CharField(
label=_('Your email address'),
validators=[validate_email],
error_messages={
'required': _('Please enter an email address.'),
'invalid': _('Please enter a valid email address.')})
display_name = forms.CharField(
label=_('Your name (optional)'), required=False)
class ListSettingsForm(forms.Form):
"""
Base class for list settings forms.
"""
mlist_properties = []
def __init__(self, *args, **kwargs):
self._mlist = kwargs.pop('mlist')
super(ListSettingsForm, self).__init__(*args, **kwargs)
SUBSCRIPTION_POLICY_CHOICES = (
('open', _('Open')),
('confirm', _('Confirm')),
('moderate', _('Moderate')),
('confirm_then_moderate', _('Confirm, then moderate')),
)
class ListSubscriptionPolicyForm(ListSettingsForm):
"""
List subscription policy settings.
"""
subscription_policy = forms.ChoiceField(
label=_('Subscription Policy'),
choices=SUBSCRIPTION_POLICY_CHOICES,
help_text=_('Open: Subscriptions are added automatically\n'
'Confirm: Subscribers need to confirm the subscription '
'using an email sent to them\n'
'Moderate: Moderators will have to authorize '
'each subscription manually.\n'
'Confirm then Moderate: First subscribers have to confirm,'
' then a moderator '
'needs to authorize.'))
class ArchiveSettingsForm(ListSettingsForm):
"""
Set the general archive policy.
"""
mlist_properties = ['archivers']
archive_policy_choices = (
("public", _("Public archives")),
("private", _("Private archives")),
("never", _("Do not archive this list")),
)
archive_policy = forms.ChoiceField(
choices=archive_policy_choices,
widget=forms.RadioSelect,
label=_('Archive policy'),
help_text=_('Policy for archiving messages for this list'),
)
archivers = forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple,
label=_('Active archivers'),
required=False) # May be empty if no archivers are desired.
def __init__(self, *args, **kwargs):
super(ArchiveSettingsForm, self).__init__(*args, **kwargs)
archiver_opts = sorted(self._mlist.archivers.keys())
self.fields['archivers'].choices = sorted(
[(key, key) for key in archiver_opts])
if self.initial:
self.initial['archivers'] = [
key for key in archiver_opts if self._mlist.archivers[key] is True] # noqa
def clean_archivers(self):
result = {}
for archiver, etc in self.fields['archivers'].choices:
result[archiver] = archiver in self.cleaned_data['archivers']
self.cleaned_data['archivers'] = result
return result
class MessageAcceptanceForm(ListSettingsForm):
"""
List messages acceptance settings.
"""
acceptable_aliases = ListOfStringsField(
label=_("Acceptable aliases"),
required=False,
help_text=_(
'This is a list, one per line, of addresses and regexps matching '
'addresses that are acceptable in To: or Cc: in lieu of the list '
'posting address when `require_explicit_destination\' is enabled. '
' Entries are either email addresses or regexps matching email '
'addresses. Regexps are entries beginning with `^\' and are '
'matched against every recipient address in the message. The '
'matching is performed with Python\'s re.match() function, meaning'
' they are anchored to the start of the string.'))
require_explicit_destination = forms.BooleanField(
widget=forms.RadioSelect(choices=((True, _('Yes')), (False, _('No')))),
required=False,
label=_('Require Explicit Destination'),
help_text=_(
'This checks to ensure that the list posting address or an '
'acceptable alias explicitly appears in a To: or Cc: header in '
'the post.'))
administrivia = forms.BooleanField(
widget=forms.RadioSelect(choices=((True, _('Yes')), (False, _('No')))),
required=False,
label=_('Administrivia'),
help_text=_(
'Administrivia tests will check postings to see whether it\'s '
'really meant as an administrative request (like subscribe, '
'unsubscribe, etc), and will add it to the the administrative '
'requests queue, notifying the administrator of the new request, '
'in the process.'))
default_member_action = forms.ChoiceField(
widget=forms.RadioSelect(),
label=_('Default action to take when a member posts to the list'),
error_messages={
'required': _("Please choose a default member action.")},
required=True,
choices=ACTION_CHOICES,
help_text=_(
'Default action to take when a member posts to the list.\n'
'Hold: This holds the message for approval by the list '
'moderators.\n'
'Reject: this automatically rejects the message by sending a '
'bounce notice to the post\'s author. The text of the bounce '
'notice can be configured by you.\n'
'Discard: this simply discards the message, with no notice '
'sent to the post\'s author.\n'
'Accept: accepts any postings without any further checks.\n'
'Default Processing: run additional checks and accept '
'the message.'))
default_nonmember_action = forms.ChoiceField(
widget=forms.RadioSelect(),
label=_('Default action to take when a non-member posts to the '
'list'),
error_messages={
'required': _("Please choose a default non-member action.")},
required=True,
choices=ACTION_CHOICES,
help_text=_(
'When a post from a non-member is received, the message\'s sender '
'is matched against the list of explicitly accepted, held, '
'rejected (bounced), and discarded addresses. '
'If no match is found, then this action is taken.'))
max_message_size = forms.IntegerField(
min_value=0,
label=_('Maximum message size'),
required=False,
help_text=_(
'The maximum allowed message size. '
'This can be used to prevent emails with large attachments. '
'A size of 0 disables the check.'))
max_num_recipients = forms.IntegerField(
min_value=0,
label=_('Maximum number of recipients'),
required=False,
help_text=_(
'The maximum number of recipients for a message. '
'This can be used to prevent mass mailings from being accepted. '
'A value of 0 disables the check.'))
def clean_acceptable_aliases(self):
# python's urlencode will drop this attribute completely if an empty
# list is passed with doseq=True. To make it work for us, we instead
# use an empty string to signify an empty value. In turn, Core will
# also consider an empty value to be empty list for list-of-strings
# field.
if not self.cleaned_data['acceptable_aliases']:
return EMPTY_STRING
for alias in self.cleaned_data['acceptable_aliases']:
if alias.startswith('^'):
try:
re.compile(alias)
except re.error as e:
raise forms.ValidationError(
_('Invalid alias regexp: {}: {}').format(alias, e.msg))
else:
try:
validate_email(alias)
except ValidationError:
raise forms.ValidationError(
_('Invalid alias email: {}').format(alias))
return self.cleaned_data['acceptable_aliases']
class DigestSettingsForm(ListSettingsForm):
"""
List digest settings.
"""
digest_size_threshold = forms.DecimalField(
label=_('Digest size threshold'),
help_text=_('How big in Kb should a digest be before '
'it gets sent out?'))
class DMARCMitigationsForm(ListSettingsForm):
"""
DMARC Mitigations list settings.
"""
dmarc_mitigate_action = forms.ChoiceField(
label=_('DMARC mitigation action'),
widget=forms.Select(),
required=False,
error_messages={
'required': _("Please choose a DMARC mitigation action.")},
choices=(
('no_mitigation', _('No DMARC mitigations')),
('munge_from', _('Replace From: with list address')),
('wrap_message',
_('Wrap the message in an outer message From: the list.')),
('reject', _('Reject the message')),
('discard', _('Discard the message'))),
help_text=_(
'The action to apply to messages From: a domain publishing a '
'DMARC policy of reject or quarantine or to all messages if '
'DMARC Mitigate unconditionally is True.'))
dmarc_mitigate_unconditionally = forms.TypedChoiceField(
choices=((True, _('Yes')), (False, _('No'))),
widget=forms.RadioSelect,
required=False,
label=_('DMARC Mitigate unconditionally'),
help_text=_(
'If DMARC mitigation action is munge_from or wrap_message, '
'should it apply to all messages regardless of the DMARC policy '
'of the From: domain.'))
dmarc_moderation_notice = forms.CharField(
label=_('DMARC rejection notice'),
required=False,
widget=forms.Textarea(),
help_text=_(
'Text to replace the default reason in any rejection notice to '
'be sent when DMARC mitigation action of reject applies.'))
dmarc_wrapped_message_text = forms.CharField(
label=_('DMARC wrapped message text'),
required=False,
widget=forms.Textarea(),
help_text=_(
'Text to be added as a separate text/plain MIME part preceding '
'the original message part in the wrapped message when DMARC '
'mitigation action of wrap message applies.'))
class AlterMessagesForm(ListSettingsForm):
"""
Alter messages list settings.
"""
filter_content = forms.TypedChoiceField(
choices=((True, _('Yes')), (False, _('No'))),
widget=forms.RadioSelect,
required=False,
label=_('Filter content'),
help_text=_('Should Mailman filter the content of list traffic '
'according to the settings below?'))
collapse_alternatives = forms.TypedChoiceField(
choices=((True, _('Yes')), (False, _('No'))),
widget=forms.RadioSelect,
required=False,
label=_('Collapse alternatives'),
help_text=_('Should Mailman collapse multipart/alternative to '
'its first part content?'))
convert_html_to_plaintext = forms.TypedChoiceField(
choices=((True, _('Yes')), (False, _('No'))),
widget=forms.RadioSelect,
required=False,
label=_('Convert html to plaintext'),
help_text=_('Should Mailman convert text/html parts to plain text? '
'This conversion happens after MIME attachments '
'have been stripped.'))
anonymous_list = forms.TypedChoiceField(
choices=((True, _('Yes')), (False, _('No'))),
widget=forms.RadioSelect,
required=False,
label=_('Anonymous list'),
help_text=_('Hide the sender of a message, '
'replacing it with the list address '
'(Removes From, Sender and Reply-To fields)'))
include_rfc2369_headers = forms.TypedChoiceField(
choices=((True, _('Yes')), (False, _('No'))),
widget=forms.RadioSelect,
required=False,
label=_('Include RFC2369 headers'),
help_text=_(
'Yes is highly recommended. RFC 2369 defines a set of List-* '
'headers that are normally added to every message sent to the '
'list membership. These greatly aid end-users who are using '
'standards compliant mail readers. They should normally always '
'be enabled. However, not all mail readers are standards '
'compliant yet, and if you have a large number of members who are '
'using non-compliant mail readers, they may be annoyed at these '
'headers. You should first try to educate your members as to why '
'these headers exist, and how to hide them in their mail clients. '
'As a last resort you can disable these headers, but this is not '
'recommended (and in fact, your ability to disable these headers '
'may eventually go away).'))
allow_list_posts = forms.TypedChoiceField(
choices=((True, _('Yes')), (False, _('No'))),
widget=forms.RadioSelect,
required=False,
label=_("Include the list post header"),
help_text=_(
"This can be set to no for announce lists that do not wish to "
"include the List-Post header because posting to the list is "
"discouraged."))
reply_to_address = forms.CharField(
label=_('Explicit reply-to address'),
required=False,
help_text=_(
'This option allows admins to set an explicit Reply-to address. '
'It is only used if the reply-to is set to use an explicitly set '
'header'))
first_strip_reply_to = forms.TypedChoiceField(
choices=((True, _('Yes')), (False, _('No'))),
widget=forms.RadioSelect,
required=False,
help_text=_(
'Should any existing Reply-To: header found in the original '
'message be stripped? If so, this will be done regardless of '
'whether an explict Reply-To: header is added by Mailman or not.'))
reply_goes_to_list = forms.ChoiceField(
label=_('Reply goes to list'),
widget=forms.Select(),
required=False,
error_messages={
'required': _("Please choose a reply-to action.")},
choices=(
('no_munging', _('No Munging')),
('point_to_list', _('Reply goes to list')),
('explicit_header', _('Explicit Reply-to header set')),
('explicit_header_only', _('Explicit Reply-to set; no Cc added'))),
help_text=_(
'Where are replies to list messages directed? No Munging is '
'strongly recommended for most mailing lists. \nThis option '
'controls what Mailman does to the Reply-To: header in messages '
'flowing through this mailing list. When set to No Munging, no '
'Reply-To: header is '
'added by Mailman, although if one is present in the original '
'message, it is not stripped. Setting this value to either Reply '
'to List, Explicit Reply, or Reply Only causes Mailman to insert '
'a specific Reply-To: header in all messages, overriding the '
'header in the original message if necessary '
'(Explicit Reply inserts the value of reply_to_address). '
'Explicit Reply-to set; no Cc added is useful for'
'announce-only lists where you want to avoid someone replying '
'to the list address. There are many reasons not to introduce or '
'override the Reply-To: header. One is that some posters depend '
'on their own Reply-To: settings to convey their valid return '
'address. Another is that modifying Reply-To: makes it much more '
'difficult to send private replies. See `Reply-To\' Munging '
'Considered Harmful for a general discussion of this issue. '
'See Reply-To Munging Considered Useful for a dissenting opinion. '
'Some mailing lists have restricted '
'posting privileges, with a parallel list devoted to discussions. '
'Examples are `patches\' or `checkin\' lists, where software '
'changes are posted by a revision control system, but discussion '
'about the changes occurs on a developers mailing list. To '
'support these types of mailing lists, select Explicit Reply and '
'set the Reply-To: address option to point to the parallel list.'))
posting_pipeline = forms.ChoiceField(
label=_('Pipeline'),
widget=forms.Select(),
required=False,
choices=lambda: ((p, p) for p in get_mailman_client()
.pipelines['pipelines']),
help_text=_('Type of pipeline you want to use for this mailing list'))
class ListAutomaticResponsesForm(ListSettingsForm):
"""
List settings for automatic responses.
"""
autorespond_choices = (
("respond_and_continue", _("Respond and continue processing")),
("respond_and_discard", _("Respond and discard message")),
("none", _("No automatic response")))
autorespond_owner = forms.ChoiceField(
choices=autorespond_choices,
widget=forms.RadioSelect,
label=_('Autorespond to list owner'),
help_text=_('Should Mailman send an auto-response to '
'emails sent to the -owner address?'))
autoresponse_owner_text = forms.CharField(
label=_('Autoresponse owner text'),
widget=forms.Textarea(),
required=False,
help_text=_('Auto-response text to send to -owner emails.'))
autorespond_postings = forms.ChoiceField(
choices=autorespond_choices,
widget=forms.RadioSelect,
label=_('Autorespond postings'),
help_text=_('Should Mailman send an auto-response to '
'mailing list posters?'))
autoresponse_postings_text = forms.CharField(
label=_('Autoresponse postings text'),
widget=forms.Textarea(),
required=False,
help_text=_('Auto-response text to send to mailing list posters.'))
autorespond_requests = forms.ChoiceField(
choices=autorespond_choices,
widget=forms.RadioSelect,
label=_('Autorespond requests'),
help_text=_(
'Should Mailman send an auto-response to emails sent to the '
'-request address? If you choose yes, decide whether you want '
'Mailman to discard the original email, or forward it on to the '
'system as a normal mail command.'))
autoresponse_request_text = forms.CharField(
label=_('Autoresponse request text'),
widget=forms.Textarea(),
required=False,
help_text=_('Auto-response text to send to -request emails.'))
autoresponse_grace_period = forms.CharField(
label=_('Autoresponse grace period'),
help_text=_(
'Number of days between auto-responses to either the mailing list '
'or -request/-owner address from the same poster. Set to zero '
'(or negative) for no grace period (i.e. auto-respond to every '
'message).'))
respond_to_post_requests = forms.TypedChoiceField(
choices=((True, _('Yes')), (False, _('No'))),
widget=forms.RadioSelect,
required=False,
label=_('Notify users of held messages'),
help_text=_(
'Should Mailman notify users about their messages held for '
'approval. If you say \'No\', no notifications will be sent '
'to users about the pending approval on their messages.'))
send_welcome_message = forms.TypedChoiceField(
choices=((True, _('Yes')), (False, _('No'))),
widget=forms.RadioSelect,
required=False,
label=_('Send welcome message'),
help_text=_(
'Send welcome message to newly subscribed members? '
'Turn this off only if you plan on subscribing people manually '
'and don\'t want them to know that you did so. This option is '
'most useful for transparently migrating lists from some other '
'mailing list manager to Mailman.'))
welcome_message_uri = forms.CharField(
label=_('URI for the welcome message'),
required=False,
help_text=_(
'If a welcome message is to be sent to subscribers, you can '
'specify a URI that gives the text of this message.'),
)
goodbye_message_uri = forms.CharField(
label=_('URI for the good bye message'),
required=False,
help_text=_(
'If a good bye message is to be sent to unsubscribers, you can '
'specify a URI that gives the text of this message.'),
)
admin_immed_notify = forms.BooleanField(
widget=forms.RadioSelect(choices=((True, _('Yes')), (False, _('No')))),
required=False,
label=_('Admin immed notify'),
help_text=_(
'Should the list moderators get immediate notice of new requests, '
'as well as daily notices about collected ones? List moderators '
'(and list administrators) are sent daily reminders of requests '
'pending approval, like subscriptions to a moderated list, '
'or postings that are being held for one reason or another. '
'Setting this option causes notices to be sent immediately on the '
'arrival of new requests as well. '))
admin_notify_mchanges = forms.BooleanField(
widget=forms.RadioSelect(choices=((True, _('Yes')), (False, _('No')))),
required=False,
label=_('Notify admin of membership changes'),
help_text=_('Should administrator get notices of '
'subscribes and unsubscribes?'))
class ListIdentityForm(ListSettingsForm):
"""
List identity settings.
"""
advertised = forms.TypedChoiceField(
choices=((True, _('Yes')), (False, _('No'))),
widget=forms.RadioSelect,
label=_('Show list on index page'),
help_text=_('Choose whether to include this list '
'on the list of all lists'))
description = forms.CharField(
label=_('Description'),
required=False,
help_text=_(
'This description is used when the mailing list is listed with '
'other mailing lists, or in headers, and so forth. It should be '
'as succinct as you can get it, while still identifying what the '
'list is.'),
)
info = forms.CharField(
label=_('Information'),
help_text=_('A longer description of this mailing list.'),
required=False,
widget=forms.Textarea())
display_name = forms.CharField(
label=_('Display name'),
required=False,
help_text=_('Display name is the name shown in the web interface.')
)
subject_prefix = forms.CharField(
label=_('Subject prefix'),
strip=False,
required=False,
)
def clean_subject_prefix(self):
"""
Strip the leading whitespaces from the subject_prefix form field.
"""
return self.cleaned_data.get('subject_prefix', '').lstrip()
class ListMassSubscription(forms.Form):
"""Form fields to masssubscribe users to a list.
"""
emails = ListOfStringsField(
label=_('Emails to mass subscribe'),
help_text=_(
'The following formats are accepted:\n'
'jdoe@example.com\n'
'<jdoe@example.com>\n'
'John Doe <jdoe@example.com>\n'
'"John Doe" <jdoe@example.com>\n'
'jdoe@example.com (John Doe)\n'
'Use the last three to associate a display name with'
' the address\n'),
)
class ListMassRemoval(forms.Form):
"""Form fields to remove multiple list users.
"""
emails = ListOfStringsField(
label=_('Emails to Unsubscribe'),
help_text=_('Add one email address on each line'),
)
class Meta:
"""
Class to define the name of the fieldsets and what should be
included in each.
"""
layout = [["Mass Removal", "emails"]]
class ListAddBanForm(forms.Form):
"""Ban an email address for a list."""
# TODO maxking: This form should only accept valid emails or regular
# expressions. Anything else that doesn't look like a valid email address
# or regexp for email should not be a valid value for the field. However,
# checking for that might not be easy.
email = forms.CharField(
label=_('Add ban'),
help_text=_(
'You can ban a single email address or use a regular expression '
'to match similar email addresses.'),
error_messages={
'required': _('Please enter an email address.'),
'invalid': _('Please enter a valid email address.')})
class ListHeaderMatchForm(forms.Form):
"""Edit a list's header match."""
HM_ACTION_CHOICES = [(None, _("Default antispam action"))] + \
[a for a in ACTION_CHOICES if a[0] != 'defer']
header = forms.CharField(
label=_('Header'),
help_text=_('Email header to filter on (case-insensitive).'),
error_messages={
'required': _('Please enter a header.'),
'invalid': _('Please enter a valid header.')})
pattern = forms.CharField(
label=_('Pattern'),
help_text=_('Regular expression matching the header\'s value.'),
error_messages={
'required': _('Please enter a pattern.'),
'invalid': _('Please enter a valid pattern.')})
action = forms.ChoiceField(
label=_('Action'),
error_messages={'invalid': _('Please enter a valid action.')},
required=False,
choices=HM_ACTION_CHOICES,
help_text=_('Action to take when a header matches')
)
class ListHeaderMatchFormset(forms.BaseFormSet):
def clean(self):
"""Checks that no two header matches have the same order."""
if any(self.errors):
# Don't bother validating the formset unless
# each form is valid on its own
return
orders = []
for form in self.forms:
try:
order = form.cleaned_data['ORDER']
except KeyError:
continue
if order in orders:
raise forms.ValidationError('Header matches must have'
' distinct orders.')
orders.append(order)
class MemberModeration(forms.Form):
"""
Form handling the member's moderation_action.
"""
moderation_action = forms.ChoiceField(
widget=forms.Select(),
label=_('Moderation'),
required=False,
choices=[(None, _('List default'))] + list(ACTION_CHOICES),
help_text=_(
'Default action to take when this member posts to the list. \n'
'List default -- follow the list\'s default member action. \n'
'Hold -- This holds the message for approval by the list '
'moderators. \n'
'Reject -- this automatically rejects the message by sending a '
'bounce notice to the post\'s author. The text of the bounce '
'notice can be configured by you. \n'
'Discard -- this simply discards the message, with no notice '
'sent to the post\'s author. \n'
'Accept -- accepts any postings without any further checks. \n'
'Defer -- default processing, run additional checks and accept '
'the message. \n'))
class ChangeSubscriptionForm(forms.Form):
email = forms.ChoiceField()
def __init__(self, user_emails, *args, **kwargs):
super(ChangeSubscriptionForm, self).__init__(*args, **kwargs)
self.fields['email'] = forms.ChoiceField(
label=_('Select Email'),
required=False,
widget=forms.Select(),
choices=((address, address) for address in user_emails))
postorius-1.2.4/src/postorius/forms/member_forms.py 0000664 0001750 0001750 00000002423 13414502172 023720 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2017-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
#
from django import forms
from django.utils.translation import ugettext_lazy as _
class MemberForm(forms.Form):
"""Assign a role to the member"""
email = forms.EmailField(
label=_('Email Address'),
error_messages={
'required': _('Please enter an email address.'),
'invalid': _('Please enter a valid email address.')})
display_name = forms.CharField(
label=_('Display Name'),
required=False,
error_messages={
'invalid': _('Please enter an display name.')})
postorius-1.2.4/src/postorius/forms/user_forms.py 0000664 0001750 0001750 00000013636 13414502172 023437 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2017-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
#
from django import forms
from django.utils.translation import ugettext_lazy as _
from postorius.forms.fields import NullBooleanRadioSelect
class UserPreferences(forms.Form):
"""
Form handling the user's global, address and subscription based preferences
"""
def __init__(self, *args, **kwargs):
self._preferences = kwargs.pop('preferences', None)
super(UserPreferences, self).__init__(*args, **kwargs)
@property
def initial(self):
# Redirect to the preferences, this allows setting the preferences
# after instanciation and it will also set the initial data.
return self._preferences or {}
@initial.setter
def initial(self, value):
pass
choices = ((True, _('Yes')), (False, _('No')))
delivery_mode_choices = (("regular", _('Regular')),
("plaintext_digests", _('Plain Text Digests')),
("mime_digests", _('Mime Digests')),
("summary_digests", _('Summary Digests')))
delivery_status_choices = (
("enabled", _('Enabled')), ("by_user", _('Disabled')))
delivery_status = forms.ChoiceField(
widget=forms.RadioSelect,
choices=delivery_status_choices,
required=False,
label=_('Delivery status'),
help_text=_(
'Set this option to Enabled to receive messages posted to this '
'mailing list. Set it to Disabled if you want to stay subscribed, '
'but don\'t want mail delivered to you for a while (e.g. you\'re '
'going on vacation). If you disable mail delivery, don\'t forget '
'to re-enable it when you come back; it will not be automatically '
're-enabled.'))
delivery_mode = forms.ChoiceField(
widget=forms.Select(),
choices=delivery_mode_choices,
required=False,
label=_('Delivery mode'),
help_text=_(
'If you select summary digests , you\'ll get posts bundled '
'together (usually one per day but possibly more on busy lists), '
'instead of singly when they\'re sent. Your mail reader may or '
'may not support MIME digests. In general MIME digests are '
'preferred, but if you have a problem reading them, select '
'plain text digests.'))
receive_own_postings = forms.NullBooleanField(
widget=NullBooleanRadioSelect(choices=choices),
required=False,
label=_('Receive own postings'),
help_text=_(
'Ordinarily, you will get a copy of every message you post to the '
'list. If you don\'t want to receive this copy, set this option '
'to No.'
))
acknowledge_posts = forms.NullBooleanField(
widget=NullBooleanRadioSelect(choices=choices),
required=False,
label=_('Acknowledge posts'),
help_text=_(
'Receive acknowledgement mail when you send mail to the list?'))
hide_address = forms.NullBooleanField(
widget=NullBooleanRadioSelect(choices=choices),
required=False,
label=_('Hide address'),
help_text=_(
'When someone views the list membership, your email address is '
'normally shown (in an obscured fashion to thwart spam '
'harvesters). '
'If you do not want your email address to show up on this '
'membership roster at all, select Yes for this option.'))
receive_list_copy = forms.NullBooleanField(
widget=NullBooleanRadioSelect(choices=choices),
required=False,
label=_('Receive list copies (possible duplicates)'),
help_text=_(
'When you are listed explicitly in the To: or Cc: headers of a '
'list message, you can opt to not receive another copy from the '
'mailing list. Select No to receive copies. '
'Select Yes to avoid receiving copies from the mailing list'))
class Meta:
"""
Class to define the name of the fieldsets and what should be
included in each.
"""
layout = [["User Preferences", "acknowledge_posts", "hide_address",
"receive_list_copy", "receive_own_postings",
"delivery_mode", "delivery_status"]]
def save(self):
if not self.changed_data:
return
for key in self.changed_data:
if self.cleaned_data[key] is not None:
# None: nothing set yet. Remember to remove this test
# when Mailman accepts None as a "reset to default"
# value.
self._preferences[key] = self.cleaned_data[key]
self._preferences.save()
class UserPreferencesFormset(forms.BaseFormSet):
def __init__(self, *args, **kwargs):
self._preferences = kwargs.pop('preferences')
kwargs["initial"] = self._preferences
super(UserPreferencesFormset, self).__init__(*args, **kwargs)
def _construct_form(self, i, **kwargs):
form = super(UserPreferencesFormset, self)._construct_form(i, **kwargs)
form._preferences = self._preferences[i]
return form
def save(self):
for form in self.forms:
form.save()
postorius-1.2.4/src/postorius/management/ 0000775 0001750 0001750 00000000000 13427706007 021665 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/management/__init__.py 0000664 0001750 0001750 00000000000 13413660001 023750 0 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/management/commands/ 0000775 0001750 0001750 00000000000 13427706007 023466 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/management/commands/__init__.py 0000664 0001750 0001750 00000000000 13413660001 025551 0 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/management/commands/mmclient.py 0000664 0001750 0001750 00000003270 13414502172 025643 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
from django.core.management.base import BaseCommand
from django_mailman3.lib.mailman import get_mailman_client
class Command(BaseCommand):
help = """Opens a Python shell with a mailmanclient object named `client`.
Usage example:
client.lists
[]
foo = client.get_list('foo@example.org')
foo.members
[]
A complete list of commands can be found in the mailmanclient documentation."""
def handle(self, *args, **options):
# choose an interpreter
try:
import IPython
console_fn = IPython.embed
except ImportError:
import code
shell = code.InteractiveConsole(globals())
console_fn = shell.interact
# connect to mailmanclient
client = get_mailman_client()
# Putting client back in the global scope
globals()['client'] = client
# run the interpreter
console_fn()
postorius-1.2.4/src/postorius/management/commands/reset_passwords.py 0000664 0001750 0001750 00000004660 13414502172 027266 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2017-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
#
import os
import base64
from django.core.management.base import BaseCommand
from django_mailman3.lib.mailman import get_mailman_client
PASSWORD_BYTES = 32
class Command(BaseCommand):
help = '''Reset passwords of all users in Mailman Core. This does not affect
the login passwords of users in Django or any other social
authentication. Users will be able to login with their current
passwords. Mailman Core maintains a second set of passwords for
every user, which would be set to a random value of base64 encode
32 bytes.
'''
def handle(self, *args, **kwargs):
client = get_mailman_client()
for user in self._get_all_users(client):
self._reset_password(user)
def _get_all_users(self, client):
"""Given a mailmanclient.Client instance, returns an iterator of
paginated user records.
"""
page = client.get_user_page(count=50, page=1)
while True:
for user in page:
yield user
if page.has_next:
page = page.next
else:
break
def _reset_password(self, user):
"""Given a mailmanclient.restobject.user.User object, reset its password
to None in the database.
"""
user.password = self._get_random_password()
user.save()
msg = 'Password reset for {}'.format(user)
self.stdout.write(self.style.SUCCESS(msg))
def _get_random_password(self):
"""Generate a random password for a user.
"""
tok = os.urandom(PASSWORD_BYTES)
return base64.urlsafe_b64encode(tok).rstrip(b'=').decode('ascii')
postorius-1.2.4/src/postorius/middleware.py 0000664 0001750 0001750 00000002606 13414502172 022235 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2015-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
from postorius import utils
from postorius.models import MailmanApiError
from mailmanclient import MailmanConnectionError
import logging
logger = logging.getLogger(__name__)
__all__ = [
'PostoriusMiddleware',
]
class PostoriusMiddleware(object):
def __init__(self, get_response=None):
self.get_response = get_response
def __call__(self, request):
return self.get_response(request)
def process_exception(self, request, exception):
if isinstance(exception, (MailmanApiError, MailmanConnectionError)):
logger.exception('Mailman REST API not available')
return utils.render_api_error(request)
postorius-1.2.4/src/postorius/migrations/ 0000775 0001750 0001750 00000000000 13427706007 021725 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/migrations/0001_initial.py 0000664 0001750 0001750 00000001545 13413660001 024361 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='AddressConfirmationProfile',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False,
auto_created=True, primary_key=True)),
('email', models.EmailField(max_length=254)),
('activation_key', models.CharField(max_length=40)),
('created', models.DateTimeField()),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL,
on_delete=models.CASCADE)),
],
),
]
postorius-1.2.4/src/postorius/migrations/0002_auto_20160210_0721.py 0000664 0001750 0001750 00000001367 13413660001 025327 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('postorius', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='addressconfirmationprofile',
name='activation_key',
field=models.CharField(unique=True, max_length=32),
),
migrations.AlterField(
model_name='addressconfirmationprofile',
name='created',
field=models.DateTimeField(auto_now=True),
),
migrations.AlterField(
model_name='addressconfirmationprofile',
name='email',
field=models.EmailField(unique=True, max_length=254),
),
]
postorius-1.2.4/src/postorius/migrations/0003_drop_addressconfirmationprofile.py 0000664 0001750 0001750 00000000716 13413660001 031374 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-08-13 09:48
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('postorius', '0002_auto_20160210_0721'),
]
operations = [
migrations.RemoveField(
model_name='addressconfirmationprofile',
name='user',
),
migrations.DeleteModel(
name='AddressConfirmationProfile',
),
]
postorius-1.2.4/src/postorius/migrations/0004_create_email_template.py 0000664 0001750 0001750 00000014171 13413660001 027237 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-07-02 04:44
from __future__ import unicode_literals
from django.db import migrations, models
# flake8: noqa
class Migration(migrations.Migration):
initial = True
dependencies = [
('postorius', '0003_drop_addressconfirmationprofile'),
]
operations = [
migrations.CreateModel(
name='EmailTemplate',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(choices=[('list:admin:action:post', 'Sent to the list administrators when moderator approval for a posting is required.'), ('list:admin:action:subscribe', 'Sent to the list administrators when moderator approval for a subscription request is required.'), ('list:admin:action:unsubscribe', 'Sent to the list administrators when moderator approval for an unsubscription request is required.'), ('list:admin:notice:subscribe', 'Sent to the list administrators to notify them when a new member has been subscribed.'), ('list:admin:notice:unrecognized', 'Sent to the list administrators when a bounce message in an unrecognized format has been received.'), ('list:admin:notice:unsubscribe', 'Sent to the list administrators to notify them when a member has been unsubscribed.'), ('list:member:digest:footer', 'The footer for a digest message.'), ('list:member:digest:header', 'The header for a digest message.'), ('list:member:digest:masthead', 'The digest “mastheadâ€; i.e. a common introduction for all digest messages.'), ('list:member:regular:footer', 'The footer for a regular (non-digest) message.'), ('list:member:regular:header', 'The header for a regular (non-digest) message.'), ('list:user:action:subscribe', 'The message sent to subscribers when a subscription confirmation is required.'), ('list:user:action:unsubscribe', 'The message sent to subscribers when an unsubscription confirmation is required.'), ('list:user:notice:goodbye', 'The notice sent to a member when they unsubscribe from a mailing list.'), ('list:user:notice:hold', 'The notice sent to a poster when their message is being held or moderator approval.'), ('list:user:notice:no-more-today', 'Sent to a user when the maximum number of autoresponses has been reached for that day.'), ('list:user:notice:post', 'Notice sent to a poster when their message has been received by the mailing list.'), ('list:user:notice:probe', 'A bounce probe sent to a member when their subscription has been disabled due to bounces.'), ('list:user:notice:refuse', 'Notice sent to a poster when their message has been rejected by the list’s moderator.'), ('list:user:notice:welcome', 'The notice sent to a member when they are subscribed to the mailing list.')], help_text='Choose the template you want to customize.', max_length=100)),
('data', models.TextField(help_text="You can use these variables in the templates. \n$hyperkitty_url: Permalink to archived message in Hyperkitty\n$listname: Name of the Mailing List e.g. ant@example.com \n$list_id: The List-ID header e.g. ant.example.com \n$display_name: Display name of the mailing list e.g. Ant \n$short_listname: Local part of the listname e.g. ant \n$domain: The domain part of the listname e.g. example.com \n$info: The mailing list's longer descriptive text \n$request_email: The email address for -request address \n$owner_email: The email address for -owner address \n$site_email: The email address to reach the owners of the site \n$language: The two letter language code for list's preferred language e.g. fr, en, de \n")),
('language', models.CharField(blank=True, choices=[('af', 'Afrikaans'), ('ar', 'Arabic'), ('ast', 'Asturian'), ('az', 'Azerbaijani'), ('bg', 'Bulgarian'), ('be', 'Belarusian'), ('bn', 'Bengali'), ('br', 'Breton'), ('bs', 'Bosnian'), ('ca', 'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de', 'German'), ('dsb', 'Lower Sorbian'), ('el', 'Greek'), ('en', 'English'), ('en-au', 'Australian English'), ('en-gb', 'British English'), ('eo', 'Esperanto'), ('es', 'Spanish'), ('es-ar', 'Argentinian Spanish'), ('es-co', 'Colombian Spanish'), ('es-mx', 'Mexican Spanish'), ('es-ni', 'Nicaraguan Spanish'), ('es-ve', 'Venezuelan Spanish'), ('et', 'Estonian'), ('eu', 'Basque'), ('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'), ('fy', 'Frisian'), ('ga', 'Irish'), ('gd', 'Scottish Gaelic'), ('gl', 'Galician'), ('he', 'Hebrew'), ('hi', 'Hindi'), ('hr', 'Croatian'), ('hsb', 'Upper Sorbian'), ('hu', 'Hungarian'), ('ia', 'Interlingua'), ('id', 'Indonesian'), ('io', 'Ido'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja', 'Japanese'), ('ka', 'Georgian'), ('kk', 'Kazakh'), ('km', 'Khmer'), ('kn', 'Kannada'), ('ko', 'Korean'), ('lb', 'Luxembourgish'), ('lt', 'Lithuanian'), ('lv', 'Latvian'), ('mk', 'Macedonian'), ('ml', 'Malayalam'), ('mn', 'Mongolian'), ('mr', 'Marathi'), ('my', 'Burmese'), ('nb', 'Norwegian Bokmål'), ('ne', 'Nepali'), ('nl', 'Dutch'), ('nn', 'Norwegian Nynorsk'), ('os', 'Ossetic'), ('pa', 'Punjabi'), ('pl', 'Polish'), ('pt', 'Portuguese'), ('pt-br', 'Brazilian Portuguese'), ('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'), ('sq', 'Albanian'), ('sr', 'Serbian'), ('sr-latn', 'Serbian Latin'), ('sv', 'Swedish'), ('sw', 'Swahili'), ('ta', 'Tamil'), ('te', 'Telugu'), ('th', 'Thai'), ('tr', 'Turkish'), ('tt', 'Tatar'), ('udm', 'Udmurt'), ('uk', 'Ukrainian'), ('ur', 'Urdu'), ('vi', 'Vietnamese'), ('zh-hans', 'Simplified Chinese'), ('zh-hant', 'Traditional Chinese')], help_text="Language for the template, this should be the list's preferred language.", max_length=5)),
('craeted_at', models.DateTimeField(auto_now_add=True)),
('modified_at', models.DateTimeField(auto_now=True)),
('context', models.CharField(choices=[('site', 'Site Wide'), ('domain', 'Domain Wide'), ('list', 'MailingList Wide')], max_length=50)),
('identifier', models.CharField(blank=True, max_length=100)),
],
),
migrations.AlterUniqueTogether(
name='emailtemplate',
unique_together=set([('name', 'identifier', 'language')]),
),
]
postorius-1.2.4/src/postorius/migrations/0005_auto_20180707_1107.py 0000664 0001750 0001750 00000004572 13413660001 025347 0 ustar maxking maxking 0000000 0000000 # Generated by Django 2.0.6 on 2018-07-07 18:07
from django.db import migrations, models
# flake8: noqa
class Migration(migrations.Migration):
dependencies = [
('postorius', '0004_create_email_template'),
]
operations = [
migrations.AlterField(
model_name='emailtemplate',
name='language',
field=models.CharField(blank=True, choices=[('af', 'Afrikaans'), ('ar', 'Arabic'), ('ast', 'Asturian'), ('az', 'Azerbaijani'), ('bg', 'Bulgarian'), ('be', 'Belarusian'), ('bn', 'Bengali'), ('br', 'Breton'), ('bs', 'Bosnian'), ('ca', 'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de', 'German'), ('dsb', 'Lower Sorbian'), ('el', 'Greek'), ('en', 'English'), ('en-au', 'Australian English'), ('en-gb', 'British English'), ('eo', 'Esperanto'), ('es', 'Spanish'), ('es-ar', 'Argentinian Spanish'), ('es-co', 'Colombian Spanish'), ('es-mx', 'Mexican Spanish'), ('es-ni', 'Nicaraguan Spanish'), ('es-ve', 'Venezuelan Spanish'), ('et', 'Estonian'), ('eu', 'Basque'), ('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'), ('fy', 'Frisian'), ('ga', 'Irish'), ('gd', 'Scottish Gaelic'), ('gl', 'Galician'), ('he', 'Hebrew'), ('hi', 'Hindi'), ('hr', 'Croatian'), ('hsb', 'Upper Sorbian'), ('hu', 'Hungarian'), ('ia', 'Interlingua'), ('id', 'Indonesian'), ('io', 'Ido'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja', 'Japanese'), ('ka', 'Georgian'), ('kab', 'Kabyle'), ('kk', 'Kazakh'), ('km', 'Khmer'), ('kn', 'Kannada'), ('ko', 'Korean'), ('lb', 'Luxembourgish'), ('lt', 'Lithuanian'), ('lv', 'Latvian'), ('mk', 'Macedonian'), ('ml', 'Malayalam'), ('mn', 'Mongolian'), ('mr', 'Marathi'), ('my', 'Burmese'), ('nb', 'Norwegian Bokmål'), ('ne', 'Nepali'), ('nl', 'Dutch'), ('nn', 'Norwegian Nynorsk'), ('os', 'Ossetic'), ('pa', 'Punjabi'), ('pl', 'Polish'), ('pt', 'Portuguese'), ('pt-br', 'Brazilian Portuguese'), ('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'), ('sq', 'Albanian'), ('sr', 'Serbian'), ('sr-latn', 'Serbian Latin'), ('sv', 'Swedish'), ('sw', 'Swahili'), ('ta', 'Tamil'), ('te', 'Telugu'), ('th', 'Thai'), ('tr', 'Turkish'), ('tt', 'Tatar'), ('udm', 'Udmurt'), ('uk', 'Ukrainian'), ('ur', 'Urdu'), ('vi', 'Vietnamese'), ('zh-hans', 'Simplified Chinese'), ('zh-hant', 'Traditional Chinese')], help_text="Language for the template, this should be the list's preferred language.", max_length=5),
),
]
postorius-1.2.4/src/postorius/migrations/0006_auto_20180711_1359.py 0000664 0001750 0001750 00000002261 13413660001 025345 0 ustar maxking maxking 0000000 0000000 # Generated by Django 2.0.6 on 2018-07-11 20:59
from django.db import migrations, models
# flake8: noqa
class Migration(migrations.Migration):
dependencies = [
('postorius', '0005_auto_20180707_1107'),
]
operations = [
migrations.AlterField(
model_name='emailtemplate',
name='data',
field=models.TextField(help_text="Note: Do not add any secret content in templates as they are publicly accessible.\nYou can use these variables in the templates. \n$hyperkitty_url: Permalink to archived message in Hyperkitty\n$listname: Name of the Mailing List e.g. ant@example.com \n$list_id: The List-ID header e.g. ant.example.com \n$display_name: Display name of the mailing list e.g. Ant \n$short_listname: Local part of the listname e.g. ant \n$domain: The domain part of the listname e.g. example.com \n$info: The mailing list's longer descriptive text \n$request_email: The email address for -request address \n$owner_email: The email address for -owner address \n$site_email: The email address to reach the owners of the site \n$language: The two letter language code for list's preferred language e.g. fr, en, de \n"),
),
]
postorius-1.2.4/src/postorius/migrations/0007_auto_20180712_0536.py 0000664 0001750 0001750 00000002516 13413660001 025346 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Generated by Django 1.11.14 on 2018-07-12 05:36
from __future__ import unicode_literals
from django.db import migrations, models
# flake8: noqa
class Migration(migrations.Migration):
dependencies = [
('postorius', '0006_auto_20180711_1359'),
]
operations = [
migrations.AlterField(
model_name='emailtemplate',
name='language',
field=models.CharField(blank=True, choices=[('ar', 'Arabic'), ('ast', 'Asturian'), ('ca', 'Catalan'), ('cs', 'Czech'), ('da', 'Danish'), ('de', 'German'), ('el', 'Greek'), ('es', 'Spanish'), ('et', 'Estonian'), ('eu', 'Euskara'), ('fi', 'Finnish'), ('fr', 'French'), ('gl', 'Galician'), ('he', 'Hebrew'), ('hr', 'Croatian'), ('hu', 'Hungarian'), ('ia', 'Interlingua'), ('it', 'Italian'), ('ja', 'Japanese'), ('ko', 'Korean'), ('lt', 'Lithuanian'), ('nl', 'Dutch'), ('no', 'Norwegian'), ('pl', 'Polish'), ('pt', 'Protuguese'), ('pt_BR', 'Protuguese (Brazil)'), ('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'), ('sr', 'Serbian'), ('sv', 'Swedish'), ('tr', 'Turkish'), ('uk', 'Ukrainian'), ('vi', 'Vietnamese'), ('zh_CN', 'Chinese'), ('zh_TW', 'Chinese (Taiwan)'), ('en', 'English (USA)')], help_text="Language for the template, this should be the list's preferred language.", max_length=5),
),
]
postorius-1.2.4/src/postorius/migrations/__init__.py 0000664 0001750 0001750 00000000000 13413660001 024010 0 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/models.py 0000664 0001750 0001750 00000024511 13414502172 021402 0 ustar maxking maxking 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius 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.
#
# Postorius 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
# Postorius. If not, see .
from __future__ import (
absolute_import, division, print_function, unicode_literals)
import logging
from urllib.parse import urljoin
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.contrib.auth.models import User
from django.db import models
from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver
from django.http import Http404
from django.urls import reverse
from django.utils.six.moves.urllib.error import HTTPError
from django.utils.translation import ugettext_lazy as _
from mailmanclient import MailmanConnectionError
from postorius.utils import get_mailman_client, LANGUAGES
from postorius.template_list import TEMPLATES_LIST
logger = logging.getLogger(__name__)
@receiver(post_save, sender=User)
def create_mailman_user(sender, **kwargs):
if kwargs.get('created'):
if getattr(settings, 'AUTOCREATE_MAILMAN_USER', False):
user = kwargs.get('instance')
try:
MailmanUser.objects.create_from_django(user)
except (MailmanApiError, HTTPError):
logger.error('Mailman user not created for {}'.format(user))
logger.error('Mailman Core API is not reachable.')
class MailmanApiError(Exception):
"""Raised if the API is not available.
"""
pass
class Mailman404Error(Exception):
"""Proxy exception. Raised if the API returns 404."""
pass
class MailmanRestManager(object):
"""Manager class to give a model class CRUD access to the API.
Returns objects (or lists of objects) retrieved from the API.
"""
def __init__(self, resource_name, resource_name_plural, cls_name=None):
self.resource_name = resource_name
self.resource_name_plural = resource_name_plural
def all(self):
try:
return getattr(get_mailman_client(), self.resource_name_plural)
except AttributeError:
raise MailmanApiError
except MailmanConnectionError as e:
raise MailmanApiError(e)
def get(self, *args, **kwargs):
try:
method = getattr(get_mailman_client(), 'get_' + self.resource_name)
return method(*args, **kwargs)
except AttributeError as e:
raise MailmanApiError(e)
except HTTPError as e:
if e.code == 404:
raise Mailman404Error('Mailman resource could not be found.')
else:
raise
except MailmanConnectionError as e:
raise MailmanApiError(e)
def get_or_404(self, *args, **kwargs):
"""Similar to `self.get` but raises standard Django 404 error.
"""
try:
return self.get(*args, **kwargs)
except Mailman404Error:
raise Http404
except MailmanConnectionError as e:
raise MailmanApiError(e)
def create(self, *args, **kwargs):
try:
method = getattr(
get_mailman_client(), 'create_' + self.resource_name)
return method(*args, **kwargs)
except AttributeError as e:
raise MailmanApiError(e)
except HTTPError as e:
if e.code == 409:
raise MailmanApiError
else:
raise
except MailmanConnectionError:
raise MailmanApiError
def delete(self):
"""Not implemented since the objects returned from the API
have a `delete` method of their own.
"""
pass
class MailmanListManager(MailmanRestManager):
def __init__(self):
super(MailmanListManager, self).__init__('list', 'lists')
def all(self, advertised=False):
try:
method = getattr(
get_mailman_client(), 'get_' + self.resource_name_plural)
return method(advertised=advertised)
except AttributeError:
raise MailmanApiError
except MailmanConnectionError as e:
raise MailmanApiError(e)
def by_mail_host(self, mail_host, advertised=False):
objects = self.all(advertised)
host_objects = []
for obj in objects:
if obj.mail_host == mail_host:
host_objects.append(obj)
return host_objects
class MailmanUserManager(MailmanRestManager):
def __init__(self):
super(MailmanUserManager, self).__init__('user', 'users')
def create_from_django(self, user):
return self.create(
email=user.email, password=None, display_name=user.get_full_name())
def get_or_create_from_django(self, user):
try:
return self.get(address=user.email)
except Mailman404Error:
return self.create_from_django(user)
class MailmanRestModel(object):
"""Simple REST Model class to make REST API calls Django style.
"""
MailmanApiError = MailmanApiError
DoesNotExist = Mailman404Error
def __init__(self, *args, **kwargs):
self.args = args
self.kwargs = kwargs
def save(self):
"""Proxy function for `objects.create`.
(REST API uses `create`, while Django uses `save`.)
"""
self.objects.create(*self.args, **self.kwargs)
class Domain(MailmanRestModel):
"""Domain model class.
"""
objects = MailmanRestManager('domain', 'domains')
class List(MailmanRestModel):
"""List model class.
"""
objects = MailmanListManager()
class MailmanUser(MailmanRestModel):
"""MailmanUser model class.
"""
objects = MailmanUserManager()
class Member(MailmanRestModel):
"""Member model class.
"""
objects = MailmanRestManager('member', 'members')
class Style(MailmanRestModel):
"""
"""
objects = MailmanRestManager(None, 'styles')
TEMPLATE_CONTEXT_CHOICES = (
('site', 'Site Wide'),
('domain', 'Domain Wide'),
('list', 'MailingList Wide')
)
class EmailTemplate(models.Model):
"""A Template represents contents of partial or complete emails sent out by
Mailman Core on various events or when an action is required. Headers and
Footers on emails for decorations are also repsented as templates.
"""
name = models.CharField(
max_length=100, choices=TEMPLATES_LIST,
help_text=_('Choose the template you want to customize.'))
data = models.TextField(
help_text=_(
'Note: Do not add any secret content in templates as they are '
'publicly accessible.\n'
'You can use these variables in the templates. \n'
'$hyperkitty_url: Permalink to archived message in Hyperkitty\n'
'$listname: Name of the Mailing List e.g. ant@example.com \n'
'$list_id: The List-ID header e.g. ant.example.com \n'
'$display_name: Display name of the mailing list e.g. Ant \n'
'$short_listname: Local part of the listname e.g. ant \n'
'$domain: The domain part of the listname e.g. example.com \n'
'$info: The mailing list\'s longer descriptive text \n'
'$request_email: The email address for -request address \n'
'$owner_email: The email address for -owner address \n'
'$site_email: The email address to reach the owners of the site \n'
'$language: The two letter language code for list\'s preferred language e.g. fr, en, de \n' # noqa: E501
)
)
language = models.CharField(
max_length=5, choices=LANGUAGES,
help_text=_('Language for the template, this should be the list\'s preferred language.'), # noqa: E501
blank=True)
craeted_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True)
context = models.CharField(max_length=50, choices=TEMPLATE_CONTEXT_CHOICES)
identifier = models.CharField(blank=True, max_length=100)
class Meta:
unique_together = ('name', 'identifier', 'language')
def __str__(self):
return ''.format(self.name, self.context)
@property
def description(self):
"""Return the long description of template that is human readable."""
return dict(TEMPLATES_LIST)[self.name]
@property
def api_url(self):
"""API url is the remote url that Core can use to fetch templates"""
base_url = getattr(settings, 'POSTORIUS_TEMPLATE_BASE_URL', None)
if not base_url:
raise ImproperlyConfigured
resource_url = reverse(
'rest_template',
kwargs=dict(context=self.context,
identifier=self.identifier,
name=self.name)
)
return urljoin(base_url, resource_url)
def _get_context_obj(self):
if self.context == 'list':
obj = List.objects.get_or_404(fqdn_listname=self.identifier)
elif self.context == 'domain':
obj = Domain.objects.get_or_404(mail_host=self.identifier)
elif self.context == 'site':
obj = get_mailman_client()
else:
obj = None
return obj
def _update_core(self, deleted=False):
obj = self._get_context_obj()
if obj is None:
return
if deleted:
# POST'ing an empty string will delete this record in Core.
api_url = ''
else:
# Use the API endpoint of self that Core can use to fetch this.
api_url = self.api_url
obj.set_template(self.name, api_url)
@receiver(post_save, sender=EmailTemplate)
def update_core_post_update(sender, **kwargs):
kwargs['instance']._update_core()
@receiver(post_delete, sender=EmailTemplate)
def update_core_post_delete(sender, **kwargs):
kwargs['instance']._update_core(deleted=True)
postorius-1.2.4/src/postorius/static/ 0000775 0001750 0001750 00000000000 13427706007 021040 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/static/postorius/ 0000775 0001750 0001750 00000000000 13427706007 023107 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/static/postorius/css/ 0000775 0001750 0001750 00000000000 13427706007 023677 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/static/postorius/css/style.css 0000664 0001750 0001750 00000003075 13413660001 025542 0 ustar maxking maxking 0000000 0000000 /* Sticky footer: http://getbootstrap.com/examples/sticky-footer/ */
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 90px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #f8f8f8;
border-top: 1px solid #e7e7e7;
border-radius: 4px;
padding-top: 20px;
}
/* ---- */
.margin-bottom {
margin-bottom: 1em;
}
form.bans-add-form {
margin-bottom: 2.5em;
}
table.bans-current {
width: auto;
}
/* Header matches */
table.header-matches th .text-muted {
font-weight: normal;
font-size: small;
}
table.header-matches td .errorlist {
list-style-type: none;
padding: 0;
margin: 0;
}
.header-matches-pending-changes {
display: none;
margin-left: 1em;
}
.page-header{
margin-top: 0px;
padding-top: 0px;
}
.page-header h1 {
margin-top: 0px;
padding-top: 0px;
}
/* Improve contrast per accessibility guidelines */
.navbar-default .navbar-brand {
color: #666;
}
.navbar-default .navbar-nav > li > a {
color: #666;
}
.h1 .small, .h1 small, .h2 .small, .h2 small, .h3 .small, .h3 small, .h4 .small, .h4 small, .h5 .small, .h5 small, .h6 .small, .h6 small, h1 .small, h1 small, h2 .small, h2 small, h3 .small, h3 small, h4 .small, h4 small, h5 .small, h5 small, h6 .small, h6 small {
color: #666;
}
a {
color: #2269a6;
}
.btn-danger {
background-color: #c8423e;
}
.btn-success {
background-color: #298529;
}
.btn-warning {
background-color: #A4660E;
}
.alert-success {
color: #294C29;
}
.alert-danger {
color: #773231;
}
postorius-1.2.4/src/postorius/static/postorius/img/ 0000775 0001750 0001750 00000000000 13427706007 023663 5 ustar maxking maxking 0000000 0000000 postorius-1.2.4/src/postorius/static/postorius/img/favicon.ico 0000664 0001750 0001750 00000012666 13403007015 026002 0 ustar maxking maxking 0000000 0000000 ( &