mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 02:24:26 +00:00
Merge branch 'master' into stock
This commit is contained in:
commit
20deda8a8e
@ -41,3 +41,13 @@ Sites et doc cools
|
|||||||
------------------
|
------------------
|
||||||
|
|
||||||
[Classy Class-Based Views](http://ccbv.co.uk/projects/Django/1.8/)
|
[Classy Class-Based Views](http://ccbv.co.uk/projects/Django/1.8/)
|
||||||
|
|
||||||
|
Helpers:
|
||||||
|
|
||||||
|
`./manage.py makemessages --ignore "env/*" -e py,jinja`
|
||||||
|
|
||||||
|
`for f in $(find . -name "*.py" ! -path "*migration*" ! -path "./env/*" ! -path "./doc/*"); do cat ./doc/header "$f" > /tmp/temp && mv /tmp/temp "$f"; done`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
687
LICENSE
687
LICENSE
@ -1,21 +1,674 @@
|
|||||||
The MIT License (MIT)
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
Copyright (c) 2016 Skia
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Preamble
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The GNU General Public License is a free, copyleft license for
|
||||||
copies or substantial portions of the Software.
|
software and other kinds of works.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
The licenses for most software and other practical works are designed
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
to take away your freedom to share and change the works. By contrast,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
share and change all versions of a program--to make sure it remains free
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
GNU General Public License for most of our software; it applies also to
|
||||||
SOFTWARE.
|
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.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
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
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
|
21
LICENSE.old
Normal file
21
LICENSE.old
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 Skia
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
15
README.md
15
README.md
@ -22,7 +22,14 @@ generate a complete HTML documentation that will be available in the *./doc/html
|
|||||||
See requirements.txt
|
See requirements.txt
|
||||||
|
|
||||||
You may need to install some dev libraries like `libmysqlclient-dev`, `libssl-dev`, `libjpeg-dev`, or `zlib1g-dev` to install all the
|
You may need to install some dev libraries like `libmysqlclient-dev`, `libssl-dev`, `libjpeg-dev`, or `zlib1g-dev` to install all the
|
||||||
requiered dependancies with pip. You may also need `mysql-client`.
|
requiered dependancies with pip. You may also need `mysql-client`. Don't also forget `python3-dev` if you don't have it
|
||||||
|
already.
|
||||||
|
|
||||||
|
You can check all of them with:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt install libmysqlclient-dev libssl-dev libjpeg-dev zlib1g-dev python3-dev libffi-dev
|
||||||
|
```
|
||||||
|
|
||||||
The development is done with sqlite, but it is advised to set a more robust DBMS for production (Postgresql for example)
|
The development is done with sqlite, but it is advised to set a more robust DBMS for production (Postgresql for example)
|
||||||
|
|
||||||
@ -49,6 +56,12 @@ Finally, when building a class based view, which is highly advised, you just hav
|
|||||||
CanEditMixin, or CanViewMixin, which are located in core.views. Your view will then be protected using either the
|
CanEditMixin, or CanViewMixin, which are located in core.views. Your view will then be protected using either the
|
||||||
appropriate group fields, or the right method to check user permissions.
|
appropriate group fields, or the right method to check user permissions.
|
||||||
|
|
||||||
|
#### Counting the number of line of code
|
||||||
|
|
||||||
|
```
|
||||||
|
# apt install cloc
|
||||||
|
$ cloc --exclude-dir=doc,env .
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from accounting.models import *
|
from accounting.models import *
|
||||||
|
19
accounting/migrations/0005_auto_20170324_0917.py
Normal file
19
accounting/migrations/0005_auto_20170324_0917.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('accounting', '0004_auto_20161005_1505'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='operation',
|
||||||
|
name='remark',
|
||||||
|
field=models.CharField(null=True, max_length=128, blank=True, verbose_name='comment'),
|
||||||
|
),
|
||||||
|
]
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core import validators
|
from django.core import validators
|
||||||
@ -45,6 +69,32 @@ class Company(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("company")
|
verbose_name = _("company")
|
||||||
|
|
||||||
|
def is_owned_by(self, user):
|
||||||
|
"""
|
||||||
|
Method to see if that object can be edited by the given user
|
||||||
|
"""
|
||||||
|
if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def can_be_edited_by(self, user):
|
||||||
|
"""
|
||||||
|
Method to see if that object can be edited by the given user
|
||||||
|
"""
|
||||||
|
for club in user.memberships.filter(end_date=None).all():
|
||||||
|
if club and club.role == settings.SITH_CLUB_ROLES_ID['Treasurer']:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def can_be_viewed_by(self, user):
|
||||||
|
"""
|
||||||
|
Method to see if that object can be viewed by the given user
|
||||||
|
"""
|
||||||
|
for club in user.memberships.filter(end_date=None).all():
|
||||||
|
if club and club.role >= settings.SITH_CLUB_ROLES_ID['Treasurer']:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('accounting:co_edit', kwargs={'co_id': self.id})
|
return reverse('accounting:co_edit', kwargs={'co_id': self.id})
|
||||||
|
|
||||||
@ -71,7 +121,7 @@ class BankAccount(models.Model):
|
|||||||
if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID):
|
if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID):
|
||||||
return True
|
return True
|
||||||
m = self.club.get_membership_for(user)
|
m = self.club.get_membership_for(user)
|
||||||
if m is not None and m.role >= 7:
|
if m is not None and m.role >= settings.SITH_CLUB_ROLES_ID['Treasurer']:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -103,7 +153,7 @@ class ClubAccount(models.Model):
|
|||||||
Method to see if that object can be edited by the given user
|
Method to see if that object can be edited by the given user
|
||||||
"""
|
"""
|
||||||
m = self.club.get_membership_for(user)
|
m = self.club.get_membership_for(user)
|
||||||
if m and m.role == 7:
|
if m and m.role == settings.SITH_CLUB_ROLES_ID['Treasurer']:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -112,7 +162,7 @@ class ClubAccount(models.Model):
|
|||||||
Method to see if that object can be viewed by the given user
|
Method to see if that object can be viewed by the given user
|
||||||
"""
|
"""
|
||||||
m = self.club.get_membership_for(user)
|
m = self.club.get_membership_for(user)
|
||||||
if m and m.role >= 7:
|
if m and m.role >= settings.SITH_CLUB_ROLES_ID['Treasurer']:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -161,6 +211,16 @@ class GeneralJournal(models.Model):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def can_be_edited_by(self, user):
|
||||||
|
"""
|
||||||
|
Method to see if that object can be edited by the given user
|
||||||
|
"""
|
||||||
|
if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID):
|
||||||
|
return True
|
||||||
|
if self.club_account.can_be_edited_by(user):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def can_be_viewed_by(self, user):
|
def can_be_viewed_by(self, user):
|
||||||
return self.club_account.can_be_edited_by(user)
|
return self.club_account.can_be_edited_by(user)
|
||||||
|
|
||||||
@ -192,7 +252,7 @@ class Operation(models.Model):
|
|||||||
journal = models.ForeignKey(GeneralJournal, related_name="operations", null=False, verbose_name=_("journal"))
|
journal = models.ForeignKey(GeneralJournal, related_name="operations", null=False, verbose_name=_("journal"))
|
||||||
amount = CurrencyField(_('amount'))
|
amount = CurrencyField(_('amount'))
|
||||||
date = models.DateField(_('date'))
|
date = models.DateField(_('date'))
|
||||||
remark = models.CharField(_('comment'), max_length=128)
|
remark = models.CharField(_('comment'), max_length=128, null=True, blank=True)
|
||||||
mode = models.CharField(_('payment method'), max_length=255, choices=settings.SITH_ACCOUNTING_PAYMENT_METHOD)
|
mode = models.CharField(_('payment method'), max_length=255, choices=settings.SITH_ACCOUNTING_PAYMENT_METHOD)
|
||||||
cheque_number = models.CharField(_('cheque number'), max_length=32, default="", null=True, blank=True)
|
cheque_number = models.CharField(_('cheque number'), max_length=32, default="", null=True, blank=True)
|
||||||
invoice = models.ForeignKey(SithFile, related_name='operations', verbose_name=_("invoice"), null=True, blank=True)
|
invoice = models.ForeignKey(SithFile, related_name='operations', verbose_name=_("invoice"), null=True, blank=True)
|
||||||
@ -265,7 +325,7 @@ class Operation(models.Model):
|
|||||||
if self.journal.closed:
|
if self.journal.closed:
|
||||||
return False
|
return False
|
||||||
m = self.journal.club_account.club.get_membership_for(user)
|
m = self.journal.club_account.club.get_membership_for(user)
|
||||||
if m is not None and m.role >= 7:
|
if m is not None and m.role >= settings.SITH_CLUB_ROLES_ID['Treasurer']:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -273,7 +333,12 @@ class Operation(models.Model):
|
|||||||
"""
|
"""
|
||||||
Method to see if that object can be edited by the given user
|
Method to see if that object can be edited by the given user
|
||||||
"""
|
"""
|
||||||
if self.is_owned_by(user):
|
if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID):
|
||||||
|
return True
|
||||||
|
if self.journal.closed:
|
||||||
|
return False
|
||||||
|
m = self.journal.club_account.club.get_membership_for(user)
|
||||||
|
if m is not None and m.role == settings.SITH_CLUB_ROLES_ID['Treasurer']:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<hr>
|
<hr>
|
||||||
<h2>{% trans %}Bank account: {% endtrans %}{{ object.name }}</h2>
|
<h2>{% trans %}Bank account: {% endtrans %}{{ object.name }}</h2>
|
||||||
{% if user.is_root and not object.club_accounts.exists() %}
|
{% if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID) and not object.club_accounts.exists() %}
|
||||||
<a href="{{ url('accounting:bank_delete', b_account_id=object.id) }}">{% trans %}Delete{% endtrans %}</a>
|
<a href="{{ url('accounting:bank_delete', b_account_id=object.id) }}">{% trans %}Delete{% endtrans %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<h4>{% trans %}Infos{% endtrans %}</h4>
|
<h4>{% trans %}Infos{% endtrans %}</h4>
|
||||||
@ -24,6 +24,9 @@
|
|||||||
{% for c in object.club_accounts.all() %}
|
{% for c in object.club_accounts.all() %}
|
||||||
<li><a href="{{ url('accounting:club_details', c_account_id=c.id) }}">{{ c }}</a>
|
<li><a href="{{ url('accounting:club_details', c_account_id=c.id) }}">{{ c }}</a>
|
||||||
- <a href="{{ url('accounting:club_edit', c_account_id=c.id) }}">{% trans %}Edit{% endtrans %}</a>
|
- <a href="{{ url('accounting:club_edit', c_account_id=c.id) }}">{% trans %}Edit{% endtrans %}</a>
|
||||||
|
{% if c.journals.count() == 0 %}
|
||||||
|
- <a href="{{ url('accounting:club_delete', c_account_id=c.id) }}">{% trans %}Delete{% endtrans %}</a>
|
||||||
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
{% if user.is_root and not object.journals.exists() %}
|
{% if user.is_root and not object.journals.exists() %}
|
||||||
<a href="{{ url('accounting:club_delete', c_account_id=object.id) }}">{% trans %}Delete{% endtrans %}</a>
|
<a href="{{ url('accounting:club_delete', c_account_id=object.id) }}">{% trans %}Delete{% endtrans %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID) %}
|
||||||
<p><a href="{{ url('accounting:label_new') }}?parent={{ object.id }}">{% trans %}New label{% endtrans %}</a></p>
|
<p><a href="{{ url('accounting:label_new') }}?parent={{ object.id }}">{% trans %}New label{% endtrans %}</a></p>
|
||||||
|
{% endif %}
|
||||||
<p><a href="{{ url('accounting:label_list', clubaccount_id=object.id) }}">{% trans %}Label list{% endtrans %}</a></p>
|
<p><a href="{{ url('accounting:label_list', clubaccount_id=object.id) }}">{% trans %}Label list{% endtrans %}</a></p>
|
||||||
{% if not object.has_open_journal() %}
|
{% if not object.has_open_journal() %}
|
||||||
<p><a href="{{ url('accounting:journal_new') }}?parent={{ object.id }}">{% trans %}New journal{% endtrans %}</a></p>
|
<p><a href="{{ url('accounting:journal_new') }}?parent={{ object.id }}">{% trans %}New journal{% endtrans %}</a></p>
|
||||||
@ -52,7 +54,11 @@
|
|||||||
<td>{% trans %}No{% endtrans %}</td>
|
<td>{% trans %}No{% endtrans %}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td> <a href="{{ url('accounting:journal_details', j_id=j.id) }}">{% trans %}View{% endtrans %}</a>
|
<td> <a href="{{ url('accounting:journal_details', j_id=j.id) }}">{% trans %}View{% endtrans %}</a>
|
||||||
<a href="{{ url('accounting:journal_edit', j_id=j.id) }}">{% trans %}Edit{% endtrans %}</a> </td>
|
<a href="{{ url('accounting:journal_edit', j_id=j.id) }}">{% trans %}Edit{% endtrans %}</a>
|
||||||
|
{% if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID) and j.operations.count() == 0 %}
|
||||||
|
<a href="{{ url('accounting:journal_delete', j_id=j.id) }}">{% trans %}Delete{% endtrans %}</a>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID) or user.is_root %}
|
||||||
<p><a href="{{ url('accounting:co_new') }}">{% trans %}Create new company{% endtrans %}</a></p>
|
<p><a href="{{ url('accounting:co_new') }}">{% trans %}Create new company{% endtrans %}</a></p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</br>
|
</br>
|
||||||
<table>
|
<table>
|
||||||
|
@ -78,9 +78,11 @@
|
|||||||
<td>-</td>
|
<td>-</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td>
|
<td>
|
||||||
|
{% if o.journal.club_account.bank_account.name != "AE TI" and o.journal.club_account.bank_account.name != "TI" or user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID) %}
|
||||||
{% if not o.journal.closed %}
|
{% if not o.journal.closed %}
|
||||||
<a href="{{ url('accounting:op_edit', op_id=o.id) }}">{% trans %}Edit{% endtrans %}</a>
|
<a href="{{ url('accounting:op_edit', op_id=o.id) }}">{% trans %}Edit{% endtrans %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td><a href="{{ url('accounting:op_pdf', op_id=o.id) }}">{% trans %}Generate{% endtrans %}</a></td>
|
<td><a href="{{ url('accounting:op_pdf', op_id=o.id) }}">{% trans %}Generate{% endtrans %}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -12,13 +12,18 @@
|
|||||||
</p>
|
</p>
|
||||||
<hr>
|
<hr>
|
||||||
<p><a href="{{ url('accounting:club_details', c_account_id=object.id) }}">{% trans %}Back to club account{% endtrans %}</a></p>
|
<p><a href="{{ url('accounting:club_details', c_account_id=object.id) }}">{% trans %}Back to club account{% endtrans %}</a></p>
|
||||||
|
{% if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID) %}
|
||||||
<p><a href="{{ url('accounting:label_new') }}?parent={{ object.id }}">{% trans %}New label{% endtrans %}</a></p>
|
<p><a href="{{ url('accounting:label_new') }}?parent={{ object.id }}">{% trans %}New label{% endtrans %}</a></p>
|
||||||
|
{% endif %}
|
||||||
{% if object.labels.all() %}
|
{% if object.labels.all() %}
|
||||||
<h3>{% trans %}Label list{% endtrans %}</h3>
|
<h3>{% trans %}Label list{% endtrans %}</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{% for l in object.labels.all() %}
|
{% for l in object.labels.all() %}
|
||||||
<li><a href="{{ url('accounting:label_edit', label_id=l.id) }}">{{ l }}</a> -
|
<li><a href="{{ url('accounting:label_edit', label_id=l.id) }}">{{ l }}</a>
|
||||||
|
{% if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID) %}
|
||||||
|
-
|
||||||
<a href="{{ url('accounting:label_delete', label_id=l.id) }}">{% trans %}Delete{% endtrans %}</a>
|
<a href="{{ url('accounting:label_delete', label_id=l.id) }}">{% trans %}Delete{% endtrans %}</a>
|
||||||
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.test import Client, TestCase
|
from django.test import Client, TestCase
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
|
|
||||||
from accounting.views import *
|
from accounting.views import *
|
||||||
@ -26,6 +50,7 @@ urlpatterns = [
|
|||||||
url(r'^journal/create$', JournalCreateView.as_view(), name='journal_new'),
|
url(r'^journal/create$', JournalCreateView.as_view(), name='journal_new'),
|
||||||
url(r'^journal/(?P<j_id>[0-9]+)$', JournalDetailView.as_view(), name='journal_details'),
|
url(r'^journal/(?P<j_id>[0-9]+)$', JournalDetailView.as_view(), name='journal_details'),
|
||||||
url(r'^journal/(?P<j_id>[0-9]+)/edit$', JournalEditView.as_view(), name='journal_edit'),
|
url(r'^journal/(?P<j_id>[0-9]+)/edit$', JournalEditView.as_view(), name='journal_edit'),
|
||||||
|
url(r'^journal/(?P<j_id>[0-9]+)/delete$', JournalDeleteView.as_view(), name='journal_delete'),
|
||||||
url(r'^journal/(?P<j_id>[0-9]+)/statement/nature$', JournalNatureStatementView.as_view(), name='journal_nature_statement'),
|
url(r'^journal/(?P<j_id>[0-9]+)/statement/nature$', JournalNatureStatementView.as_view(), name='journal_nature_statement'),
|
||||||
url(r'^journal/(?P<j_id>[0-9]+)/statement/person$', JournalPersonStatementView.as_view(), name='journal_person_statement'),
|
url(r'^journal/(?P<j_id>[0-9]+)/statement/person$', JournalPersonStatementView.as_view(), name='journal_person_statement'),
|
||||||
url(r'^journal/(?P<j_id>[0-9]+)/statement/accounting$', JournalAccountingStatementView.as_view(), name='journal_accounting_statement'),
|
url(r'^journal/(?P<j_id>[0-9]+)/statement/accounting$', JournalAccountingStatementView.as_view(), name='journal_accounting_statement'),
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.views.generic import ListView, DetailView, RedirectView
|
from django.views.generic import ListView, DetailView, RedirectView
|
||||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView, FormView
|
from django.views.generic.edit import UpdateView, CreateView, DeleteView, FormView
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
@ -230,6 +254,21 @@ class JournalEditView(CanEditMixin, UpdateView):
|
|||||||
fields = ['name', 'start_date', 'end_date', 'club_account', 'closed']
|
fields = ['name', 'start_date', 'end_date', 'club_account', 'closed']
|
||||||
template_name = 'core/edit.jinja'
|
template_name = 'core/edit.jinja'
|
||||||
|
|
||||||
|
class JournalDeleteView(CanEditPropMixin, DeleteView):
|
||||||
|
"""
|
||||||
|
Delete a club account (for the admins)
|
||||||
|
"""
|
||||||
|
model = GeneralJournal
|
||||||
|
pk_url_kwarg = "j_id"
|
||||||
|
template_name = 'core/delete_confirm.jinja'
|
||||||
|
success_url = reverse_lazy('accounting:club_details')
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
self.object = self.get_object()
|
||||||
|
if self.object.operations.count() == 0:
|
||||||
|
return super(JournalDeleteView, self).dispatch(request, *args, **kwargs)
|
||||||
|
else:
|
||||||
|
raise PermissionDenied
|
||||||
|
|
||||||
# Operation views
|
# Operation views
|
||||||
|
|
||||||
@ -385,7 +424,7 @@ class OperationPDFView(CanViewMixin, DetailView):
|
|||||||
target = self.object.target.get_display_name()
|
target = self.object.target.get_display_name()
|
||||||
|
|
||||||
response = HttpResponse(content_type='application/pdf')
|
response = HttpResponse(content_type='application/pdf')
|
||||||
response['Content-Disposition'] = 'attachment; filename="op-%d(%s_on_%s).pdf"' %(num, ti, club_name)
|
response['Content-Disposition'] = 'filename="op-%d(%s_on_%s).pdf"' %(num, ti, club_name)
|
||||||
p = canvas.Canvas(response)
|
p = canvas.Canvas(response)
|
||||||
|
|
||||||
p.setFont('DejaVu', 12)
|
p.setFont('DejaVu', 12)
|
||||||
@ -401,8 +440,7 @@ class OperationPDFView(CanViewMixin, DetailView):
|
|||||||
label = Table(labelStr, colWidths=[150], rowHeights=[20])
|
label = Table(labelStr, colWidths=[150], rowHeights=[20])
|
||||||
|
|
||||||
label.setStyle(TableStyle([
|
label.setStyle(TableStyle([
|
||||||
('ALIGN',(0,0),(-1,-1),'CENTER'),
|
('ALIGN',(0,0),(-1,-1),'RIGHT'),
|
||||||
('BOX', (0,0), (-1,-1), 0.25, colors.black),
|
|
||||||
]))
|
]))
|
||||||
w, h = label.wrapOn(label, 0, 0)
|
w, h = label.wrapOn(label, 0, 0)
|
||||||
label.drawOn(p, width-180, height)
|
label.drawOn(p, width-180, height)
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
24
api/admin.py
24
api/admin.py
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
|
24
api/tests.py
24
api/tests.py
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
# Create your tests here.
|
# Create your tests here.
|
||||||
|
24
api/urls.py
24
api/urls.py
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
|
|
||||||
from api.views import *
|
from api.views import *
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.decorators import api_view, renderer_classes
|
from rest_framework.decorators import api_view, renderer_classes
|
||||||
from rest_framework.renderers import StaticHTMLRenderer
|
from rest_framework.renderers import StaticHTMLRenderer
|
||||||
@ -6,14 +30,14 @@ from rest_framework.views import APIView
|
|||||||
from core.templatetags.renderer import markdown
|
from core.templatetags.renderer import markdown
|
||||||
|
|
||||||
|
|
||||||
@api_view(['GET'])
|
@api_view(['POST'])
|
||||||
@renderer_classes((StaticHTMLRenderer,))
|
@renderer_classes((StaticHTMLRenderer,))
|
||||||
def RenderMarkdown(request):
|
def RenderMarkdown(request):
|
||||||
"""
|
"""
|
||||||
Render Markdown
|
Render Markdown
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
data = markdown(request.GET['text'])
|
data = markdown(request.POST['text'])
|
||||||
except:
|
except:
|
||||||
data = 'Error'
|
data = 'Error'
|
||||||
return Response(data)
|
return Response(data)
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from club.models import Club
|
from club.models import Club
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.decorators import list_route
|
from rest_framework.decorators import list_route
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from core.models import RealGroup
|
from core.models import RealGroup
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.decorators import list_route
|
from rest_framework.decorators import list_route
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from club.models import Club, Membership
|
from club.models import Club, Membership
|
||||||
|
18
club/migrations/0007_auto_20170324_0917.py
Normal file
18
club/migrations/0007_auto_20170324_0917.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('club', '0006_auto_20161229_0040'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='club',
|
||||||
|
options={'ordering': ['name', 'unix_name']},
|
||||||
|
),
|
||||||
|
]
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.core import validators
|
from django.core import validators
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -38,6 +62,9 @@ class Club(models.Model):
|
|||||||
home = models.OneToOneField(SithFile, related_name='home_of_club', verbose_name=_("home"), null=True, blank=True,
|
home = models.OneToOneField(SithFile, related_name='home_of_club', verbose_name=_("home"), null=True, blank=True,
|
||||||
on_delete=models.SET_NULL)
|
on_delete=models.SET_NULL)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ['name', 'unix_name']
|
||||||
|
|
||||||
def check_loop(self):
|
def check_loop(self):
|
||||||
"""Raise a validation error when a loop is found within the parent list"""
|
"""Raise a validation error when a loop is found within the parent list"""
|
||||||
objs = []
|
objs = []
|
||||||
@ -122,7 +149,7 @@ class Club(models.Model):
|
|||||||
sub = User.objects.filter(pk=user.pk).first()
|
sub = User.objects.filter(pk=user.pk).first()
|
||||||
if sub is None:
|
if sub is None:
|
||||||
return False
|
return False
|
||||||
return sub.is_subscribed()
|
return sub.is_subscribed
|
||||||
|
|
||||||
def get_membership_for(self, user):
|
def get_membership_for(self, user):
|
||||||
"""
|
"""
|
||||||
@ -151,7 +178,7 @@ class Membership(models.Model):
|
|||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
sub = User.objects.filter(pk=self.user.pk).first()
|
sub = User.objects.filter(pk=self.user.pk).first()
|
||||||
if sub is None or not sub.is_subscribed():
|
if sub is None or not sub.is_subscribed:
|
||||||
raise ValidationError(_('User must be subscriber to take part to a club'))
|
raise ValidationError(_('User must be subscriber to take part to a club'))
|
||||||
if Membership.objects.filter(user=self.user).filter(club=self.club).filter(end_date=None).exists():
|
if Membership.objects.filter(user=self.user).filter(club=self.club).filter(end_date=None).exists():
|
||||||
raise ValidationError(_('User is already member of that club'))
|
raise ValidationError(_('User is already member of that club'))
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
</form>
|
</form>
|
||||||
<p>
|
<p>
|
||||||
{% trans %}Quantity: {% endtrans %}{{ total_quantity }} {% trans %}units{% endtrans %}<br/>
|
{% trans %}Quantity: {% endtrans %}{{ total_quantity }} {% trans %}units{% endtrans %}<br/>
|
||||||
{% trans %}Total: {% endtrans %}{{ total }} €
|
{% trans %}Total: {% endtrans %}{{ total }} €<br/>
|
||||||
|
{% trans %}Benefit: {% endtrans %}{{ benefit }} €
|
||||||
</p>
|
</p>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
<h4>{% trans %}Communication:{% endtrans %}</h4>
|
<h4>{% trans %}Communication:{% endtrans %}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li> <a href="{{ url('com:news_new') }}?club={{ object.id }}">{% trans %}Create a news{% endtrans %}</a></li>
|
<li> <a href="{{ url('com:news_new') }}?club={{ object.id }}">{% trans %}Create a news{% endtrans %}</a></li>
|
||||||
|
<li> <a href="{{ url('com:weekmail_article') }}?club={{ object.id }}">{% trans %}Post in the Weekmail{% endtrans %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h4>{% trans %}Counters:{% endtrans %}</h4>
|
<h4>{% trans %}Counters:{% endtrans %}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
|
24
club/urls.py
24
club/urls.py
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
|
|
||||||
from club.views import *
|
from club.views import *
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.views.generic import ListView, DetailView, TemplateView
|
from django.views.generic import ListView, DetailView, TemplateView
|
||||||
@ -133,6 +157,8 @@ class ClubMembersView(ClubTabsMixin, CanViewMixin, UpdateView):
|
|||||||
form.instance = Membership.objects.filter(club=self.object).filter(user=form.data.get('user')).filter(end_date=None).first()
|
form.instance = Membership.objects.filter(club=self.object).filter(user=form.data.get('user')).filter(end_date=None).first()
|
||||||
if form.instance is None: # Instanciate a new membership
|
if form.instance is None: # Instanciate a new membership
|
||||||
form.instance = Membership(club=self.object, user=self.request.user)
|
form.instance = Membership(club=self.object, user=self.request.user)
|
||||||
|
if not self.request.user.is_root:
|
||||||
|
form.fields.pop('start_date', None)
|
||||||
# form.initial = {'user': self.request.user}
|
# form.initial = {'user': self.request.user}
|
||||||
# form._user = self.request.user
|
# form._user = self.request.user
|
||||||
return form
|
return form
|
||||||
@ -203,6 +229,7 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailView):
|
|||||||
kwargs['result'] = qs.all().order_by('-id')
|
kwargs['result'] = qs.all().order_by('-id')
|
||||||
kwargs['total'] = sum([s.quantity * s.unit_price for s in qs.all()])
|
kwargs['total'] = sum([s.quantity * s.unit_price for s in qs.all()])
|
||||||
kwargs['total_quantity'] = sum([s.quantity for s in qs.all()])
|
kwargs['total_quantity'] = sum([s.quantity for s in qs.all()])
|
||||||
|
kwargs['benefit'] = kwargs['total'] - sum([s.product.purchase_price for s in qs.exclude(product=None)])
|
||||||
else:
|
else:
|
||||||
kwargs['result'] = qs[:0]
|
kwargs['result'] = qs[:0]
|
||||||
kwargs['form'] = form
|
kwargs['form'] = form
|
||||||
@ -222,8 +249,11 @@ class ClubSellingCSVView(ClubSellingView):
|
|||||||
kwargs = self.get_context_data(**kwargs)
|
kwargs = self.get_context_data(**kwargs)
|
||||||
writer = csv.writer(response, delimiter=";", lineterminator='\n', quoting=csv.QUOTE_ALL)
|
writer = csv.writer(response, delimiter=";", lineterminator='\n', quoting=csv.QUOTE_ALL)
|
||||||
|
|
||||||
|
writer.writerow([_t('Quantity'), kwargs['total_quantity']])
|
||||||
|
writer.writerow([_t('Total'), kwargs['total']])
|
||||||
|
writer.writerow([_t('Benefit'), kwargs['benefit']])
|
||||||
writer.writerow([_t('Date'),_t('Counter'),_t('Barman'),_t('Customer'),_t('Label'),
|
writer.writerow([_t('Date'),_t('Counter'),_t('Barman'),_t('Customer'),_t('Label'),
|
||||||
_t('Quantity'), _t('Total'),_t('Payment method')])
|
_t('Quantity'), _t('Total'),_t('Payment method'), _t('Selling price'), _t('Purchase price'), _t('Benefit')])
|
||||||
for o in kwargs['result']:
|
for o in kwargs['result']:
|
||||||
row = [o.date, o.counter]
|
row = [o.date, o.counter]
|
||||||
if o.seller:
|
if o.seller:
|
||||||
@ -234,6 +264,11 @@ class ClubSellingCSVView(ClubSellingView):
|
|||||||
else: row.append('')
|
else: row.append('')
|
||||||
row = row +[o.label, o.quantity, o.quantity * o.unit_price,
|
row = row +[o.label, o.quantity, o.quantity * o.unit_price,
|
||||||
o.get_payment_method_display()]
|
o.get_payment_method_display()]
|
||||||
|
if o.product:
|
||||||
|
row.append(o.product.selling_price)
|
||||||
|
row.append(o.product.purchase_price)
|
||||||
|
row.append(o.product.selling_price - o.product.purchase_price)
|
||||||
|
else: row = row + ['', '', '']
|
||||||
writer.writerow(row)
|
writer.writerow(row)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
25
com/admin.py
25
com/admin.py
@ -1,9 +1,34 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from com.models import *
|
from com.models import *
|
||||||
|
|
||||||
admin.site.register(Sith)
|
admin.site.register(Sith)
|
||||||
admin.site.register(News)
|
admin.site.register(News)
|
||||||
|
admin.site.register(Weekmail)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
49
com/migrations/0003_auto_20170115_2300.py
Normal file
49
com/migrations/0003_auto_20170115_2300.py
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('club', '0006_auto_20161229_0040'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('com', '0002_news_newsdate'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Weekmail',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)),
|
||||||
|
('title', models.CharField(max_length=64, verbose_name='title', blank=True)),
|
||||||
|
('intro', models.TextField(verbose_name='intro', blank=True)),
|
||||||
|
('joke', models.TextField(verbose_name='joke', blank=True)),
|
||||||
|
('protip', models.TextField(verbose_name='protip', blank=True)),
|
||||||
|
('conclusion', models.TextField(verbose_name='conclusion', blank=True)),
|
||||||
|
('sent', models.BooleanField(verbose_name='sent', default=False)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'ordering': ['-id'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='WeekmailArticle',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)),
|
||||||
|
('title', models.CharField(max_length=64, verbose_name='title')),
|
||||||
|
('content', models.TextField(verbose_name='content')),
|
||||||
|
('rank', models.IntegerField(verbose_name='rank', default=-1)),
|
||||||
|
('author', models.ForeignKey(to=settings.AUTH_USER_MODEL, verbose_name='author', related_name='owned_weekmail_articles')),
|
||||||
|
('club', models.ForeignKey(to='club.Club', verbose_name='club', related_name='weekmail_articles')),
|
||||||
|
('weekmail', models.ForeignKey(to='com.Weekmail', verbose_name='weekmail', related_name='articles', null=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sith',
|
||||||
|
name='weekmail_destinations',
|
||||||
|
field=models.TextField(verbose_name='weekmail destinations', default=''),
|
||||||
|
),
|
||||||
|
]
|
@ -1,9 +1,36 @@
|
|||||||
from django.db import models
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
from django.shortcuts import render
|
||||||
|
from django.db import models, transaction
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.core.urlresolvers import reverse_lazy, reverse
|
from django.core.urlresolvers import reverse_lazy, reverse
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.core.mail import EmailMultiAlternatives
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
from core.models import User
|
from core.models import User, Preferences
|
||||||
from club.models import Club
|
from club.models import Club
|
||||||
|
|
||||||
class Sith(models.Model):
|
class Sith(models.Model):
|
||||||
@ -11,6 +38,7 @@ class Sith(models.Model):
|
|||||||
alert_msg = models.TextField(_("alert message"), default="", blank=True)
|
alert_msg = models.TextField(_("alert message"), default="", blank=True)
|
||||||
info_msg = models.TextField(_("info message"), default="", blank=True)
|
info_msg = models.TextField(_("info message"), default="", blank=True)
|
||||||
index_page = models.TextField(_("index page"), default="", blank=True)
|
index_page = models.TextField(_("index page"), default="", blank=True)
|
||||||
|
weekmail_destinations = models.TextField(_("weekmail destinations"), default="")
|
||||||
|
|
||||||
def is_owned_by(self, user):
|
def is_owned_by(self, user):
|
||||||
return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
|
return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
|
||||||
@ -64,3 +92,63 @@ class NewsDate(models.Model):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s: %s - %s" % (self.news.title, self.start_date, self.end_date)
|
return "%s: %s - %s" % (self.news.title, self.start_date, self.end_date)
|
||||||
|
|
||||||
|
class Weekmail(models.Model):
|
||||||
|
"""
|
||||||
|
The weekmail class
|
||||||
|
"""
|
||||||
|
title = models.CharField(_("title"), max_length=64, blank=True)
|
||||||
|
intro = models.TextField(_("intro"), blank=True)
|
||||||
|
joke = models.TextField(_("joke"), blank=True)
|
||||||
|
protip = models.TextField(_("protip"), blank=True)
|
||||||
|
conclusion = models.TextField(_("conclusion"), blank=True)
|
||||||
|
sent = models.BooleanField(_("sent"), default=False)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ['-id']
|
||||||
|
|
||||||
|
def send(self):
|
||||||
|
dest = [i[0] for i in Preferences.objects.filter(receive_weekmail=True).values_list('user__email')]
|
||||||
|
with transaction.atomic():
|
||||||
|
email = EmailMultiAlternatives(
|
||||||
|
subject=self.title,
|
||||||
|
body=self.render_text(),
|
||||||
|
from_email=settings.DEFAULT_FROM_EMAIL,
|
||||||
|
to=Sith.objects.first().weekmail_destinations.split(' '),
|
||||||
|
bcc=dest,
|
||||||
|
)
|
||||||
|
email.attach_alternative(self.render_html(), "text/html")
|
||||||
|
email.send()
|
||||||
|
self.sent = True
|
||||||
|
self.save()
|
||||||
|
Weekmail().save()
|
||||||
|
|
||||||
|
def render_text(self):
|
||||||
|
return render(None, "com/weekmail_renderer_text.jinja", context={
|
||||||
|
'weekmail': self,
|
||||||
|
}).content.decode('utf-8')
|
||||||
|
|
||||||
|
def render_html(self):
|
||||||
|
return render(None, "com/weekmail_renderer_html.jinja", context={
|
||||||
|
'weekmail': self,
|
||||||
|
}).content.decode('utf-8')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "Weekmail %s (sent: %s) - %s" % (self.id, self.sent, self.title)
|
||||||
|
|
||||||
|
def is_owned_by(self, user):
|
||||||
|
return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
|
||||||
|
|
||||||
|
class WeekmailArticle(models.Model):
|
||||||
|
weekmail = models.ForeignKey(Weekmail, related_name="articles", verbose_name=_("weekmail"), null=True)
|
||||||
|
title = models.CharField(_("title"), max_length=64)
|
||||||
|
content = models.TextField(_("content"))
|
||||||
|
author = models.ForeignKey(User, related_name="owned_weekmail_articles", verbose_name=_("author"))
|
||||||
|
club = models.ForeignKey(Club, related_name="weekmail_articles", verbose_name=_("club"))
|
||||||
|
rank = models.IntegerField(_('rank'), default=-1)
|
||||||
|
|
||||||
|
def is_owned_by(self, user):
|
||||||
|
return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "%s - %s (%s)" % (self.title, self.author, self.club)
|
||||||
|
@ -11,16 +11,6 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if 'preview' in request.POST.keys() %}
|
{% if 'preview' in request.POST.keys() %}
|
||||||
<section class="news_event">
|
|
||||||
<h4> <a href="#">{{ form.instance.title }}</a></h4>
|
|
||||||
<p class="date">
|
|
||||||
<span>{{ form.instance.dates.first().start_date|localtime|time(DATETIME_FORMAT) }}</span> -
|
|
||||||
<span>{{ form.instance.dates.first().end_date|localtime|time(DATETIME_FORMAT) }}</span>
|
|
||||||
</p>
|
|
||||||
<p><a href="#">{{ form.instance.club or "Club" }}</a></p>
|
|
||||||
<p>{{ form.instance.summary|markdown }}</p>
|
|
||||||
</section>
|
|
||||||
<hr>
|
|
||||||
<section class="news_event">
|
<section class="news_event">
|
||||||
<h4>{{ form.instance.title }}</h4>
|
<h4>{{ form.instance.title }}</h4>
|
||||||
<p class="date">
|
<p class="date">
|
||||||
|
@ -54,8 +54,10 @@ section.news_event:nth-of-type(even) {
|
|||||||
<section class="news_event">
|
<section class="news_event">
|
||||||
<h4> <a href="{{ url('com:news_detail', news_id=news.id) }}">{{ news.title }}</a></h4>
|
<h4> <a href="{{ url('com:news_detail', news_id=news.id) }}">{{ news.title }}</a></h4>
|
||||||
<p class="date">
|
<p class="date">
|
||||||
<span>{{ news.dates.first().start_date|localtime|time(DATETIME_FORMAT) }}</span> -
|
<span>{{ news.dates.first().start_date|localtime|date(DATETIME_FORMAT) }}
|
||||||
<span>{{ news.dates.first().end_date|localtime|time(DATETIME_FORMAT) }}</span>
|
{{ news.dates.first().start_date|localtime|time(DATETIME_FORMAT) }}</span> -
|
||||||
|
<span>{{ news.dates.first().end_date|localtime|date(DATETIME_FORMAT) }}
|
||||||
|
{{ news.dates.first().end_date|localtime|time(DATETIME_FORMAT) }}</span>
|
||||||
</p>
|
</p>
|
||||||
<p><a href="{{ news.club.get_absolute_url() }}">{{ news.club }}</a></p>
|
<p><a href="{{ news.club.get_absolute_url() }}">{{ news.club }}</a></p>
|
||||||
<p>{{ news.summary|markdown }}</p>
|
<p>{{ news.summary|markdown }}</p>
|
||||||
|
79
com/templates/com/weekmail.jinja
Normal file
79
com/templates/com/weekmail.jinja
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
{% extends "core/base.jinja" %}
|
||||||
|
{% from 'core/macros.jinja' import user_profile_link %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{% trans %}Weekmail{% endtrans %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h3>{% trans %}Weekmail{% endtrans %} {{ object.id }}</h3>
|
||||||
|
<p><a href="{{ url('com:weekmail_preview') }}">{% trans %}Preview{% endtrans %}</a></p>
|
||||||
|
<p><a href="{{ url('com:weekmail_preview') }}?send=true">{% trans %}Send{% endtrans %}</a></p>
|
||||||
|
<p><a href="{{ url('com:weekmail_article') }}">{% trans %}New article{% endtrans %}</a></p>
|
||||||
|
<h4>{% trans %}Articles in no weekmail yet{% endtrans %}</h4>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>{% trans %}Author{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Club{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Title{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Content{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Actions{% endtrans %}</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for a in orphans.all() %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ user_profile_link(a.author) }}</td>
|
||||||
|
<td><a href="{{ a.club.get_absolute_url() }}">{{ a.club }}</a></td>
|
||||||
|
<td>{{ a.title }}</td>
|
||||||
|
<td>{{ a.content|markdown }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ url('com:weekmail_article_edit', article_id=a.id) }}">{% trans %}Edit{% endtrans %}</a> |
|
||||||
|
<a href="{{ url('com:weekmail_article_delete', article_id=a.id) }}">{% trans %}Delete{% endtrans %}</a> |
|
||||||
|
<a href="?add_article={{ a.id }}">{% trans %}Add to weekmail{% endtrans %}</a> |
|
||||||
|
<a href="?up_article={{ a.id }}">{% trans %}Up{% endtrans %}</a> |
|
||||||
|
<a href="?down_article={{ a.id }}">{% trans %}Down{% endtrans %}</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<h4>{% trans %}Articles included the next weekmail{% endtrans %}</h4>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>{% trans %}Author{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Club{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Title{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Content{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Actions{% endtrans %}</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for a in object.articles.order_by('rank') %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ user_profile_link(a.author) }}</td>
|
||||||
|
<td><a href="{{ a.club.get_absolute_url() }}">{{ a.club }}</a></td>
|
||||||
|
<td>{{ a.title }}</td>
|
||||||
|
<td>{{ a.content|markdown }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ url('com:weekmail_article_edit', article_id=a.id) }}">{% trans %}Edit{% endtrans %}</a> |
|
||||||
|
<a href="{{ url('com:weekmail_article_delete', article_id=a.id) }}">{% trans %}Delete{% endtrans %}</a> |
|
||||||
|
<a href="?del_article={{ a.id }}">{% trans %}Delete from weekmail{% endtrans %}</a> |
|
||||||
|
<a href="?up_article={{ a.id }}">{% trans %}Up{% endtrans %}</a> |
|
||||||
|
<a href="?down_article={{ a.id }}">{% trans %}Down{% endtrans %}</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<form action="" method="post" enctype="multipart/form-data">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p() }}
|
||||||
|
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
25
com/templates/com/weekmail_preview.jinja
Normal file
25
com/templates/com/weekmail_preview.jinja
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{% extends "core/base.jinja" %}
|
||||||
|
{% from 'core/macros.jinja' import user_profile_link %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{{ weekmail.title }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<a href="{{ url('com:weekmail') }}">{% trans %}Back{% endtrans %}</a>
|
||||||
|
{% if request.GET['send'] %}
|
||||||
|
<p>{% trans %}Are you sure you want to send this weekmail?{% endtrans %}</p>
|
||||||
|
{% if request.LANGUAGE_CODE != settings.LANGUAGE_CODE[:2] %}
|
||||||
|
<p><strong>{% trans %}Warning: you are sending the weekmail in another language than the default one!{% endtrans %}</strong></p>
|
||||||
|
{% endif %}
|
||||||
|
<form method="post" action="">
|
||||||
|
{% csrf_token %}
|
||||||
|
<button type="submit" name="send" value="validate">{% trans %}Send{% endtrans %}</button>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
<hr>
|
||||||
|
{{ weekmail_rendered|safe }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
46
com/templates/com/weekmail_renderer_html.jinja
Normal file
46
com/templates/com/weekmail_renderer_html.jinja
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<style type="text/css" media="all">
|
||||||
|
h1, h2, h3, h4, h5, h6, p {
|
||||||
|
padding: 5px;
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div style="background: black; padding: 0px 5%;">
|
||||||
|
<div style="background: white;">
|
||||||
|
<h2 style="background: lightblue;">{{ weekmail.title }}</h2>
|
||||||
|
|
||||||
|
{% if weekmail.intro %}
|
||||||
|
<h3 style="background: black; color: white">{% trans %}Intro{% endtrans %}</h3>
|
||||||
|
{{ weekmail.intro|markdown }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<h3 style="background: black; color: white">{% trans %}Table of content{% endtrans %}</h3>
|
||||||
|
<ul>
|
||||||
|
{% for a in weekmail.articles.all() %}
|
||||||
|
<li>[{{ a.club }}] {{ a.title }}</li>
|
||||||
|
{%- endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{%- for a in weekmail.articles.all() %}
|
||||||
|
<h3 style="background: lightblue;">[{{ a.club }}] {{ a.title }}</h3>
|
||||||
|
{{ a.content|markdown }}
|
||||||
|
{%- endfor -%}
|
||||||
|
|
||||||
|
{%- if weekmail.joke %}
|
||||||
|
<h3 style="background: black; color: white">{% trans %}Joke{% endtrans %}</h3>
|
||||||
|
{{ weekmail.joke|markdown }}
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
|
{%- if weekmail.protip %}
|
||||||
|
<h3 style="background: black; color: white">{% trans %}Pro tip{% endtrans %}</h3>
|
||||||
|
{{ weekmail.protip|markdown }}
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
|
{%- if weekmail.conclusion %}
|
||||||
|
<h3 style="background: black; color: white">{% trans %}Final word{% endtrans %}</h3>
|
||||||
|
{{ weekmail.conclusion|markdown }}
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
32
com/templates/com/weekmail_renderer_text.jinja
Normal file
32
com/templates/com/weekmail_renderer_text.jinja
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# {{ weekmail.title }}
|
||||||
|
|
||||||
|
{%- if weekmail.intro %}
|
||||||
|
## {% trans %}Intro{% endtrans %}
|
||||||
|
{{ weekmail.intro }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
## {% trans %}Table of content{% endtrans %}
|
||||||
|
{% for a in weekmail.articles.all() %}
|
||||||
|
* [{{ a.club }}] {{ a.title }}
|
||||||
|
{% endfor -%}
|
||||||
|
|
||||||
|
{% for a in weekmail.articles.all() %}
|
||||||
|
## [{{ a.club }}] {{ a.title }}
|
||||||
|
{{ a.content }}
|
||||||
|
{% endfor -%}
|
||||||
|
|
||||||
|
{%- if weekmail.joke %}
|
||||||
|
## {% trans %}Joke{% endtrans %}
|
||||||
|
{{ weekmail.joke }}
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
|
{%- if weekmail.protip %}
|
||||||
|
## {% trans %}Pro tip{% endtrans %}
|
||||||
|
{{ weekmail.protip }}
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
|
{%- if weekmail.conclusion %}
|
||||||
|
## {% trans %}Final word{% endtrans %}
|
||||||
|
{{ weekmail.conclusion }}
|
||||||
|
{% endif -%}
|
||||||
|
|
24
com/tests.py
24
com/tests.py
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
30
com/urls.py
30
com/urls.py
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
|
|
||||||
from com.views import *
|
from com.views import *
|
||||||
@ -6,6 +30,12 @@ urlpatterns = [
|
|||||||
url(r'^sith/edit/alert$', AlertMsgEditView.as_view(), name='alert_edit'),
|
url(r'^sith/edit/alert$', AlertMsgEditView.as_view(), name='alert_edit'),
|
||||||
url(r'^sith/edit/info$', InfoMsgEditView.as_view(), name='info_edit'),
|
url(r'^sith/edit/info$', InfoMsgEditView.as_view(), name='info_edit'),
|
||||||
url(r'^sith/edit/index$', IndexEditView.as_view(), name='index_edit'),
|
url(r'^sith/edit/index$', IndexEditView.as_view(), name='index_edit'),
|
||||||
|
url(r'^sith/edit/weekmail_destinations$', WeekmailDestinationEditView.as_view(), name='weekmail_destinations'),
|
||||||
|
url(r'^weekmail$', WeekmailEditView.as_view(), name='weekmail'),
|
||||||
|
url(r'^weekmail/preview$', WeekmailPreviewView.as_view(), name='weekmail_preview'),
|
||||||
|
url(r'^weekmail/new_article$', WeekmailArticleCreateView.as_view(), name='weekmail_article'),
|
||||||
|
url(r'^weekmail/article/(?P<article_id>[0-9]+)/delete$', WeekmailArticleDeleteView.as_view(), name='weekmail_article_delete'),
|
||||||
|
url(r'^weekmail/article/(?P<article_id>[0-9]+)/edit$', WeekmailArticleEditView.as_view(), name='weekmail_article_edit'),
|
||||||
url(r'^news$', NewsListView.as_view(), name='news_list'),
|
url(r'^news$', NewsListView.as_view(), name='news_list'),
|
||||||
url(r'^news/admin$', NewsAdminListView.as_view(), name='news_admin_list'),
|
url(r'^news/admin$', NewsAdminListView.as_view(), name='news_admin_list'),
|
||||||
url(r'^news/create$', NewsCreateView.as_view(), name='news_new'),
|
url(r'^news/create$', NewsCreateView.as_view(), name='news_new'),
|
||||||
|
176
com/views.py
176
com/views.py
@ -1,18 +1,45 @@
|
|||||||
from django.shortcuts import render, redirect
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
|
from django.http import HttpResponseRedirect
|
||||||
from django.views.generic import ListView, DetailView, RedirectView
|
from django.views.generic import ListView, DetailView, RedirectView
|
||||||
from django.views.generic.edit import UpdateView, CreateView
|
from django.views.generic.edit import UpdateView, CreateView, DeleteView
|
||||||
from django.views.generic.detail import SingleObjectMixin
|
from django.views.generic.detail import SingleObjectMixin
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.core.urlresolvers import reverse, reverse_lazy
|
from django.core.urlresolvers import reverse, reverse_lazy
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.db.models import Max
|
||||||
|
from django.forms.models import modelform_factory
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from com.models import Sith, News, NewsDate
|
from com.models import Sith, News, NewsDate, Weekmail, WeekmailArticle
|
||||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin, CanCreateMixin
|
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin, CanCreateMixin, QuickNotifMixin
|
||||||
from core.views.forms import SelectDateTime
|
from core.views.forms import SelectDateTime
|
||||||
from core.models import Notification, RealGroup
|
from core.models import Notification, RealGroup
|
||||||
from club.models import Club
|
from club.models import Club
|
||||||
@ -28,6 +55,16 @@ class ComTabsMixin(TabedViewMixin):
|
|||||||
|
|
||||||
def get_list_of_tabs(self):
|
def get_list_of_tabs(self):
|
||||||
tab_list = []
|
tab_list = []
|
||||||
|
tab_list.append({
|
||||||
|
'url': reverse('com:weekmail'),
|
||||||
|
'slug': 'weekmail',
|
||||||
|
'name': _("Weekmail"),
|
||||||
|
})
|
||||||
|
tab_list.append({
|
||||||
|
'url': reverse('com:weekmail_destinations'),
|
||||||
|
'slug': 'weekmail_destinations',
|
||||||
|
'name': _("Weekmail destinations"),
|
||||||
|
})
|
||||||
tab_list.append({
|
tab_list.append({
|
||||||
'url': reverse('com:index_edit'),
|
'url': reverse('com:index_edit'),
|
||||||
'slug': 'index',
|
'slug': 'index',
|
||||||
@ -67,6 +104,11 @@ class IndexEditView(ComEditView):
|
|||||||
current_tab = "index"
|
current_tab = "index"
|
||||||
success_url = reverse_lazy('com:index_edit')
|
success_url = reverse_lazy('com:index_edit')
|
||||||
|
|
||||||
|
class WeekmailDestinationEditView(ComEditView):
|
||||||
|
fields = ['weekmail_destinations']
|
||||||
|
current_tab = "weekmail_destinations"
|
||||||
|
success_url = reverse_lazy('com:weekmail_destinations')
|
||||||
|
|
||||||
# News
|
# News
|
||||||
|
|
||||||
class NewsForm(forms.ModelForm):
|
class NewsForm(forms.ModelForm):
|
||||||
@ -89,6 +131,8 @@ class NewsForm(forms.ModelForm):
|
|||||||
self.add_error('start_date', ValidationError(_("This field is required.")))
|
self.add_error('start_date', ValidationError(_("This field is required.")))
|
||||||
if not self.cleaned_data['end_date']:
|
if not self.cleaned_data['end_date']:
|
||||||
self.add_error('end_date', ValidationError(_("This field is required.")))
|
self.add_error('end_date', ValidationError(_("This field is required.")))
|
||||||
|
if self.cleaned_data['start_date'] > self.cleaned_data['end_date']:
|
||||||
|
self.add_error('end_date', ValidationError(_("You crazy? You can not finish an event before starting it.")))
|
||||||
if self.cleaned_data['type'] == "WEEKLY" and not self.cleaned_data['until']:
|
if self.cleaned_data['type'] == "WEEKLY" and not self.cleaned_data['until']:
|
||||||
self.add_error('until', ValidationError(_("This field is required.")))
|
self.add_error('until', ValidationError(_("This field is required.")))
|
||||||
return self.cleaned_data
|
return self.cleaned_data
|
||||||
@ -148,7 +192,7 @@ class NewsEditView(CanEditMixin, UpdateView):
|
|||||||
Notification(user=u, url=reverse("com:news_detail", kwargs={'news_id': self.object.id}), type="NEWS_MODERATION").save()
|
Notification(user=u, url=reverse("com:news_detail", kwargs={'news_id': self.object.id}), type="NEWS_MODERATION").save()
|
||||||
return super(NewsEditView, self).form_valid(form)
|
return super(NewsEditView, self).form_valid(form)
|
||||||
|
|
||||||
class NewsCreateView(CanCreateMixin, CreateView):
|
class NewsCreateView(CanCreateMixin, CreateView): #XXX no can_be_created_by function in News model
|
||||||
model = News
|
model = News
|
||||||
form_class = NewsForm
|
form_class = NewsForm
|
||||||
template_name = 'com/news_edit.jinja'
|
template_name = 'com/news_edit.jinja'
|
||||||
@ -213,4 +257,126 @@ class NewsDetailView(CanViewMixin, DetailView):
|
|||||||
template_name = 'com/news_detail.jinja'
|
template_name = 'com/news_detail.jinja'
|
||||||
pk_url_kwarg = 'news_id'
|
pk_url_kwarg = 'news_id'
|
||||||
|
|
||||||
|
# Weekmail
|
||||||
|
|
||||||
|
class WeekmailPreviewView(ComTabsMixin, CanEditPropMixin, DetailView):
|
||||||
|
model = Weekmail
|
||||||
|
template_name = 'com/weekmail_preview.jinja'
|
||||||
|
success_url = reverse_lazy('com:weekmail')
|
||||||
|
current_tab = "weekmail"
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
self.object = self.get_object()
|
||||||
|
try:
|
||||||
|
if request.POST['send'] == "validate":
|
||||||
|
self.object.send()
|
||||||
|
return HttpResponseRedirect(reverse('com:weekmail') + "?qn_weekmail_send_success")
|
||||||
|
except: pass
|
||||||
|
return super(WeekmailEditView, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def get_object(self, queryset=None):
|
||||||
|
return self.model.objects.filter(sent=False).order_by('-id').first()
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
"""Add rendered weekmail"""
|
||||||
|
kwargs = super(WeekmailPreviewView, self).get_context_data(**kwargs)
|
||||||
|
kwargs['weekmail_rendered'] = self.object.render_html()
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
class WeekmailEditView(ComTabsMixin, QuickNotifMixin, CanEditPropMixin, UpdateView):
|
||||||
|
model = Weekmail
|
||||||
|
template_name = 'com/weekmail.jinja'
|
||||||
|
form_class = modelform_factory(Weekmail, fields=['title', 'intro', 'joke', 'protip', 'conclusion'],
|
||||||
|
help_texts={'title': _("Delete and save to regenerate")})
|
||||||
|
success_url = reverse_lazy('com:weekmail')
|
||||||
|
current_tab = "weekmail"
|
||||||
|
|
||||||
|
def get_object(self, queryset=None):
|
||||||
|
weekmail = self.model.objects.filter(sent=False).order_by('-id').first()
|
||||||
|
if not weekmail.title:
|
||||||
|
now = timezone.now()
|
||||||
|
weekmail.title = _("Weekmail of the ") + (now + timedelta(days=6 - now.weekday())).strftime('%d/%m/%Y')
|
||||||
|
weekmail.save()
|
||||||
|
return weekmail
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
self.object = self.get_object()
|
||||||
|
if 'up_article' in request.GET.keys():
|
||||||
|
art = get_object_or_404(WeekmailArticle, id=request.GET['up_article'], weekmail=self.object)
|
||||||
|
prev_art = self.object.articles.order_by('rank').filter(rank__lt=art.rank).last()
|
||||||
|
if prev_art:
|
||||||
|
art.rank, prev_art.rank = prev_art.rank, art.rank
|
||||||
|
art.save()
|
||||||
|
prev_art.save()
|
||||||
|
self.quick_notif_list += ['qn_success']
|
||||||
|
if 'down_article' in request.GET.keys():
|
||||||
|
art = get_object_or_404(WeekmailArticle, id=request.GET['down_article'], weekmail=self.object)
|
||||||
|
next_art = self.object.articles.order_by('rank').filter(rank__gt=art.rank).first()
|
||||||
|
if next_art:
|
||||||
|
art.rank, next_art.rank = next_art.rank, art.rank
|
||||||
|
art.save()
|
||||||
|
next_art.save()
|
||||||
|
self.quick_notif_list += ['qn_success']
|
||||||
|
if 'add_article' in request.GET.keys():
|
||||||
|
art = get_object_or_404(WeekmailArticle, id=request.GET['add_article'], weekmail=None)
|
||||||
|
art.weekmail = self.object
|
||||||
|
art.rank = self.object.articles.aggregate(Max('rank'))['rank__max'] or 0
|
||||||
|
art.rank += 1
|
||||||
|
art.save()
|
||||||
|
self.quick_notif_list += ['qn_success']
|
||||||
|
if 'del_article' in request.GET.keys():
|
||||||
|
art = get_object_or_404(WeekmailArticle, id=request.GET['del_article'], weekmail=self.object)
|
||||||
|
art.weekmail = None
|
||||||
|
art.rank = -1
|
||||||
|
art.save()
|
||||||
|
self.quick_notif_list += ['qn_success']
|
||||||
|
return super(WeekmailEditView, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
"""Add orphan articles """
|
||||||
|
kwargs = super(WeekmailEditView, self).get_context_data(**kwargs)
|
||||||
|
kwargs['orphans'] = WeekmailArticle.objects.filter(weekmail=None)
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
class WeekmailArticleEditView(ComTabsMixin, QuickNotifMixin, CanEditPropMixin, UpdateView):
|
||||||
|
"""Edit an article"""
|
||||||
|
model = WeekmailArticle
|
||||||
|
fields = ['title', 'club', 'content']
|
||||||
|
pk_url_kwarg = "article_id"
|
||||||
|
template_name = 'core/edit.jinja'
|
||||||
|
success_url = reverse_lazy('com:weekmail')
|
||||||
|
quick_notif_url_arg = "qn_weekmail_article_edit"
|
||||||
|
current_tab = "weekmail"
|
||||||
|
|
||||||
|
class WeekmailArticleCreateView(QuickNotifMixin, CreateView): #XXX need to protect this view
|
||||||
|
"""Post an article"""
|
||||||
|
model = WeekmailArticle
|
||||||
|
fields = ['title', 'club', 'content']
|
||||||
|
template_name = 'core/create.jinja'
|
||||||
|
success_url = reverse_lazy('core:user_tools')
|
||||||
|
quick_notif_url_arg = "qn_weekmail_new_article"
|
||||||
|
|
||||||
|
def get_initial(self):
|
||||||
|
init = {}
|
||||||
|
try:
|
||||||
|
init['club'] = Club.objects.filter(id=self.request.GET['club']).first()
|
||||||
|
except: pass
|
||||||
|
return init
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
# club = get_object_or_404(Club, id=self.kwargs['club_id'])
|
||||||
|
# form.instance.club = club
|
||||||
|
form.instance.author = self.request.user
|
||||||
|
return super(WeekmailArticleCreateView, self).form_valid(form)
|
||||||
|
|
||||||
|
class WeekmailArticleDeleteView(CanEditPropMixin, DeleteView):
|
||||||
|
"""Delete an article"""
|
||||||
|
model = WeekmailArticle
|
||||||
|
template_name = 'core/delete_confirm.jinja'
|
||||||
|
success_url = reverse_lazy('com:weekmail')
|
||||||
|
pk_url_kwarg = "article_id"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from ajax_select import make_ajax_form
|
from ajax_select import make_ajax_form
|
||||||
from core.models import User, Page, RealGroup, SithFile
|
from core.models import User, Page, RealGroup, SithFile
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from ajax_select import register, LookupChannel
|
from ajax_select import register, LookupChannel
|
||||||
|
|
||||||
@ -14,7 +38,7 @@ def check_token(request):
|
|||||||
|
|
||||||
class RightManagedLookupChannel(LookupChannel):
|
class RightManagedLookupChannel(LookupChannel):
|
||||||
def check_auth(self, request):
|
def check_auth(self, request):
|
||||||
if not request.user.subscribed and not check_token(request):
|
if not request.user.was_subscribed and not check_token(request):
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
|
|
||||||
@register('users')
|
@register('users')
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from io import StringIO, BytesIO
|
from io import StringIO, BytesIO
|
||||||
@ -16,8 +40,9 @@ from core.utils import resize_image
|
|||||||
from club.models import Club, Membership
|
from club.models import Club, Membership
|
||||||
from subscription.models import Subscription
|
from subscription.models import Subscription
|
||||||
from counter.models import Customer, ProductType, Product, Counter
|
from counter.models import Customer, ProductType, Product, Counter
|
||||||
from com.models import Sith
|
from com.models import Sith, Weekmail
|
||||||
from election.models import Election, Role, Candidature, ElectionList
|
from election.models import Election, Role, Candidature, ElectionList
|
||||||
|
from forum.models import Forum, ForumMessage, ForumTopic
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
@ -37,7 +62,9 @@ class Command(BaseCommand):
|
|||||||
Site(id=4000, domain=settings.SITH_URL, name=settings.SITH_NAME).save()
|
Site(id=4000, domain=settings.SITH_URL, name=settings.SITH_NAME).save()
|
||||||
root_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
root_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
||||||
Group(name="Root").save()
|
Group(name="Root").save()
|
||||||
Group(name="Not registered users").save()
|
Group(name="Public").save()
|
||||||
|
Group(name="Subscribers").save()
|
||||||
|
Group(name="Old subscribers").save()
|
||||||
Group(name="Accounting admin").save()
|
Group(name="Accounting admin").save()
|
||||||
Group(name="Communication admin").save()
|
Group(name="Communication admin").save()
|
||||||
Group(name="Counter admin").save()
|
Group(name="Counter admin").save()
|
||||||
@ -45,6 +72,7 @@ class Command(BaseCommand):
|
|||||||
Group(name="Banned from counters").save()
|
Group(name="Banned from counters").save()
|
||||||
Group(name="Banned to subscribe").save()
|
Group(name="Banned to subscribe").save()
|
||||||
Group(name="SAS admin").save()
|
Group(name="SAS admin").save()
|
||||||
|
Group(name="Forum admin").save()
|
||||||
self.reset_index("core", "auth")
|
self.reset_index("core", "auth")
|
||||||
root = User(id=0, username='root', last_name="", first_name="Bibou",
|
root = User(id=0, username='root', last_name="", first_name="Bibou",
|
||||||
email="ae.info@utbm.fr",
|
email="ae.info@utbm.fr",
|
||||||
@ -86,7 +114,8 @@ class Command(BaseCommand):
|
|||||||
home_root.save()
|
home_root.save()
|
||||||
club_root.save()
|
club_root.save()
|
||||||
|
|
||||||
Sith().save()
|
Sith(weekmail_destinations="etudiants@git.an personnel@git.an").save()
|
||||||
|
Weekmail().save()
|
||||||
|
|
||||||
p = Page(name='Index')
|
p = Page(name='Index')
|
||||||
p.set_lock(root)
|
p.set_lock(root)
|
||||||
@ -428,3 +457,15 @@ Welcome to the wiki page!
|
|||||||
cand = Candidature(role=pres, user=sli, election_list=listeT, program="En fait j'aime pas l'info, je voulais faire GMC")
|
cand = Candidature(role=pres, user=sli, election_list=listeT, program="En fait j'aime pas l'info, je voulais faire GMC")
|
||||||
cand.save()
|
cand.save()
|
||||||
|
|
||||||
|
# Forum
|
||||||
|
room = Forum(name="Salon de discussions", description="Pour causer de tout", is_category=True)
|
||||||
|
room.save()
|
||||||
|
Forum(name="AE", description="Réservé au bureau AE", parent=room).save()
|
||||||
|
Forum(name="BdF", description="Réservé au bureau BdF", parent=room).save()
|
||||||
|
hall = Forum(name="Hall de discussions", description="Pour toutes les discussions", parent=room)
|
||||||
|
hall.save()
|
||||||
|
various = Forum(name="Divers", description="Pour causer de rien", is_category=True)
|
||||||
|
various.save()
|
||||||
|
Forum(name="Promos", description="Réservé aux Promos", parent=various).save()
|
||||||
|
ForumTopic(forum=hall)
|
||||||
|
|
||||||
|
33
core/management/commands/setup.py
Executable file → Normal file
33
core/management/commands/setup.py
Executable file → Normal file
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
@ -14,9 +38,14 @@ class Command(BaseCommand):
|
|||||||
root_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
root_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
||||||
try:
|
try:
|
||||||
os.mkdir(os.path.join(root_path)+'/data')
|
os.mkdir(os.path.join(root_path)+'/data')
|
||||||
|
print("Data dir created")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
repr(e)
|
||||||
call_command('flush')
|
try:
|
||||||
|
os.remove(os.path.join(root_path, 'db.sqlite3'))
|
||||||
|
print("db.sqlite3 deleted")
|
||||||
|
except Exception as e:
|
||||||
|
repr(e)
|
||||||
call_command('migrate')
|
call_command('migrate')
|
||||||
if options['prod']:
|
if options['prod']:
|
||||||
call_command('populate', '--prod')
|
call_command('populate', '--prod')
|
||||||
|
183
core/markdown.py
183
core/markdown.py
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from mistune import Renderer, InlineGrammar, InlineLexer, Markdown
|
from mistune import Renderer, InlineGrammar, InlineLexer, Markdown
|
||||||
from django.core.urlresolvers import reverse_lazy, reverse
|
from django.core.urlresolvers import reverse_lazy, reverse
|
||||||
@ -7,9 +31,102 @@ class SithRenderer(Renderer):
|
|||||||
def file_link(self, id, suffix):
|
def file_link(self, id, suffix):
|
||||||
return reverse('core:file_detail', kwargs={'file_id': id}) + suffix
|
return reverse('core:file_detail', kwargs={'file_id': id}) + suffix
|
||||||
|
|
||||||
|
def exposant(self, text):
|
||||||
|
return """<sup>%s</sup>""" % text
|
||||||
|
|
||||||
|
def indice(self, text):
|
||||||
|
return """<sub>%s</sub>""" % text
|
||||||
|
|
||||||
|
def underline(self, text):
|
||||||
|
return """<span class="underline">%s</span>""" % text
|
||||||
|
|
||||||
|
class SithInlineGrammar(InlineGrammar):
|
||||||
|
double_emphasis = re.compile(
|
||||||
|
r'^\*{2}([\s\S]+?)\*{2}(?!\*)' # **word**
|
||||||
|
)
|
||||||
|
emphasis = re.compile(
|
||||||
|
r'^\*((?:\*\*|[^\*])+?)\*(?!\*)' # *word*
|
||||||
|
)
|
||||||
|
underline = re.compile(
|
||||||
|
r'^_{2}([\s\S]+?)_{2}(?!_)' # __word__
|
||||||
|
)
|
||||||
|
exposant = re.compile( # FIXME Does not work for now
|
||||||
|
r'^\^([\s\S]+?)\^' # ^text^
|
||||||
|
# r'|' # FIXME doesn't properly works like this
|
||||||
|
# r'^\^(\S+)' # ^word
|
||||||
|
)
|
||||||
|
indice = re.compile(
|
||||||
|
r'^_([\s\S]+?)_' # _text_ (^` hack, because no other solution were found :/ this sadly prevent code in indices)
|
||||||
|
# r'|' # FIXME doesn't properly works like this
|
||||||
|
# r'^_(\S+)' # _word
|
||||||
|
)
|
||||||
|
|
||||||
class SithInlineLexer(InlineLexer):
|
class SithInlineLexer(InlineLexer):
|
||||||
|
grammar_class = SithInlineGrammar
|
||||||
|
|
||||||
|
default_rules = [
|
||||||
|
'escape',
|
||||||
|
'inline_html',
|
||||||
|
'autolink',
|
||||||
|
'url',
|
||||||
|
'footnote',
|
||||||
|
'link',
|
||||||
|
'reflink',
|
||||||
|
'nolink',
|
||||||
|
'exposant',
|
||||||
|
'double_emphasis',
|
||||||
|
'emphasis',
|
||||||
|
'underline',
|
||||||
|
'indice',
|
||||||
|
'code',
|
||||||
|
'linebreak',
|
||||||
|
'strikethrough',
|
||||||
|
'text',
|
||||||
|
]
|
||||||
|
inline_html_rules = [
|
||||||
|
'escape',
|
||||||
|
'autolink',
|
||||||
|
'url',
|
||||||
|
'link',
|
||||||
|
'reflink',
|
||||||
|
'nolink',
|
||||||
|
'exposant',
|
||||||
|
'double_emphasis',
|
||||||
|
'emphasis',
|
||||||
|
'underline',
|
||||||
|
'indice',
|
||||||
|
'code',
|
||||||
|
'linebreak',
|
||||||
|
'strikethrough',
|
||||||
|
'text',
|
||||||
|
]
|
||||||
|
|
||||||
|
def output_underline(self, m):
|
||||||
|
text = m.group(1)
|
||||||
|
return self.renderer.underline(text)
|
||||||
|
|
||||||
|
def output_exposant(self, m):
|
||||||
|
text = m.group(1)
|
||||||
|
return self.renderer.exposant(text)
|
||||||
|
|
||||||
|
def output_indice(self, m):
|
||||||
|
text = m.group(1)
|
||||||
|
return self.renderer.indice(text)
|
||||||
|
|
||||||
|
# Double emphasis rule changed
|
||||||
|
def output_double_emphasis(self, m):
|
||||||
|
text = m.group(1)
|
||||||
|
text = self.output(text)
|
||||||
|
return self.renderer.double_emphasis(text)
|
||||||
|
|
||||||
|
# Emphasis rule changed
|
||||||
|
def output_emphasis(self, m):
|
||||||
|
text = m.group(1)
|
||||||
|
text = self.output(text)
|
||||||
|
return self.renderer.emphasis(text)
|
||||||
|
|
||||||
def _process_link(self, m, link, title=None):
|
def _process_link(self, m, link, title=None):
|
||||||
try:
|
try: # Add page:// support for links
|
||||||
page = re.compile(
|
page = re.compile(
|
||||||
r'^page://(\S*)' # page://nom_de_ma_page
|
r'^page://(\S*)' # page://nom_de_ma_page
|
||||||
)
|
)
|
||||||
@ -17,7 +134,7 @@ class SithInlineLexer(InlineLexer):
|
|||||||
page = match.group(1) or ""
|
page = match.group(1) or ""
|
||||||
link = reverse('core:page', kwargs={'page_name': page})
|
link = reverse('core:page', kwargs={'page_name': page})
|
||||||
except: pass
|
except: pass
|
||||||
try:
|
try: # Add file:// support for links
|
||||||
file_link = re.compile(
|
file_link = re.compile(
|
||||||
r'^file://(\d*)/?(\S*)?' # file://4000/download
|
r'^file://(\d*)/?(\S*)?' # file://4000/download
|
||||||
)
|
)
|
||||||
@ -28,30 +145,48 @@ class SithInlineLexer(InlineLexer):
|
|||||||
except: pass
|
except: pass
|
||||||
return super(SithInlineLexer, self)._process_link(m, link, title)
|
return super(SithInlineLexer, self)._process_link(m, link, title)
|
||||||
|
|
||||||
# def enable_file_link(self):
|
renderer = SithRenderer(escape=True)
|
||||||
# # add file_link rules
|
|
||||||
# self.rules.file_link = re.compile(
|
|
||||||
# r'dfile://(\d*)/?(\S*)?' # dfile://4000/download
|
|
||||||
# )
|
|
||||||
# # Add file_link parser to default rules
|
|
||||||
# # you can insert it some place you like
|
|
||||||
# # but place matters, maybe 2 is not good
|
|
||||||
# self.default_rules.insert(0, 'file_link')
|
|
||||||
|
|
||||||
# def output_file_link(self, m):
|
|
||||||
# id = m.group(1)
|
|
||||||
# suffix = m.group(2) or ""
|
|
||||||
# # you can create an custom render
|
|
||||||
# # you can also return the html if you like
|
|
||||||
# # return directly html like this:
|
|
||||||
# # return reverse('core:file_detail', kwargs={'file_id': id}) + suffix
|
|
||||||
# return self.renderer.file_link(id, suffix)
|
|
||||||
|
|
||||||
renderer = SithRenderer()
|
|
||||||
inline = SithInlineLexer(renderer)
|
inline = SithInlineLexer(renderer)
|
||||||
|
|
||||||
# enable the features
|
|
||||||
# inline.enable_file_link()
|
|
||||||
markdown = Markdown(renderer, inline=inline)
|
markdown = Markdown(renderer, inline=inline)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(markdown.inline.default_rules)
|
||||||
|
print(markdown.inline.inline_html_rules)
|
||||||
|
text = """
|
||||||
|
## Basique
|
||||||
|
|
||||||
|
* Mettre le texte en **gras** : `**texte**`
|
||||||
|
|
||||||
|
* Mettre le texte en *italique* : `*texte*`
|
||||||
|
|
||||||
|
* __Souligner__ le texte : `__texte__`
|
||||||
|
|
||||||
|
* ~~Barrer du texte~~ : `~~texte~~`
|
||||||
|
|
||||||
|
* Mettre ^du texte^ en ^exposant^ : `^mot` ou `^texte^`
|
||||||
|
|
||||||
|
* _Mettre du texte_ en _indice_ : `_mot` ou `_texte_`
|
||||||
|
|
||||||
|
* Pied de page [^en pied de page]
|
||||||
|
|
||||||
|
## Blocs de citations
|
||||||
|
|
||||||
|
Un bloc de citation se crée ainsi :
|
||||||
|
```
|
||||||
|
> Ceci est
|
||||||
|
> un bloc de
|
||||||
|
> citation
|
||||||
|
```
|
||||||
|
|
||||||
|
> Ceci est
|
||||||
|
> un bloc de
|
||||||
|
> citation
|
||||||
|
|
||||||
|
Il est possible d'intégrer de la syntaxe Markdown-AE dans un tel bloc.
|
||||||
|
|
||||||
|
Petit *test* _sur_ ^une^ **seule** ^ligne pour voir^
|
||||||
|
|
||||||
|
"""
|
||||||
|
print(markdown(text))
|
||||||
|
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.functional import SimpleLazyObject
|
from django.utils.functional import SimpleLazyObject
|
||||||
|
19
core/migrations/0019_preferences_receive_weekmail.py
Normal file
19
core/migrations/0019_preferences_receive_weekmail.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0018_auto_20161224_0211'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='preferences',
|
||||||
|
name='receive_weekmail',
|
||||||
|
field=models.BooleanField(default=False, verbose_name='do you want to receive the weekmail'),
|
||||||
|
),
|
||||||
|
]
|
24
core/migrations/0020_auto_20170324_0917.py
Normal file
24
core/migrations/0020_auto_20170324_0917.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.core.validators
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0019_preferences_receive_weekmail'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='group',
|
||||||
|
options={'ordering': ['name']},
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='page',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(validators=[django.core.validators.RegexValidator('^[A-z.+-]+$', 'Enter a valid page name. This value may contain only unaccented letters, numbers and ./+/-/_ characters.')], max_length=30, verbose_name='page unix name'),
|
||||||
|
),
|
||||||
|
]
|
112
core/models.py
112
core/models.py
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, UserManager, Group as AuthGroup, GroupManager as AuthGroupManager, AnonymousUser as AuthAnonymousUser
|
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, UserManager, Group as AuthGroup, GroupManager as AuthGroupManager, AnonymousUser as AuthAnonymousUser
|
||||||
@ -10,6 +34,10 @@ from django.conf import settings
|
|||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||||
from django.utils.html import escape
|
from django.utils.html import escape
|
||||||
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
from phonenumber_field.modelfields import PhoneNumberField
|
from phonenumber_field.modelfields import PhoneNumberField
|
||||||
|
|
||||||
from datetime import datetime, timedelta, date
|
from datetime import datetime, timedelta, date
|
||||||
@ -31,6 +59,10 @@ class Group(AuthGroup):
|
|||||||
help_text=_('Whether a group is a meta group or not'),
|
help_text=_('Whether a group is a meta group or not'),
|
||||||
)
|
)
|
||||||
description = models.CharField(_('description'), max_length=60)
|
description = models.CharField(_('description'), max_length=60)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ['name']
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
"""
|
"""
|
||||||
This is needed for black magic powered UpdateView's children
|
This is needed for black magic powered UpdateView's children
|
||||||
@ -182,9 +214,11 @@ class User(AbstractBaseUser):
|
|||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return self.__dict__
|
return self.__dict__
|
||||||
|
|
||||||
|
@cached_property
|
||||||
def was_subscribed(self):
|
def was_subscribed(self):
|
||||||
return self.subscriptions.exists()
|
return self.subscriptions.exists()
|
||||||
|
|
||||||
|
@cached_property
|
||||||
def is_subscribed(self):
|
def is_subscribed(self):
|
||||||
s = self.subscriptions.last()
|
s = self.subscriptions.last()
|
||||||
return s.is_valid_now() if s is not None else False
|
return s.is_valid_now() if s is not None else False
|
||||||
@ -204,8 +238,12 @@ class User(AbstractBaseUser):
|
|||||||
return False
|
return False
|
||||||
if group_id == settings.SITH_GROUP_PUBLIC_ID:
|
if group_id == settings.SITH_GROUP_PUBLIC_ID:
|
||||||
return True
|
return True
|
||||||
|
if group_id == settings.SITH_GROUP_SUBSCRIBERS_ID:
|
||||||
|
return self.is_subscribed
|
||||||
|
if group_id == settings.SITH_GROUP_OLD_SUBSCRIBERS_ID:
|
||||||
|
return self.was_subscribed
|
||||||
if group_name == settings.SITH_MAIN_MEMBERS_GROUP: # We check the subscription if asked
|
if group_name == settings.SITH_MAIN_MEMBERS_GROUP: # We check the subscription if asked
|
||||||
return self.is_subscribed()
|
return self.is_subscribed
|
||||||
if group_name[-len(settings.SITH_BOARD_SUFFIX):] == settings.SITH_BOARD_SUFFIX:
|
if group_name[-len(settings.SITH_BOARD_SUFFIX):] == settings.SITH_BOARD_SUFFIX:
|
||||||
from club.models import Club
|
from club.models import Club
|
||||||
name = group_name[:-len(settings.SITH_BOARD_SUFFIX)]
|
name = group_name[:-len(settings.SITH_BOARD_SUFFIX)]
|
||||||
@ -226,25 +264,25 @@ class User(AbstractBaseUser):
|
|||||||
return True
|
return True
|
||||||
return self.groups.filter(name=group_name).exists()
|
return self.groups.filter(name=group_name).exists()
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def is_root(self):
|
def is_root(self):
|
||||||
return self.is_superuser or self.groups.filter(id=settings.SITH_GROUP_ROOT_ID).exists()
|
return self.is_superuser or self.groups.filter(id=settings.SITH_GROUP_ROOT_ID).exists()
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def is_board_member(self):
|
def is_board_member(self):
|
||||||
from club.models import Club
|
from club.models import Club
|
||||||
return Club.objects.filter(unix_name=settings.SITH_MAIN_CLUB['unix_name']).first().get_membership_for(self)
|
return Club.objects.filter(unix_name=settings.SITH_MAIN_CLUB['unix_name']).first().get_membership_for(self)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def is_launderette_manager(self):
|
def is_launderette_manager(self):
|
||||||
from club.models import Club
|
from club.models import Club
|
||||||
return Club.objects.filter(unix_name=settings.SITH_LAUNDERETTE_MANAGER['unix_name']).first().get_membership_for(self)
|
return Club.objects.filter(unix_name=settings.SITH_LAUNDERETTE_MANAGER['unix_name']).first().get_membership_for(self)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def is_banned_alcohol(self):
|
def is_banned_alcohol(self):
|
||||||
return self.is_in_group(settings.SITH_GROUP_BANNED_ALCOHOL_ID)
|
return self.is_in_group(settings.SITH_GROUP_BANNED_ALCOHOL_ID)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def is_banned_counter(self):
|
def is_banned_counter(self):
|
||||||
return self.is_in_group(settings.SITH_GROUP_BANNED_COUNTER_ID)
|
return self.is_in_group(settings.SITH_GROUP_BANNED_COUNTER_ID)
|
||||||
|
|
||||||
@ -402,7 +440,7 @@ class User(AbstractBaseUser):
|
|||||||
return user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user.is_root
|
return user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user.is_root
|
||||||
|
|
||||||
def can_be_viewed_by(self, user):
|
def can_be_viewed_by(self, user):
|
||||||
return (user.is_in_group(settings.SITH_MAIN_MEMBERS_GROUP) and self.is_subscriber_viewable) or user.is_root
|
return (user.was_subscribed and self.is_subscriber_viewable) or user.is_root
|
||||||
|
|
||||||
def get_mini_item(self):
|
def get_mini_item(self):
|
||||||
return """
|
return """
|
||||||
@ -418,14 +456,25 @@ class User(AbstractBaseUser):
|
|||||||
escape(self.get_display_name()),
|
escape(self.get_display_name()),
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def subscribed(self):
|
def subscribed(self):
|
||||||
return self.is_in_group(settings.SITH_MAIN_MEMBERS_GROUP)
|
return self.is_in_group(settings.SITH_MAIN_MEMBERS_GROUP)
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def forum_infos(self):
|
||||||
|
try:
|
||||||
|
return self._forum_infos
|
||||||
|
except:
|
||||||
|
from forum.models import ForumUserInfo
|
||||||
|
infos = ForumUserInfo(user=self)
|
||||||
|
infos.save()
|
||||||
|
return infos
|
||||||
|
|
||||||
class AnonymousUser(AuthAnonymousUser):
|
class AnonymousUser(AuthAnonymousUser):
|
||||||
def __init__(self, request):
|
def __init__(self, request):
|
||||||
super(AnonymousUser, self).__init__()
|
super(AnonymousUser, self).__init__()
|
||||||
|
|
||||||
|
@property
|
||||||
def was_subscribed(self):
|
def was_subscribed(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -487,12 +536,23 @@ class AnonymousUser(AuthAnonymousUser):
|
|||||||
|
|
||||||
class Preferences(models.Model):
|
class Preferences(models.Model):
|
||||||
user = models.OneToOneField(User, related_name="preferences")
|
user = models.OneToOneField(User, related_name="preferences")
|
||||||
|
receive_weekmail = models.BooleanField(
|
||||||
|
_('do you want to receive the weekmail'),
|
||||||
|
default=False,
|
||||||
|
# help_text=_('Do you want to receive the weekmail?'),
|
||||||
|
)
|
||||||
show_my_stats = models.BooleanField(
|
show_my_stats = models.BooleanField(
|
||||||
_('define if we show a users stats'),
|
_('define if we show a users stats'),
|
||||||
default=False,
|
default=False,
|
||||||
help_text=_('Show your account statistics to others'),
|
help_text=_('Show your account statistics to others'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_display_name(self):
|
||||||
|
return self.user.get_display_name()
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return self.user.get_absolute_url()
|
||||||
|
|
||||||
def get_directory(instance, filename):
|
def get_directory(instance, filename):
|
||||||
return '.{0}/{1}'.format(instance.get_parent_path(), filename)
|
return '.{0}/{1}'.format(instance.get_parent_path(), filename)
|
||||||
|
|
||||||
@ -630,10 +690,10 @@ class SithFile(models.Model):
|
|||||||
if self.is_folder:
|
if self.is_folder:
|
||||||
for c in self.children.all():
|
for c in self.children.all():
|
||||||
c.move_to(self)
|
c.move_to(self)
|
||||||
shutil.rmtree(settings.MEDIA_ROOT + old_file_name)
|
shutil.rmtree(os.path.join(settings.MEDIA_ROOT, old_file_name))
|
||||||
else:
|
else:
|
||||||
self.file.save(name=self.name, content=self.file)
|
self.file.save(name=self.name, content=self.file)
|
||||||
os.remove(settings.MEDIA_ROOT + old_file_name)
|
os.remove(os.path.join(settings.MEDIA_ROOT, old_file_name))
|
||||||
|
|
||||||
def __getattribute__(self, attr):
|
def __getattribute__(self, attr):
|
||||||
if attr == "is_file":
|
if attr == "is_file":
|
||||||
@ -641,12 +701,12 @@ class SithFile(models.Model):
|
|||||||
else:
|
else:
|
||||||
return super(SithFile, self).__getattribute__(attr)
|
return super(SithFile, self).__getattribute__(attr)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def as_picture(self):
|
def as_picture(self):
|
||||||
from sas.models import Picture
|
from sas.models import Picture
|
||||||
return Picture.objects.filter(id=self.id).first()
|
return Picture.objects.filter(id=self.id).first()
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def as_album(self):
|
def as_album(self):
|
||||||
from sas.models import Album
|
from sas.models import Album
|
||||||
return Album.objects.filter(id=self.id).first()
|
return Album.objects.filter(id=self.id).first()
|
||||||
@ -703,7 +763,15 @@ class Page(models.Model):
|
|||||||
Be careful with the _full_name attribute: this field may not be valid until you call save(). It's made for fast
|
Be careful with the _full_name attribute: this field may not be valid until you call save(). It's made for fast
|
||||||
query, but don't rely on it when playing with a Page object, use get_full_name() instead!
|
query, but don't rely on it when playing with a Page object, use get_full_name() instead!
|
||||||
"""
|
"""
|
||||||
name = models.CharField(_('page name'), max_length=30, blank=False)
|
name = models.CharField(_('page unix name'), max_length=30,
|
||||||
|
validators=[
|
||||||
|
validators.RegexValidator(
|
||||||
|
r'^[A-z.+-]+$',
|
||||||
|
_('Enter a valid page name. This value may contain only '
|
||||||
|
'unaccented letters, numbers ' 'and ./+/-/_ characters.')
|
||||||
|
),
|
||||||
|
],
|
||||||
|
blank=False)
|
||||||
parent = models.ForeignKey('self', related_name="children", verbose_name=_("parent"), null=True, blank=True, on_delete=models.SET_NULL)
|
parent = models.ForeignKey('self', related_name="children", verbose_name=_("parent"), null=True, blank=True, on_delete=models.SET_NULL)
|
||||||
# Attention: this field may not be valid until you call save(). It's made for fast query, but don't rely on it when
|
# Attention: this field may not be valid until you call save(). It's made for fast query, but don't rely on it when
|
||||||
# playing with a Page object, use get_full_name() instead!
|
# playing with a Page object, use get_full_name() instead!
|
||||||
@ -808,6 +876,14 @@ class Page(models.Model):
|
|||||||
p.set_lock_recursive(user)
|
p.set_lock_recursive(user)
|
||||||
self.set_lock(user)
|
self.set_lock(user)
|
||||||
|
|
||||||
|
def unset_lock_recursive(self):
|
||||||
|
"""
|
||||||
|
Unlocks recursively all the child pages
|
||||||
|
"""
|
||||||
|
for p in self.children.all():
|
||||||
|
p.unset_lock_recursive()
|
||||||
|
self.unset_lock()
|
||||||
|
|
||||||
def unset_lock(self):
|
def unset_lock(self):
|
||||||
"""Always try to unlock, even if there is no lock"""
|
"""Always try to unlock, even if there is no lock"""
|
||||||
self.lock_user = None
|
self.lock_user = None
|
||||||
@ -848,6 +924,16 @@ class Page(models.Model):
|
|||||||
except:
|
except:
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def delete(self):
|
||||||
|
self.unset_lock_recursive()
|
||||||
|
self.set_lock_recursive(User.objects.get(id=0))
|
||||||
|
for child in self.children.all():
|
||||||
|
child.parent = self.parent
|
||||||
|
child.save()
|
||||||
|
child.unset_lock_recursive()
|
||||||
|
super(Page, self).delete()
|
||||||
|
|
||||||
|
|
||||||
class PageRev(models.Model):
|
class PageRev(models.Model):
|
||||||
"""
|
"""
|
||||||
This is the true content of the page.
|
This is the true content of the page.
|
||||||
|
@ -1,4 +1,30 @@
|
|||||||
from haystack import indexes
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
from haystack import indexes, signals
|
||||||
|
|
||||||
from core.models import User
|
from core.models import User
|
||||||
|
|
||||||
@ -15,3 +41,15 @@ class UserIndex(indexes.SearchIndex, indexes.Indexable):
|
|||||||
|
|
||||||
def get_updated_field(self):
|
def get_updated_field(self):
|
||||||
return "last_update"
|
return "last_update"
|
||||||
|
|
||||||
|
|
||||||
|
class UserOnlySignalProcessor(signals.BaseSignalProcessor):
|
||||||
|
def setup(self):
|
||||||
|
# Listen only to the ``User`` model.
|
||||||
|
models.signals.post_save.connect(self.handle_save, sender=User)
|
||||||
|
models.signals.post_delete.connect(self.handle_delete, sender=User)
|
||||||
|
|
||||||
|
def teardown(self):
|
||||||
|
# Disconnect only for the ``User`` model.
|
||||||
|
models.signals.post_save.disconnect(self.handle_save, sender=User)
|
||||||
|
models.signals.post_delete.disconnect(self.handle_delete, sender=User)
|
||||||
|
BIN
core/static/core/img/partners.png
Normal file
BIN
core/static/core/img/partners.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
@ -35,6 +35,9 @@ $( function() {
|
|||||||
popup.html('<iframe src="/file/popup" width="100%" height="95%"></iframe><div id="file_id" value="null" />');
|
popup.html('<iframe src="/file/popup" width="100%" height="95%"></iframe><div id="file_id" value="null" />');
|
||||||
popup.dialog({title: $(this).text()}).dialog( "open" );
|
popup.dialog({title: $(this).text()}).dialog( "open" );
|
||||||
});
|
});
|
||||||
|
$("#quick_notif li").click(function () {
|
||||||
|
$(this).hide();
|
||||||
|
})
|
||||||
} );
|
} );
|
||||||
|
|
||||||
function display_notif() {
|
function display_notif() {
|
||||||
|
@ -11,6 +11,20 @@ a {
|
|||||||
}
|
}
|
||||||
a:hover { color: #7FDBFF; }
|
a:hover { color: #7FDBFF; }
|
||||||
a:active { color: #007BE6; }
|
a:active { color: #007BE6; }
|
||||||
|
.ib {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 2px;
|
||||||
|
margin: 2px;
|
||||||
|
}
|
||||||
|
.w_big {
|
||||||
|
width: 75%;
|
||||||
|
}
|
||||||
|
.w_medium {
|
||||||
|
width: 45%;
|
||||||
|
}
|
||||||
|
.w_small {
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
/*--------------------------------HEADER-------------------------------*/
|
/*--------------------------------HEADER-------------------------------*/
|
||||||
#logo {
|
#logo {
|
||||||
margin-left: 5%;
|
margin-left: 5%;
|
||||||
@ -122,6 +136,15 @@ nav a:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------CONTENT------------------------------*/
|
/*--------------------------------CONTENT------------------------------*/
|
||||||
|
#quick_notif {
|
||||||
|
width: 90%;
|
||||||
|
margin: 0px auto;
|
||||||
|
list-style-type: none;
|
||||||
|
background: lightblue;
|
||||||
|
}
|
||||||
|
#quick_notif li {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
#content {
|
#content {
|
||||||
width: 88%;
|
width: 88%;
|
||||||
margin: 0px auto;
|
margin: 0px auto;
|
||||||
@ -180,7 +203,11 @@ ul, ol {
|
|||||||
code {
|
code {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
|
blockquote {
|
||||||
|
margin: 10px;
|
||||||
|
padding: 5px;
|
||||||
|
border: solid 1px black;
|
||||||
|
}
|
||||||
.edit-bar {
|
.edit-bar {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 4px;
|
margin: 4px;
|
||||||
@ -220,10 +247,16 @@ tbody>tr:hover {
|
|||||||
background: darkgrey;
|
background: darkgrey;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
em {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
.highlight {
|
.highlight {
|
||||||
background: orange;
|
background: orange;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.underline {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
.tool-bar {
|
.tool-bar {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
@ -363,6 +396,80 @@ textarea {
|
|||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*------------------------------FORUM----------------------------------*/
|
||||||
|
.topic a, .forum a, .category a {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
.topic a:hover, .forum a:hover, .category a:hover {
|
||||||
|
color: #424242;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.topic {
|
||||||
|
border: solid skyblue 1px;
|
||||||
|
padding: 2px;
|
||||||
|
margin: 2px;
|
||||||
|
}
|
||||||
|
.forum {
|
||||||
|
background: lightblue;
|
||||||
|
padding: 2px;
|
||||||
|
margin: 2px;
|
||||||
|
}
|
||||||
|
.category {
|
||||||
|
background: skyblue;
|
||||||
|
}
|
||||||
|
.message {
|
||||||
|
padding: 2px;
|
||||||
|
margin: 2px;
|
||||||
|
background: #eff7ff;
|
||||||
|
}
|
||||||
|
.message:nth-child(odd) {
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
.message h5 {
|
||||||
|
font-size: 100%;
|
||||||
|
}
|
||||||
|
.message.unread {
|
||||||
|
background: #d8e7f3;
|
||||||
|
}
|
||||||
|
.msg_author.deleted {
|
||||||
|
background: #ffcfcf;
|
||||||
|
}
|
||||||
|
.msg_content.deleted {
|
||||||
|
background: #ffefef;
|
||||||
|
}
|
||||||
|
.msg_content {
|
||||||
|
display: inline-block;
|
||||||
|
width: 80%;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
.msg_author {
|
||||||
|
display: inline-block;
|
||||||
|
width: 19%;
|
||||||
|
text-align: center;
|
||||||
|
background: #d8e7f3;
|
||||||
|
}
|
||||||
|
.msg_author img {
|
||||||
|
max-width: 70%;
|
||||||
|
margin: 0px auto;
|
||||||
|
}
|
||||||
|
.msg_meta {
|
||||||
|
font-size: small;
|
||||||
|
list-style-type: none;
|
||||||
|
}
|
||||||
|
.msg_meta li {
|
||||||
|
padding: 2px;
|
||||||
|
margin: 2px;
|
||||||
|
}
|
||||||
|
.forum_signature {
|
||||||
|
color: #C0C0C0;
|
||||||
|
border-top: 1px solid #C0C0C0;
|
||||||
|
}
|
||||||
|
.forum_signature a {
|
||||||
|
color: #C0C0C0;
|
||||||
|
}
|
||||||
|
.forum_signature a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
/*------------------------------SAS------------------------------------*/
|
/*------------------------------SAS------------------------------------*/
|
||||||
.album {
|
.album {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -54,8 +54,8 @@
|
|||||||
<ul id="notif">
|
<ul id="notif">
|
||||||
{% for n in user.notifications.filter(viewed=False).order_by('-id') %}
|
{% for n in user.notifications.filter(viewed=False).order_by('-id') %}
|
||||||
<li><a href="{{ url("core:notification", notif_id=n.id) }}">
|
<li><a href="{{ url("core:notification", notif_id=n.id) }}">
|
||||||
<span style="font-size: small; ">{{ n.date|date(DATE_FORMAT) }} {{
|
<span style="font-size: small; ">{{ n.date|localtime|date(DATE_FORMAT) }} {{
|
||||||
n.date|time(DATETIME_FORMAT) }}</span><br>
|
n.date|localtime|time(DATETIME_FORMAT) }}</span><br>
|
||||||
{{ n }}</a></li>
|
{{ n }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<li><a href="{{ url('core:notification_list') }}">{% trans %}View more{% endtrans %}</a>
|
<li><a href="{{ url('core:notification_list') }}">{% trans %}View more{% endtrans %}</a>
|
||||||
@ -91,7 +91,7 @@
|
|||||||
<a href="https://ae.utbm.fr/matmatronch/">{% trans %}Matmatronch{% endtrans %}</a>
|
<a href="https://ae.utbm.fr/matmatronch/">{% trans %}Matmatronch{% endtrans %}</a>
|
||||||
<a href="{{ url('core:page', page_name="Index") }}">{% trans %}Wiki{% endtrans %}</a>
|
<a href="{{ url('core:page', page_name="Index") }}">{% trans %}Wiki{% endtrans %}</a>
|
||||||
<a href="{{ url('sas:main') }}">{% trans %}SAS{% endtrans %}</a>
|
<a href="{{ url('sas:main') }}">{% trans %}SAS{% endtrans %}</a>
|
||||||
<a href="https://ae.utbm.fr/forum2/">{% trans %}Forum{% endtrans %}</a>
|
<a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a>
|
||||||
<a href="{{ url('core:page', "services") }}">{% trans %}Services{% endtrans %}</a>
|
<a href="{{ url('core:page', "services") }}">{% trans %}Services{% endtrans %}</a>
|
||||||
<a href="{{ url('core:file_list') }}">{% trans %}Files{% endtrans %}</a>
|
<a href="{{ url('core:file_list') }}">{% trans %}Files{% endtrans %}</a>
|
||||||
<a href="https://ae.utbm.fr/article.php?name=liens">{% trans %}Sponsors{% endtrans %}</a>
|
<a href="https://ae.utbm.fr/article.php?name=liens">{% trans %}Sponsors{% endtrans %}</a>
|
||||||
@ -100,6 +100,12 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
<ul id="quick_notif">
|
||||||
|
{% for n in quick_notifs %}
|
||||||
|
<li>{{ n }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
{% if list_of_tabs %}
|
{% if list_of_tabs %}
|
||||||
<div class="tool-bar">
|
<div class="tool-bar">
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
<li style="background: lightgrey;">
|
<li style="background: lightgrey;">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="{{ url("core:notification", notif_id=n.id) }}">
|
<a href="{{ url("core:notification", notif_id=n.id) }}">
|
||||||
<span style="font-size: small; ">{{ n.date|date(DATE_FORMAT) }} {{
|
<span style="font-size: small; ">{{ n.date|localtime|date(DATE_FORMAT) }} {{
|
||||||
n.date|time(DATETIME_FORMAT) }}</span><br>
|
n.date|localtime|time(DATETIME_FORMAT) }}</span><br>
|
||||||
{{ n }}</a>
|
{{ n }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<h3>{% trans %}Page list{% endtrans %}</h3>
|
<h3>{% trans %}Page list{% endtrans %}</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{% for p in page_list %}
|
{% for p in page_list %}
|
||||||
<li><a href="{{ url('core:page', page_name=p.get_full_name()) }}">{{ p.get_display_name() }}</a></li>
|
<li><a href="{{ p.get_absolute_url() }}">{{ p.get_display_name() }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -4,10 +4,12 @@
|
|||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script>
|
<script>
|
||||||
function make_preview() {
|
function make_preview() {
|
||||||
|
text = $("#id_content").val();
|
||||||
|
console.log("Rendering text: " + text);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ url('api:api_markdown') }}",
|
url: "{{ url('api:api_markdown') }}",
|
||||||
method: "GET",
|
method: "POST",
|
||||||
data: { text: $("#id_content").val() }
|
data: { text: text, csrfmiddlewaretoken: "{{ csrf_token }}"}
|
||||||
}).done(function (msg) {
|
}).done(function (msg) {
|
||||||
$("#preview").html(msg);
|
$("#preview").html(msg);
|
||||||
});
|
});
|
||||||
@ -23,6 +25,7 @@ function make_preview() {
|
|||||||
<p><input type="button" value="{% trans %}Preview{% endtrans %}" onclick="javascript:make_preview();" /></p>
|
<p><input type="button" value="{% trans %}Preview{% endtrans %}" onclick="javascript:make_preview();" /></p>
|
||||||
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
||||||
</form>
|
</form>
|
||||||
|
<a href="{{ url('core:page_delete', page_id=page.id)}}">{% trans %}Delete{% endtrans %}</a>
|
||||||
<div id="preview">
|
<div id="preview">
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
{% if user.memberships.filter(end_date=None).exists() or user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user == profile %}
|
{% if user.memberships.filter(end_date=None).exists() or user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user == profile %}
|
||||||
{# if the user is member of a club, he can view the subscription state #}
|
{# if the user is member of a club, he can view the subscription state #}
|
||||||
<p>
|
<p>
|
||||||
{% if profile.is_subscribed() %}
|
{% if profile.is_subscribed %}
|
||||||
{% if user == profile or user.is_root or user.is_board_member %}
|
{% if user == profile or user.is_root or user.is_board_member %}
|
||||||
{{ user_subscription(profile) }}
|
{{ user_subscription(profile) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -5,27 +5,19 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% set album = None %}
|
{% set picture_qs = profile.pictures.exclude(picture=None).order_by('-picture__parent__id', 'id').select_related('picture__parent__parent__name') %}
|
||||||
{% set new_album = True %}
|
{% for a in picture_qs.distinct('picture__parent') %}
|
||||||
{% for r in profile.pictures.exclude(picture=None).order_by('-picture__parent__id', 'id') -%}
|
|
||||||
{%- if album != r.picture.parent %}
|
|
||||||
{%- if album %}
|
|
||||||
</div>
|
|
||||||
{% endif -%}
|
|
||||||
{% set new_album = True %}
|
|
||||||
{% set album = r.picture.parent %}
|
|
||||||
<div style="padding: 10px">
|
<div style="padding: 10px">
|
||||||
<h4>{{ album.name }}</h4>
|
<h4>{{ a.picture.parent.name }}</h4>
|
||||||
<hr>
|
<hr>
|
||||||
{% else %}
|
{% for r in picture_qs.filter(picture__parent=a.picture.parent) -%}
|
||||||
{% set new_album = False %}
|
|
||||||
{%- endif %}
|
|
||||||
<div class="picture">
|
<div class="picture">
|
||||||
<a href="{{ url("sas:picture", picture_id=r.picture.id) }}#pict">
|
<a href="{{ url("sas:picture", picture_id=r.picture.id) }}#pict">
|
||||||
<img src="{{ r.picture.get_download_thumb_url() }}" alt="{{ r.picture.get_display_name() }}" style="max-width: 100%"/>
|
<img src="{{ r.picture.get_download_thumb_url() }}" alt="{{ r.picture.get_display_name() }}" style="max-width: 100%"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{%- endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
{% endfor %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -75,6 +75,10 @@
|
|||||||
<h4>{% trans %}Communication{% endtrans %}</h4>
|
<h4>{% trans %}Communication{% endtrans %}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
{% if user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) or user.is_root %}
|
{% if user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) or user.is_root %}
|
||||||
|
<li><a href="{{ url('com:weekmail_article') }}">{% trans %}Create weekmail article{% endtrans %}</a></li>
|
||||||
|
<li><a href="{{ url('com:weekmail') }}">{% trans %}Weekmail{% endtrans %}</a></li>
|
||||||
|
<li><a href="{{ url('com:weekmail_destinations') }}">{% trans %}Weekmail destinations{% endtrans %}</a></li>
|
||||||
|
<li><a href="{{ url('com:news_new') }}">{% trans %}Create news{% endtrans %}</a></li>
|
||||||
<li><a href="{{ url('com:news_admin_list') }}">{% trans %}Moderate news{% endtrans %}</a></li>
|
<li><a href="{{ url('com:news_admin_list') }}">{% trans %}Moderate news{% endtrans %}</a></li>
|
||||||
<li><a href="{{ url('com:index_edit') }}">{% trans %}Edit index page{% endtrans %}</a></li>
|
<li><a href="{{ url('com:index_edit') }}">{% trans %}Edit index page{% endtrans %}</a></li>
|
||||||
<li><a href="{{ url('com:alert_edit') }}">{% trans %}Edit alert message{% endtrans %}</a></li>
|
<li><a href="{{ url('com:alert_edit') }}">{% trans %}Edit alert message{% endtrans %}</a></li>
|
||||||
@ -98,7 +102,7 @@
|
|||||||
<h4>{% trans %}Elections{% endtrans %}</h4>
|
<h4>{% trans %}Elections{% endtrans %}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="{{ url('election:list') }}">{% trans %}See available elections{% endtrans %}</a></li>
|
<li><a href="{{ url('election:list') }}">{% trans %}See available elections{% endtrans %}</a></li>
|
||||||
{%- if user.is_subscribed() -%}
|
{%- if user.is_subscribed -%}
|
||||||
<li><a href="{{ url('election:create') }}">{% trans %}Create a new election{% endtrans %}</a></li>
|
<li><a href="{{ url('election:create') }}">{% trans %}Create a new election{% endtrans %}</a></li>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django import template
|
from django import template
|
||||||
from django.template.defaultfilters import stringfilter
|
from django.template.defaultfilters import stringfilter
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
@ -10,7 +34,7 @@ register = template.Library()
|
|||||||
@register.filter(is_safe=False)
|
@register.filter(is_safe=False)
|
||||||
@stringfilter
|
@stringfilter
|
||||||
def markdown(text):
|
def markdown(text):
|
||||||
return mark_safe(md(escape(text)))
|
return mark_safe(md(text))
|
||||||
|
|
||||||
@register.filter()
|
@register.filter()
|
||||||
@stringfilter
|
@stringfilter
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.test import Client, TestCase
|
from django.test import Client, TestCase
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
@ -253,8 +277,8 @@ http://git.an
|
|||||||
response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy'}))
|
response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy'}))
|
||||||
self.assertTrue(response.status_code == 200)
|
self.assertTrue(response.status_code == 200)
|
||||||
self.assertTrue('<p>Guy <em>bibou</em></p>\\n<p><a href="http://git.an">http://git.an</a></p>\\n' +
|
self.assertTrue('<p>Guy <em>bibou</em></p>\\n<p><a href="http://git.an">http://git.an</a></p>\\n' +
|
||||||
'<h1>Swag</h1>\\n<p><guy>Bibou</guy></p>\\n' +
|
'<h1>Swag</h1>\\n<guy>Bibou</guy>' +
|
||||||
'<p><script>alert('Guy');</script></p>' in str(response.content))
|
"<script>alert(\\'Guy\\');</script>" in str(response.content))
|
||||||
|
|
||||||
#TODO: many tests on the pages:
|
#TODO: many tests on the pages:
|
||||||
# - renaming a page
|
# - renaming a page
|
||||||
|
26
core/urls.py
26
core/urls.py
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
|
|
||||||
from core.views import *
|
from core.views import *
|
||||||
@ -40,6 +64,7 @@ urlpatterns = [
|
|||||||
url(r'^user/(?P<user_id>[0-9]+)/edit$', UserUpdateProfileView.as_view(), name='user_edit'),
|
url(r'^user/(?P<user_id>[0-9]+)/edit$', UserUpdateProfileView.as_view(), name='user_edit'),
|
||||||
url(r'^user/(?P<user_id>[0-9]+)/profile_upload$', UserUploadProfilePictView.as_view(), name='user_profile_upload'),
|
url(r'^user/(?P<user_id>[0-9]+)/profile_upload$', UserUploadProfilePictView.as_view(), name='user_profile_upload'),
|
||||||
url(r'^user/(?P<user_id>[0-9]+)/clubs$', UserClubView.as_view(), name='user_clubs'),
|
url(r'^user/(?P<user_id>[0-9]+)/clubs$', UserClubView.as_view(), name='user_clubs'),
|
||||||
|
url(r'^user/(?P<user_id>[0-9]+)/prefs$', UserPreferencesView.as_view(), name='user_prefs'),
|
||||||
url(r'^user/(?P<user_id>[0-9]+)/groups$', UserUpdateGroupView.as_view(), name='user_groups'),
|
url(r'^user/(?P<user_id>[0-9]+)/groups$', UserUpdateGroupView.as_view(), name='user_groups'),
|
||||||
url(r'^user/tools/$', UserToolsView.as_view(), name='user_tools'),
|
url(r'^user/tools/$', UserToolsView.as_view(), name='user_tools'),
|
||||||
url(r'^user/(?P<user_id>[0-9]+)/account$', UserAccountView.as_view(), name='user_account'),
|
url(r'^user/(?P<user_id>[0-9]+)/account$', UserAccountView.as_view(), name='user_account'),
|
||||||
@ -60,6 +85,7 @@ urlpatterns = [
|
|||||||
# Page views
|
# Page views
|
||||||
url(r'^page/$', PageListView.as_view(), name='page_list'),
|
url(r'^page/$', PageListView.as_view(), name='page_list'),
|
||||||
url(r'^page/create$', PageCreateView.as_view(), name='page_new'),
|
url(r'^page/create$', PageCreateView.as_view(), name='page_new'),
|
||||||
|
url(r'^page/(?P<page_id>[0-9]*)/delete$', PageDeleteView.as_view(), name='page_delete'),
|
||||||
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/edit$', PageEditView.as_view(), name='page_edit'),
|
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/edit$', PageEditView.as_view(), name='page_edit'),
|
||||||
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/prop$', PagePropView.as_view(), name='page_prop'),
|
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/prop$', PagePropView.as_view(), name='page_prop'),
|
||||||
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/hist$', PageHistView.as_view(), name='page_hist'),
|
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/hist$', PageHistView.as_view(), name='page_hist'),
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
# Image utils
|
# Image utils
|
||||||
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
@ -1,9 +1,34 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
import types
|
import types
|
||||||
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.http import HttpResponseForbidden, HttpResponseNotFound
|
from django.http import HttpResponseForbidden, HttpResponseNotFound
|
||||||
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist, ImproperlyConfigured
|
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist, ImproperlyConfigured
|
||||||
from django.views.generic.base import View
|
from django.views.generic.base import View
|
||||||
|
from django.db.models import Count
|
||||||
|
|
||||||
from core.models import Group
|
from core.models import Group
|
||||||
from core.views.forms import LoginForm
|
from core.views.forms import LoginForm
|
||||||
@ -66,7 +91,7 @@ class CanEditPropMixin(View):
|
|||||||
except: pass
|
except: pass
|
||||||
# If we get here, it's a ListView
|
# If we get here, it's a ListView
|
||||||
l_id = [o.id for o in self.get_queryset() if can_edit_prop(o, request.user)]
|
l_id = [o.id for o in self.get_queryset() if can_edit_prop(o, request.user)]
|
||||||
if not l_id:
|
if not l_id and self.get_queryset().count() != 0:
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
self._get_queryset = self.get_queryset
|
self._get_queryset = self.get_queryset
|
||||||
def get_qs(self2):
|
def get_qs(self2):
|
||||||
@ -88,7 +113,7 @@ class CanEditMixin(View):
|
|||||||
except: pass
|
except: pass
|
||||||
# If we get here, it's a ListView
|
# If we get here, it's a ListView
|
||||||
l_id = [o.id for o in self.get_queryset() if can_edit(o, request.user)]
|
l_id = [o.id for o in self.get_queryset() if can_edit(o, request.user)]
|
||||||
if not l_id:
|
if not l_id and self.get_queryset().count() != 0:
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
self._get_queryset = self.get_queryset
|
self._get_queryset = self.get_queryset
|
||||||
def get_qs(self2):
|
def get_qs(self2):
|
||||||
@ -110,7 +135,7 @@ class CanViewMixin(View):
|
|||||||
except: pass
|
except: pass
|
||||||
# If we get here, it's a ListView
|
# If we get here, it's a ListView
|
||||||
l_id = [o.id for o in self.get_queryset() if can_view(o, request.user)]
|
l_id = [o.id for o in self.get_queryset() if can_view(o, request.user)]
|
||||||
if not l_id:
|
if not l_id and self.get_queryset().count() != 0:
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
self._get_queryset = self.get_queryset
|
self._get_queryset = self.get_queryset
|
||||||
def get_qs(self2):
|
def get_qs(self2):
|
||||||
@ -147,6 +172,36 @@ class TabedViewMixin(View):
|
|||||||
kwargs['list_of_tabs'] = self.get_list_of_tabs()
|
kwargs['list_of_tabs'] = self.get_list_of_tabs()
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
class QuickNotifMixin:
|
||||||
|
quick_notif_list = []
|
||||||
|
|
||||||
|
def dispatch(self, request, *arg, **kwargs):
|
||||||
|
self.quick_notif_list = [] # In some cases, the class can stay instanciated, so we need to reset the list
|
||||||
|
return super(QuickNotifMixin, self).dispatch(request, *arg, **kwargs)
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
ret = super(QuickNotifMixin, self).get_success_url()
|
||||||
|
try:
|
||||||
|
if '?' in ret:
|
||||||
|
ret += '&' + self.quick_notif_url_arg
|
||||||
|
else:
|
||||||
|
ret += '?' + self.quick_notif_url_arg
|
||||||
|
except: pass
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
"""Add quick notifications to context"""
|
||||||
|
kwargs = super(QuickNotifMixin, self).get_context_data(**kwargs)
|
||||||
|
kwargs['quick_notifs'] = []
|
||||||
|
for n in self.quick_notif_list:
|
||||||
|
kwargs['quick_notifs'].append(settings.SITH_QUICK_NOTIF[n])
|
||||||
|
for k,v in settings.SITH_QUICK_NOTIF.items():
|
||||||
|
for gk in self.request.GET.keys():
|
||||||
|
if k == gk:
|
||||||
|
kwargs['quick_notifs'].append(v)
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
from .user import *
|
from .user import *
|
||||||
from .page import *
|
from .page import *
|
||||||
from .files import *
|
from .files import *
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
# This file contains all the views that concern the page model
|
# This file contains all the views that concern the page model
|
||||||
from django.shortcuts import render, redirect, get_object_or_404
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
from django.views.generic import ListView, DetailView, TemplateView
|
from django.views.generic import ListView, DetailView, TemplateView
|
||||||
@ -7,7 +31,7 @@ from django.contrib.auth.decorators import login_required, permission_required
|
|||||||
from django.forms.models import modelform_factory
|
from django.forms.models import modelform_factory
|
||||||
from django.forms import CheckboxSelectMultiple
|
from django.forms import CheckboxSelectMultiple
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.core.servers.basehttp import FileWrapper
|
from django.core.servers.basehttp import FileWrapper
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
@ -38,10 +62,11 @@ def send_file(request, file_id, file_class=SithFile, file_attr="file"):
|
|||||||
):
|
):
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
name = f.__getattribute__(file_attr).name
|
name = f.__getattribute__(file_attr).name
|
||||||
with open((settings.MEDIA_ROOT + name).encode('utf-8'), 'rb') as filename:
|
filepath = os.path.join(settings.MEDIA_ROOT, name)
|
||||||
|
with open(filepath.encode('utf-8'), 'rb') as filename:
|
||||||
wrapper = FileWrapper(filename)
|
wrapper = FileWrapper(filename)
|
||||||
response = HttpResponse(wrapper, content_type=f.mime_type)
|
response = HttpResponse(wrapper, content_type=f.mime_type)
|
||||||
response['Content-Length'] = os.path.getsize((settings.MEDIA_ROOT + name).encode('utf-8'))
|
response['Content-Length'] = os.path.getsize(filepath.encode('utf-8'))
|
||||||
response['Content-Disposition'] = ('inline; filename="%s"' % f.name).encode('utf-8')
|
response['Content-Disposition'] = ('inline; filename="%s"' % f.name).encode('utf-8')
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@ -118,9 +143,9 @@ class FileEditPropForm(forms.ModelForm):
|
|||||||
model = SithFile
|
model = SithFile
|
||||||
fields = ['parent', 'owner', 'edit_groups', 'view_groups']
|
fields = ['parent', 'owner', 'edit_groups', 'view_groups']
|
||||||
parent = make_ajax_field(SithFile, 'parent', 'files', help_text="")
|
parent = make_ajax_field(SithFile, 'parent', 'files', help_text="")
|
||||||
edit_groups = make_ajax_field(SithFile, 'edit_groups', 'groups', help_text="")
|
edit_groups = make_ajax_field(SithFile, 'edit_groups', 'groups', help_text="", label=_("edit group"))
|
||||||
view_groups = make_ajax_field(SithFile, 'view_groups', 'groups', help_text="")
|
view_groups = make_ajax_field(SithFile, 'view_groups', 'groups', help_text="", label=_("view group"))
|
||||||
|
recursive = forms.BooleanField(label=_("Apply rights recursively"), required=False)
|
||||||
|
|
||||||
class FileEditPropView(CanEditPropMixin, UpdateView):
|
class FileEditPropView(CanEditPropMixin, UpdateView):
|
||||||
model = SithFile
|
model = SithFile
|
||||||
@ -134,6 +159,12 @@ class FileEditPropView(CanEditPropMixin, UpdateView):
|
|||||||
form.fields['parent'].queryset = SithFile.objects.filter(is_folder=True)
|
form.fields['parent'].queryset = SithFile.objects.filter(is_folder=True)
|
||||||
return form
|
return form
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
ret = super(FileEditPropView, self).form_valid(form)
|
||||||
|
if form.cleaned_data['recursive']:
|
||||||
|
self.object.apply_rights_recursively()
|
||||||
|
return ret
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse('core:file_detail', kwargs={'file_id': self.object.id, 'popup': self.kwargs['popup'] or ""})
|
return reverse('core:file_detail', kwargs={'file_id': self.object.id, 'popup': self.kwargs['popup'] or ""})
|
||||||
|
|
||||||
|
@ -1,10 +1,35 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, UserChangeForm
|
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, UserChangeForm
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.contrib.auth import logout, login, authenticate
|
from django.contrib.auth import logout, login, authenticate
|
||||||
from django.forms import CheckboxSelectMultiple, Select, DateInput, TextInput, DateTimeInput
|
from django.forms import CheckboxSelectMultiple, Select, DateInput, TextInput, DateTimeInput
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from django.utils.translation import ugettext
|
||||||
from phonenumber_field.widgets import PhoneNumberInternationalFallbackWidget
|
from phonenumber_field.widgets import PhoneNumberInternationalFallbackWidget
|
||||||
from ajax_select.fields import AutoCompleteSelectField
|
from ajax_select.fields import AutoCompleteSelectField
|
||||||
|
|
||||||
@ -59,7 +84,7 @@ class SelectFile(TextInput):
|
|||||||
'title': _("Choose file"),
|
'title': _("Choose file"),
|
||||||
'name': name,
|
'name': name,
|
||||||
}
|
}
|
||||||
output += '<span name="' + name + '" class="choose_file_button">' + _("Choose file") + '</span>'
|
output += '<span name="' + name + '" class="choose_file_button">' + ugettext("Choose file") + '</span>'
|
||||||
return output
|
return output
|
||||||
|
|
||||||
class SelectUser(TextInput):
|
class SelectUser(TextInput):
|
||||||
@ -73,7 +98,7 @@ class SelectUser(TextInput):
|
|||||||
'title': _("Choose user"),
|
'title': _("Choose user"),
|
||||||
'name': name,
|
'name': name,
|
||||||
}
|
}
|
||||||
output += '<span name="' + name + '" class="choose_user_button">' + _("Choose user") + '</span>'
|
output += '<span name="' + name + '" class="choose_user_button">' + ugettext("Choose user") + '</span>'
|
||||||
return output
|
return output
|
||||||
|
|
||||||
# Forms
|
# Forms
|
||||||
@ -167,7 +192,8 @@ class UserProfileForm(forms.ModelForm):
|
|||||||
im = Image.open(BytesIO(f.read()))
|
im = Image.open(BytesIO(f.read()))
|
||||||
new_file = SithFile(parent=parent, name=self.generate_name(field, f),
|
new_file = SithFile(parent=parent, name=self.generate_name(field, f),
|
||||||
file=resize_image(im, 400, f.content_type.split('/')[-1]),
|
file=resize_image(im, 400, f.content_type.split('/')[-1]),
|
||||||
owner=self.instance, is_folder=False, mime_type=f.content_type, size=f._size)
|
owner=self.instance, is_folder=False, mime_type=f.content_type, size=f._size,
|
||||||
|
moderator=self.instance, is_moderated=True)
|
||||||
new_file.file.name = new_file.name
|
new_file.file.name = new_file.name
|
||||||
old = SithFile.objects.filter(parent=parent, name=new_file.name).first()
|
old = SithFile.objects.filter(parent=parent, name=new_file.name).first()
|
||||||
if old:
|
if old:
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView
|
from django.views.generic.edit import UpdateView, CreateView, DeleteView
|
||||||
from django.views.generic import ListView
|
from django.views.generic import ListView
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.core.urlresolvers import reverse_lazy
|
||||||
|
@ -1,7 +1,32 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
# This file contains all the views that concern the page model
|
# This file contains all the views that concern the page model
|
||||||
from django.shortcuts import render, redirect, get_object_or_404
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
|
from django.core.urlresolvers import reverse_lazy
|
||||||
from django.views.generic import ListView, DetailView
|
from django.views.generic import ListView, DetailView
|
||||||
from django.views.generic.edit import UpdateView, CreateView
|
from django.views.generic.edit import UpdateView, CreateView, DeleteView
|
||||||
from django.contrib.auth.decorators import login_required, permission_required
|
from django.contrib.auth.decorators import login_required, permission_required
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.forms.models import modelform_factory
|
from django.forms.models import modelform_factory
|
||||||
@ -159,3 +184,11 @@ class PageEditView(CanEditMixin, UpdateView):
|
|||||||
form.instance = new_rev
|
form.instance = new_rev
|
||||||
return super(PageEditView, self).form_valid(form)
|
return super(PageEditView, self).form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
|
class PageDeleteView(CanEditPropMixin, DeleteView):
|
||||||
|
model = Page
|
||||||
|
template_name = 'core/delete_confirm.jinja'
|
||||||
|
pk_url_kwarg = 'page_id'
|
||||||
|
|
||||||
|
def get_success_url(self, **kwargs):
|
||||||
|
return reverse_lazy('core:page_list')
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.shortcuts import render, redirect, get_object_or_404
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
# This file contains all the views that concern the user model
|
# This file contains all the views that concern the user model
|
||||||
from django.shortcuts import render, redirect, get_object_or_404
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
from django.contrib.auth import logout as auth_logout, views
|
from django.contrib.auth import logout as auth_logout, views
|
||||||
@ -17,9 +41,9 @@ from django.utils import timezone
|
|||||||
from datetime import timedelta, datetime, date
|
from datetime import timedelta, datetime, date
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin
|
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin, QuickNotifMixin
|
||||||
from core.views.forms import RegisteringForm, UserPropForm, UserProfileForm, LoginForm, UserGodfathersForm
|
from core.views.forms import RegisteringForm, UserPropForm, UserProfileForm, LoginForm, UserGodfathersForm
|
||||||
from core.models import User, SithFile
|
from core.models import User, SithFile, Preferences
|
||||||
from club.models import Club
|
from club.models import Club
|
||||||
from subscription.models import Subscription
|
from subscription.models import Subscription
|
||||||
|
|
||||||
@ -151,6 +175,11 @@ class UserTabsMixin(TabedViewMixin):
|
|||||||
'slug': 'edit',
|
'slug': 'edit',
|
||||||
'name': _("Edit"),
|
'name': _("Edit"),
|
||||||
})
|
})
|
||||||
|
tab_list.append({
|
||||||
|
'url': reverse('core:user_prefs', kwargs={'user_id': self.object.id}),
|
||||||
|
'slug': 'prefs',
|
||||||
|
'name': _("Preferences"),
|
||||||
|
})
|
||||||
if self.request.user.can_view(self.object):
|
if self.request.user.can_view(self.object):
|
||||||
tab_list.append({
|
tab_list.append({
|
||||||
'url': reverse('core:user_clubs', kwargs={'user_id': self.object.id}),
|
'url': reverse('core:user_clubs', kwargs={'user_id': self.object.id}),
|
||||||
@ -257,6 +286,20 @@ class UserStatsView(UserTabsMixin, CanViewMixin, DetailView):
|
|||||||
template_name = "core/user_stats.jinja"
|
template_name = "core/user_stats.jinja"
|
||||||
current_tab = 'stats'
|
current_tab = 'stats'
|
||||||
|
|
||||||
|
def dispatch(self, request, *arg, **kwargs):
|
||||||
|
profile = self.get_object()
|
||||||
|
|
||||||
|
if not hasattr(profile, "customer"):
|
||||||
|
raise Http404
|
||||||
|
|
||||||
|
if not (profile == request.user
|
||||||
|
or request.user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID)
|
||||||
|
or request.user.is_in_group(settings.SITH_BAR_MANAGER['unix_name']+settings.SITH_BOARD_SUFFIX)
|
||||||
|
or request.user.is_root):
|
||||||
|
raise PermissionDenied
|
||||||
|
|
||||||
|
return super(UserStatsView, self).dispatch(request, *arg, **kwargs)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs = super(UserStatsView, self).get_context_data(**kwargs)
|
kwargs = super(UserStatsView, self).get_context_data(**kwargs)
|
||||||
from counter.models import Counter, Product, Selling
|
from counter.models import Counter, Product, Selling
|
||||||
@ -378,6 +421,31 @@ class UserClubView(UserTabsMixin, CanViewMixin, DetailView):
|
|||||||
template_name = "core/user_clubs.jinja"
|
template_name = "core/user_clubs.jinja"
|
||||||
current_tab = "clubs"
|
current_tab = "clubs"
|
||||||
|
|
||||||
|
class UserPreferencesView(UserTabsMixin, CanEditMixin, UpdateView):
|
||||||
|
"""
|
||||||
|
Edit a user's preferences
|
||||||
|
"""
|
||||||
|
model = User
|
||||||
|
pk_url_kwarg = "user_id"
|
||||||
|
template_name = "core/edit.jinja"
|
||||||
|
form_class = modelform_factory(Preferences, fields=['receive_weekmail'])
|
||||||
|
context_object_name = "profile"
|
||||||
|
current_tab = "prefs"
|
||||||
|
|
||||||
|
def get_object(self, queryset=None):
|
||||||
|
user = get_object_or_404(User, pk=self.kwargs['user_id'])
|
||||||
|
return user
|
||||||
|
|
||||||
|
def get_form_kwargs(self):
|
||||||
|
kwargs = super(UserPreferencesView, self).get_form_kwargs()
|
||||||
|
try:
|
||||||
|
pref = self.object.preferences
|
||||||
|
except:
|
||||||
|
pref = Preferences(user=self.object)
|
||||||
|
pref.save()
|
||||||
|
kwargs.update({'instance': pref})
|
||||||
|
return kwargs
|
||||||
|
|
||||||
class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView):
|
class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView):
|
||||||
"""
|
"""
|
||||||
Edit a user's groups
|
Edit a user's groups
|
||||||
@ -390,7 +458,7 @@ class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView):
|
|||||||
context_object_name = "profile"
|
context_object_name = "profile"
|
||||||
current_tab = "groups"
|
current_tab = "groups"
|
||||||
|
|
||||||
class UserToolsView(UserTabsMixin, TemplateView):
|
class UserToolsView(QuickNotifMixin, UserTabsMixin, TemplateView):
|
||||||
"""
|
"""
|
||||||
Displays the logged user's tools
|
Displays the logged user's tools
|
||||||
"""
|
"""
|
||||||
@ -472,8 +540,8 @@ class UserAccountView(UserAccountBase):
|
|||||||
(lambda q: q.amount)
|
(lambda q: q.amount)
|
||||||
)
|
)
|
||||||
kwargs['etickets'] = self.object.customer.buyings.exclude(product__eticket=None).all()
|
kwargs['etickets'] = self.object.customer.buyings.exclude(product__eticket=None).all()
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
print(repr(e))
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
class UserAccountDetailView(UserAccountBase, YearMixin, MonthMixin):
|
class UserAccountDetailView(UserAccountBase, YearMixin, MonthMixin):
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from counter.models import *
|
from counter.models import *
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.db import models, DataError
|
from django.db import models, DataError
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@ -6,7 +30,7 @@ from django.core.urlresolvers import reverse
|
|||||||
from django.forms import ValidationError
|
from django.forms import ValidationError
|
||||||
from django.contrib.sites.shortcuts import get_current_site
|
from django.contrib.sites.shortcuts import get_current_site
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta, date
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
import os
|
import os
|
||||||
@ -35,6 +59,11 @@ class Customer(models.Model):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s - %s" % (self.user.username, self.account_id)
|
return "%s - %s" % (self.user.username, self.account_id)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_buy(self):
|
||||||
|
return (self.user.subscriptions.last() and
|
||||||
|
(date.today() - self.user.subscriptions.last().subscription_end) < timedelta(days=90))
|
||||||
|
|
||||||
def generate_account_id(number):
|
def generate_account_id(number):
|
||||||
number = str(number)
|
number = str(number)
|
||||||
letter = random.choice(string.ascii_lowercase)
|
letter = random.choice(string.ascii_lowercase)
|
||||||
@ -347,7 +376,7 @@ class Selling(models.Model):
|
|||||||
self.customer.save()
|
self.customer.save()
|
||||||
self.is_validated = True
|
self.is_validated = True
|
||||||
u = User.objects.filter(id=self.customer.user.id).first()
|
u = User.objects.filter(id=self.customer.user.id).first()
|
||||||
if u.was_subscribed():
|
if u.was_subscribed:
|
||||||
if self.product and self.product.id == settings.SITH_PRODUCT_SUBSCRIPTION_ONE_SEMESTER:
|
if self.product and self.product.id == settings.SITH_PRODUCT_SUBSCRIPTION_ONE_SEMESTER:
|
||||||
sub = Subscription(
|
sub = Subscription(
|
||||||
member=u,
|
member=u,
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
<p><input type="submit" name="submit" value="{% trans %}Save{% endtrans %}" onclick="return confirm('{% trans %}Are you sure ?{% endtrans %}');return false;" /></p>
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for c in cashsummary_list.order_by('-date') %}
|
{% for c in cashsummary_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ user_profile_link(c.user) }}</td>
|
<td>{{ user_profile_link(c.user) }}</td>
|
||||||
<td>{{ c.counter }}</td>
|
<td>{{ c.counter }}</td>
|
||||||
@ -55,6 +55,26 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<br>
|
||||||
|
{% if is_paginated %}
|
||||||
|
{% if page_obj.has_previous() %}
|
||||||
|
<a href="?page={{ page_obj.previous_page_number() }}">{% trans %}Previous{% endtrans %}</a>
|
||||||
|
{% else %}
|
||||||
|
<span class="disabled">{% trans %}Previous{% endtrans %}</span>
|
||||||
|
{% endif %}
|
||||||
|
{% for i in paginator.page_range %}
|
||||||
|
{% if page_obj.number == i %}
|
||||||
|
<span class="active">{{ i }} <span class="sr-only">({% trans %}current{% endtrans %})</span></span>
|
||||||
|
{% else %}
|
||||||
|
<a href="?page={{ i }}">{{ i }}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% if page_obj.has_next() %}
|
||||||
|
<a href="?page={{ page_obj.next_page_number() }}">{% trans %}Next{% endtrans %}</a>
|
||||||
|
{% else %}
|
||||||
|
<span class="disabled">{% trans %}Next{% endtrans %}</span>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% trans %}There is no cash register summary in this website.{% endtrans %}
|
{% trans %}There is no cash register summary in this website.{% endtrans %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
<form method="post" action="{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}">
|
<form method="post" action="{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="action" value="code">
|
<input type="hidden" name="action" value="code">
|
||||||
<input type="input" name="code" value="" autofocus class="focus" id="code_field"/>
|
<input type="input" name="code" value="" class="focus" id="code_field"/>
|
||||||
<input type="submit" value="{% trans %}Go{% endtrans %}" />
|
<input type="submit" value="{% trans %}Go{% endtrans %}" />
|
||||||
</form>
|
</form>
|
||||||
<p>{% trans %}Basket: {% endtrans %}</p>
|
<p>{% trans %}Basket: {% endtrans %}</p>
|
||||||
@ -179,6 +179,7 @@ $( function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("#products").tabs();
|
$("#products").tabs();
|
||||||
|
$("#code_field").focus();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
</select>
|
</select>
|
||||||
<input type="submit" value="{% trans %}Go{% endtrans %}" />
|
<input type="submit" value="{% trans %}Go{% endtrans %}" />
|
||||||
</form>
|
</form>
|
||||||
|
<br>
|
||||||
|
<p>{% trans %}CB Payments{% endtrans %} : {{ sum_cb }} €</p>
|
||||||
|
<br>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<td>{% trans %}Club{% endtrans %}</td>
|
<td>{% trans %}Club{% endtrans %}</td>
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
# Create your tests here.
|
# Create your tests here.
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
|
|
||||||
from counter.views import *
|
from counter.views import *
|
||||||
|
196
counter/views.py
196
counter/views.py
@ -1,6 +1,32 @@
|
|||||||
from django.shortcuts import render
|
# -*- coding:utf-8 -*
|
||||||
|
#
|
||||||
|
# Copyright 2016,2017
|
||||||
|
# - Skia <skia@libskia.so>
|
||||||
|
#
|
||||||
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
|
# http://ae.utbm.fr.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License a 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, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||||
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
from django.shortcuts import render, get_object_or_404
|
||||||
|
from django.http import Http404
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.views.generic import ListView, DetailView, RedirectView, TemplateView
|
from django.views.generic import ListView, DetailView, RedirectView, TemplateView
|
||||||
|
from django.views.generic.base import View
|
||||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView, ProcessFormView, FormMixin
|
from django.views.generic.edit import UpdateView, CreateView, DeleteView, ProcessFormView, FormMixin
|
||||||
from django.forms.models import modelform_factory
|
from django.forms.models import modelform_factory
|
||||||
from django.forms import CheckboxSelectMultiple
|
from django.forms import CheckboxSelectMultiple
|
||||||
@ -27,6 +53,33 @@ from counter.models import Counter, Customer, Product, Selling, Refilling, Produ
|
|||||||
CashRegisterSummary, CashRegisterSummaryItem, Eticket, Permanency
|
CashRegisterSummary, CashRegisterSummaryItem, Eticket, Permanency
|
||||||
from accounting.models import CurrencyField
|
from accounting.models import CurrencyField
|
||||||
|
|
||||||
|
class CounterAdminMixin(View):
|
||||||
|
"""
|
||||||
|
This view is made to protect counter admin section
|
||||||
|
"""
|
||||||
|
edit_group = [settings.SITH_GROUP_COUNTER_ADMIN_ID]
|
||||||
|
edit_club = []
|
||||||
|
|
||||||
|
def _test_group(self, user):
|
||||||
|
for g in self.edit_group:
|
||||||
|
if user.is_in_group(g):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _test_club(self, user):
|
||||||
|
for c in self.edit_club:
|
||||||
|
if c.can_be_edited_by(user):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
res = super(CounterAdminMixin, self).dispatch(request, *args, **kwargs)
|
||||||
|
if not (request.user.is_root or self._test_group(request.user)
|
||||||
|
or self._test_club(request.user)):
|
||||||
|
raise PermissionDenied
|
||||||
|
return res
|
||||||
|
|
||||||
class GetUserForm(forms.Form):
|
class GetUserForm(forms.Form):
|
||||||
"""
|
"""
|
||||||
The Form class aims at providing a valid user_id field in its cleaned data, in order to pass it to some view,
|
The Form class aims at providing a valid user_id field in its cleaned data, in order to pass it to some view,
|
||||||
@ -49,9 +102,7 @@ class GetUserForm(forms.Form):
|
|||||||
cus = Customer.objects.filter(account_id__iexact=cleaned_data['code']).first()
|
cus = Customer.objects.filter(account_id__iexact=cleaned_data['code']).first()
|
||||||
elif cleaned_data['id'] is not None:
|
elif cleaned_data['id'] is not None:
|
||||||
cus = Customer.objects.filter(user=cleaned_data['id']).first()
|
cus = Customer.objects.filter(user=cleaned_data['id']).first()
|
||||||
sub = cus.user if cus is not None else None
|
if (cus is None or not cus.can_buy):
|
||||||
if (cus is None or sub is None or not sub.subscriptions.last() or
|
|
||||||
(date.today() - sub.subscriptions.last().subscription_end) > timedelta(days=90)):
|
|
||||||
raise forms.ValidationError(_("User not found"))
|
raise forms.ValidationError(_("User not found"))
|
||||||
cleaned_data['user_id'] = cus.user.id
|
cleaned_data['user_id'] = cus.user.id
|
||||||
cleaned_data['user'] = cus.user
|
cleaned_data['user'] = cus.user
|
||||||
@ -60,12 +111,10 @@ class GetUserForm(forms.Form):
|
|||||||
class RefillForm(forms.ModelForm):
|
class RefillForm(forms.ModelForm):
|
||||||
error_css_class = 'error'
|
error_css_class = 'error'
|
||||||
required_css_class = 'required'
|
required_css_class = 'required'
|
||||||
|
amount = forms.FloatField(min_value=0, widget=forms.NumberInput(attrs={'class':'focus'}))
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Refilling
|
model = Refilling
|
||||||
fields = ['amount', 'payment_method', 'bank']
|
fields = ['amount', 'payment_method', 'bank']
|
||||||
widgets = {
|
|
||||||
'amount': forms.NumberInput(attrs={'class':'focus'},)
|
|
||||||
}
|
|
||||||
|
|
||||||
class CounterTabsMixin(TabedViewMixin):
|
class CounterTabsMixin(TabedViewMixin):
|
||||||
def get_tabs_title(self):
|
def get_tabs_title(self):
|
||||||
@ -171,9 +220,22 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
|
|||||||
pk_url_kwarg = "counter_id"
|
pk_url_kwarg = "counter_id"
|
||||||
current_tab = "counter"
|
current_tab = "counter"
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
self.customer = get_object_or_404(Customer, user__id=self.kwargs['user_id'])
|
||||||
|
obj = self.get_object()
|
||||||
|
if not self.customer.can_buy:
|
||||||
|
raise Http404
|
||||||
|
if obj.type == "BAR":
|
||||||
|
if not ('counter_token' in request.session.keys() and
|
||||||
|
request.session['counter_token'] == obj.token) or len(obj.get_barmen_list())<1:
|
||||||
|
raise PermissionDenied
|
||||||
|
else:
|
||||||
|
if not request.user.is_authenticated():
|
||||||
|
raise PermissionDenied
|
||||||
|
return super(CounterClick, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
"""Simple get view"""
|
"""Simple get view"""
|
||||||
self.customer = Customer.objects.filter(user__id=self.kwargs['user_id']).first()
|
|
||||||
if 'basket' not in request.session.keys(): # Init the basket session entry
|
if 'basket' not in request.session.keys(): # Init the basket session entry
|
||||||
request.session['basket'] = {}
|
request.session['basket'] = {}
|
||||||
request.session['basket_total'] = 0
|
request.session['basket_total'] = 0
|
||||||
@ -192,7 +254,6 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
|
|||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
""" Handle the many possibilities of the post request """
|
""" Handle the many possibilities of the post request """
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
self.customer = Customer.objects.filter(user__id=self.kwargs['user_id']).first()
|
|
||||||
self.refill_form = None
|
self.refill_form = None
|
||||||
if ((self.object.type != "BAR" and not request.user.is_authenticated()) or
|
if ((self.object.type != "BAR" and not request.user.is_authenticated()) or
|
||||||
(self.object.type == "BAR" and
|
(self.object.type == "BAR" and
|
||||||
@ -287,7 +348,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
|
|||||||
total_qty_mod_6 = self.get_total_quantity_for_pid(request, pid) % 6
|
total_qty_mod_6 = self.get_total_quantity_for_pid(request, pid) % 6
|
||||||
bq = int((total_qty_mod_6 + q) / 6) # Integer division
|
bq = int((total_qty_mod_6 + q) / 6) # Integer division
|
||||||
q -= bq
|
q -= bq
|
||||||
if self.customer.amount < (total + q*float(price)): # Check for enough money
|
if self.customer.amount < (total + round(q*float(price),2)): # Check for enough money
|
||||||
request.session['not_enough'] = True
|
request.session['not_enough'] = True
|
||||||
return False
|
return False
|
||||||
if product.limit_age >= 18 and not self.customer.user.date_of_birth:
|
if product.limit_age >= 18 and not self.customer.user.date_of_birth:
|
||||||
@ -387,14 +448,17 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
|
|||||||
|
|
||||||
def refill(self, request):
|
def refill(self, request):
|
||||||
"""Refill the customer's account"""
|
"""Refill the customer's account"""
|
||||||
form = RefillForm(request.POST)
|
if self.get_object().type == 'BAR':
|
||||||
if form.is_valid():
|
form = RefillForm(request.POST)
|
||||||
form.instance.counter = self.object
|
if form.is_valid():
|
||||||
form.instance.operator = self.operator
|
form.instance.counter = self.object
|
||||||
form.instance.customer = self.customer
|
form.instance.operator = self.operator
|
||||||
form.instance.save()
|
form.instance.customer = self.customer
|
||||||
|
form.instance.save()
|
||||||
|
else:
|
||||||
|
self.refill_form = form
|
||||||
else:
|
else:
|
||||||
self.refill_form = form
|
raise PermissionDenied
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
""" Add customer to the context """
|
""" Add customer to the context """
|
||||||
@ -512,7 +576,7 @@ class CounterEditForm(forms.ModelForm):
|
|||||||
sellers = make_ajax_field(Counter, 'sellers', 'users', help_text="")
|
sellers = make_ajax_field(Counter, 'sellers', 'users', help_text="")
|
||||||
products = make_ajax_field(Counter, 'products', 'products', help_text="")
|
products = make_ajax_field(Counter, 'products', 'products', help_text="")
|
||||||
|
|
||||||
class CounterEditView(CounterAdminTabsMixin, CanEditMixin, UpdateView):
|
class CounterEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||||
"""
|
"""
|
||||||
Edit a counter's main informations (for the counter's manager)
|
Edit a counter's main informations (for the counter's manager)
|
||||||
"""
|
"""
|
||||||
@ -522,10 +586,15 @@ class CounterEditView(CounterAdminTabsMixin, CanEditMixin, UpdateView):
|
|||||||
template_name = 'core/edit.jinja'
|
template_name = 'core/edit.jinja'
|
||||||
current_tab = "counters"
|
current_tab = "counters"
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
obj = self.get_object()
|
||||||
|
self.edit_club.append(obj.club)
|
||||||
|
return super(CounterEditView, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse_lazy('counter:admin', kwargs={'counter_id': self.object.id})
|
return reverse_lazy('counter:admin', kwargs={'counter_id': self.object.id})
|
||||||
|
|
||||||
class CounterEditPropView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView):
|
class CounterEditPropView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||||
"""
|
"""
|
||||||
Edit a counter's main informations (for the counter's admin)
|
Edit a counter's main informations (for the counter's admin)
|
||||||
"""
|
"""
|
||||||
@ -535,7 +604,7 @@ class CounterEditPropView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView):
|
|||||||
template_name = 'core/edit.jinja'
|
template_name = 'core/edit.jinja'
|
||||||
current_tab = "counters"
|
current_tab = "counters"
|
||||||
|
|
||||||
class CounterCreateView(CounterAdminTabsMixin, CanEditMixin, CreateView):
|
class CounterCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView):
|
||||||
"""
|
"""
|
||||||
Create a counter (for the admins)
|
Create a counter (for the admins)
|
||||||
"""
|
"""
|
||||||
@ -545,7 +614,7 @@ class CounterCreateView(CounterAdminTabsMixin, CanEditMixin, CreateView):
|
|||||||
template_name = 'core/create.jinja'
|
template_name = 'core/create.jinja'
|
||||||
current_tab = "counters"
|
current_tab = "counters"
|
||||||
|
|
||||||
class CounterDeleteView(CounterAdminTabsMixin, CanEditMixin, DeleteView):
|
class CounterDeleteView(CounterAdminTabsMixin, CounterAdminMixin, DeleteView):
|
||||||
"""
|
"""
|
||||||
Delete a counter (for the admins)
|
Delete a counter (for the admins)
|
||||||
"""
|
"""
|
||||||
@ -557,7 +626,7 @@ class CounterDeleteView(CounterAdminTabsMixin, CanEditMixin, DeleteView):
|
|||||||
|
|
||||||
# Product management
|
# Product management
|
||||||
|
|
||||||
class ProductTypeListView(CounterAdminTabsMixin, CanEditPropMixin, ListView):
|
class ProductTypeListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||||
"""
|
"""
|
||||||
A list view for the admins
|
A list view for the admins
|
||||||
"""
|
"""
|
||||||
@ -565,7 +634,7 @@ class ProductTypeListView(CounterAdminTabsMixin, CanEditPropMixin, ListView):
|
|||||||
template_name = 'counter/producttype_list.jinja'
|
template_name = 'counter/producttype_list.jinja'
|
||||||
current_tab = "product_types"
|
current_tab = "product_types"
|
||||||
|
|
||||||
class ProductTypeCreateView(CounterAdminTabsMixin, CanCreateMixin, CreateView):
|
class ProductTypeCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView):
|
||||||
"""
|
"""
|
||||||
A create view for the admins
|
A create view for the admins
|
||||||
"""
|
"""
|
||||||
@ -574,7 +643,7 @@ class ProductTypeCreateView(CounterAdminTabsMixin, CanCreateMixin, CreateView):
|
|||||||
template_name = 'core/create.jinja'
|
template_name = 'core/create.jinja'
|
||||||
current_tab = "products"
|
current_tab = "products"
|
||||||
|
|
||||||
class ProductTypeEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView):
|
class ProductTypeEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||||
"""
|
"""
|
||||||
An edit view for the admins
|
An edit view for the admins
|
||||||
"""
|
"""
|
||||||
@ -584,7 +653,7 @@ class ProductTypeEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView):
|
|||||||
pk_url_kwarg = "type_id"
|
pk_url_kwarg = "type_id"
|
||||||
current_tab = "products"
|
current_tab = "products"
|
||||||
|
|
||||||
class ProductArchivedListView(CounterAdminTabsMixin, CanEditPropMixin, ListView):
|
class ProductArchivedListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||||
"""
|
"""
|
||||||
A list view for the admins
|
A list view for the admins
|
||||||
"""
|
"""
|
||||||
@ -594,7 +663,7 @@ class ProductArchivedListView(CounterAdminTabsMixin, CanEditPropMixin, ListView)
|
|||||||
ordering = ['name']
|
ordering = ['name']
|
||||||
current_tab = "archive"
|
current_tab = "archive"
|
||||||
|
|
||||||
class ProductListView(CounterAdminTabsMixin, CanEditPropMixin, ListView):
|
class ProductListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||||
"""
|
"""
|
||||||
A list view for the admins
|
A list view for the admins
|
||||||
"""
|
"""
|
||||||
@ -632,7 +701,7 @@ class ProductEditForm(forms.ModelForm):
|
|||||||
c.save()
|
c.save()
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
class ProductCreateView(CounterAdminTabsMixin, CanCreateMixin, CreateView):
|
class ProductCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView):
|
||||||
"""
|
"""
|
||||||
A create view for the admins
|
A create view for the admins
|
||||||
"""
|
"""
|
||||||
@ -641,7 +710,7 @@ class ProductCreateView(CounterAdminTabsMixin, CanCreateMixin, CreateView):
|
|||||||
template_name = 'core/create.jinja'
|
template_name = 'core/create.jinja'
|
||||||
current_tab = "products"
|
current_tab = "products"
|
||||||
|
|
||||||
class ProductEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView):
|
class ProductEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||||
"""
|
"""
|
||||||
An edit view for the admins
|
An edit view for the admins
|
||||||
"""
|
"""
|
||||||
@ -705,26 +774,26 @@ class CashRegisterSummaryForm(forms.Form):
|
|||||||
"""
|
"""
|
||||||
Provide the cash summary form
|
Provide the cash summary form
|
||||||
"""
|
"""
|
||||||
ten_cents = forms.IntegerField(label=_("10 cents"), required=False)
|
ten_cents = forms.IntegerField(label=_("10 cents"), required=False, min_value=0)
|
||||||
twenty_cents = forms.IntegerField(label=_("20 cents"), required=False)
|
twenty_cents = forms.IntegerField(label=_("20 cents"), required=False, min_value=0)
|
||||||
fifty_cents = forms.IntegerField(label=_("50 cents"), required=False)
|
fifty_cents = forms.IntegerField(label=_("50 cents"), required=False, min_value=0)
|
||||||
one_euro = forms.IntegerField(label=_("1 euro"), required=False)
|
one_euro = forms.IntegerField(label=_("1 euro"), required=False, min_value=0)
|
||||||
two_euros = forms.IntegerField(label=_("2 euros"), required=False)
|
two_euros = forms.IntegerField(label=_("2 euros"), required=False, min_value=0)
|
||||||
five_euros = forms.IntegerField(label=_("5 euros"), required=False)
|
five_euros = forms.IntegerField(label=_("5 euros"), required=False, min_value=0)
|
||||||
ten_euros = forms.IntegerField(label=_("10 euros"), required=False)
|
ten_euros = forms.IntegerField(label=_("10 euros"), required=False, min_value=0)
|
||||||
twenty_euros = forms.IntegerField(label=_("20 euros"), required=False)
|
twenty_euros = forms.IntegerField(label=_("20 euros"), required=False, min_value=0)
|
||||||
fifty_euros = forms.IntegerField(label=_("50 euros"), required=False)
|
fifty_euros = forms.IntegerField(label=_("50 euros"), required=False, min_value=0)
|
||||||
hundred_euros = forms.IntegerField(label=_("100 euros"), required=False)
|
hundred_euros = forms.IntegerField(label=_("100 euros"), required=False, min_value=0)
|
||||||
check_1_value = forms.DecimalField(label=_("Check amount"), required=False)
|
check_1_value = forms.DecimalField(label=_("Check amount"), required=False, min_value=0)
|
||||||
check_1_quantity = forms.IntegerField(label=_("Check quantity"), required=False)
|
check_1_quantity = forms.IntegerField(label=_("Check quantity"), required=False, min_value=0)
|
||||||
check_2_value = forms.DecimalField(label=_("Check amount"), required=False)
|
check_2_value = forms.DecimalField(label=_("Check amount"), required=False, min_value=0)
|
||||||
check_2_quantity = forms.IntegerField(label=_("Check quantity"), required=False)
|
check_2_quantity = forms.IntegerField(label=_("Check quantity"), required=False, min_value=0)
|
||||||
check_3_value = forms.DecimalField(label=_("Check amount"), required=False)
|
check_3_value = forms.DecimalField(label=_("Check amount"), required=False, min_value=0)
|
||||||
check_3_quantity = forms.IntegerField(label=_("Check quantity"), required=False)
|
check_3_quantity = forms.IntegerField(label=_("Check quantity"), required=False, min_value=0)
|
||||||
check_4_value = forms.DecimalField(label=_("Check amount"), required=False)
|
check_4_value = forms.DecimalField(label=_("Check amount"), required=False, min_value=0)
|
||||||
check_4_quantity = forms.IntegerField(label=_("Check quantity"), required=False)
|
check_4_quantity = forms.IntegerField(label=_("Check quantity"), required=False, min_value=0)
|
||||||
check_5_value = forms.DecimalField(label=_("Check amount"), required=False)
|
check_5_value = forms.DecimalField(label=_("Check amount"), required=False, min_value=0)
|
||||||
check_5_quantity = forms.IntegerField(label=_("Check quantity"), required=False)
|
check_5_quantity = forms.IntegerField(label=_("Check quantity"), required=False, min_value=0)
|
||||||
comment = forms.CharField(label=_("Comment"), required=False)
|
comment = forms.CharField(label=_("Comment"), required=False)
|
||||||
emptied = forms.BooleanField(label=_("Emptied"), required=False)
|
emptied = forms.BooleanField(label=_("Emptied"), required=False)
|
||||||
|
|
||||||
@ -817,8 +886,8 @@ class CounterLastOperationsView(CounterTabsMixin, CanViewMixin, DetailView):
|
|||||||
"""Add form to the context """
|
"""Add form to the context """
|
||||||
kwargs = super(CounterLastOperationsView, self).get_context_data(**kwargs)
|
kwargs = super(CounterLastOperationsView, self).get_context_data(**kwargs)
|
||||||
threshold = timezone.now() - timedelta(minutes=settings.SITH_LAST_OPERATIONS_LIMIT)
|
threshold = timezone.now() - timedelta(minutes=settings.SITH_LAST_OPERATIONS_LIMIT)
|
||||||
kwargs['last_refillings'] = self.object.refillings.filter(date__gte=threshold).all()
|
kwargs['last_refillings'] = self.object.refillings.filter(date__gte=threshold).order_by('-id')[:20]
|
||||||
kwargs['last_sellings'] = self.object.sellings.filter(date__gte=threshold).all()
|
kwargs['last_sellings'] = self.object.sellings.filter(date__gte=threshold).order_by('-id')[:20]
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
class CounterCashSummaryView(CounterTabsMixin, CanViewMixin, DetailView):
|
class CounterCashSummaryView(CounterTabsMixin, CanViewMixin, DetailView):
|
||||||
@ -871,7 +940,7 @@ class CounterActivityView(DetailView):
|
|||||||
pk_url_kwarg = "counter_id"
|
pk_url_kwarg = "counter_id"
|
||||||
template_name = 'counter/activity.jinja'
|
template_name = 'counter/activity.jinja'
|
||||||
|
|
||||||
class CounterStatView(DetailView, CanEditMixin):
|
class CounterStatView(DetailView, CounterAdminMixin):
|
||||||
"""
|
"""
|
||||||
Show the bar stats
|
Show the bar stats
|
||||||
"""
|
"""
|
||||||
@ -933,7 +1002,7 @@ class CounterStatView(DetailView, CanEditMixin):
|
|||||||
return super(CanEditMixin, self).dispatch(request, *args, **kwargs)
|
return super(CanEditMixin, self).dispatch(request, *args, **kwargs)
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
|
|
||||||
class CashSummaryEditView(CanEditPropMixin, CounterAdminTabsMixin, UpdateView):
|
class CashSummaryEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||||
"""Edit cash summaries"""
|
"""Edit cash summaries"""
|
||||||
model = CashRegisterSummary
|
model = CashRegisterSummary
|
||||||
template_name = 'counter/cash_register_summary.jinja'
|
template_name = 'counter/cash_register_summary.jinja'
|
||||||
@ -949,12 +1018,14 @@ class CashSummaryFormBase(forms.Form):
|
|||||||
begin_date = forms.DateTimeField(['%Y-%m-%d %H:%M:%S'], label=_("Begin date"), required=False, widget=SelectDateTime)
|
begin_date = forms.DateTimeField(['%Y-%m-%d %H:%M:%S'], label=_("Begin date"), required=False, widget=SelectDateTime)
|
||||||
end_date = forms.DateTimeField(['%Y-%m-%d %H:%M:%S'], label=_("End date"), required=False, widget=SelectDateTime)
|
end_date = forms.DateTimeField(['%Y-%m-%d %H:%M:%S'], label=_("End date"), required=False, widget=SelectDateTime)
|
||||||
|
|
||||||
class CashSummaryListView(CanEditPropMixin, CounterAdminTabsMixin, ListView):
|
class CashSummaryListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||||
"""Display a list of cash summaries"""
|
"""Display a list of cash summaries"""
|
||||||
model = CashRegisterSummary
|
model = CashRegisterSummary
|
||||||
template_name = 'counter/cash_summary_list.jinja'
|
template_name = 'counter/cash_summary_list.jinja'
|
||||||
context_object_name = "cashsummary_list"
|
context_object_name = "cashsummary_list"
|
||||||
current_tab = "cash_summary"
|
current_tab = "cash_summary"
|
||||||
|
queryset = CashRegisterSummary.objects.all().order_by('-date')
|
||||||
|
paginate_by = settings.SITH_COUNTER_CASH_SUMMARY_LENGTH
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
""" Add sums to the context """
|
""" Add sums to the context """
|
||||||
@ -984,7 +1055,7 @@ class CashSummaryListView(CanEditPropMixin, CounterAdminTabsMixin, ListView):
|
|||||||
kwargs['refilling_sums'][c.name] = sum([s.amount for s in refillings.all()])
|
kwargs['refilling_sums'][c.name] = sum([s.amount for s in refillings.all()])
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
class InvoiceCallView(CounterAdminTabsMixin, TemplateView):
|
class InvoiceCallView(CounterAdminTabsMixin, CounterAdminMixin, TemplateView):
|
||||||
template_name = 'counter/invoices_call.jinja'
|
template_name = 'counter/invoices_call.jinja'
|
||||||
current_tab = 'invoices_call'
|
current_tab = 'invoices_call'
|
||||||
|
|
||||||
@ -1001,6 +1072,10 @@ class InvoiceCallView(CounterAdminTabsMixin, TemplateView):
|
|||||||
start_date = start_date.replace(tzinfo=pytz.UTC)
|
start_date = start_date.replace(tzinfo=pytz.UTC)
|
||||||
end_date = (start_date + timedelta(days=32)).replace(day=1, hour=0, minute=0, microsecond=0)
|
end_date = (start_date + timedelta(days=32)).replace(day=1, hour=0, minute=0, microsecond=0)
|
||||||
from django.db.models import Sum, Case, When, F, DecimalField
|
from django.db.models import Sum, Case, When, F, DecimalField
|
||||||
|
kwargs['sum_cb'] = sum([r.amount for r in Refilling.objects.filter(payment_method='CARD', is_validated=True,
|
||||||
|
date__gte=start_date, date__lte=end_date)])
|
||||||
|
kwargs['sum_cb'] += sum([s.quantity*s.unit_price for s in Selling.objects.filter(payment_method='CARD', is_validated=True,
|
||||||
|
date__gte=start_date, date__lte=end_date)])
|
||||||
kwargs['start_date'] = start_date
|
kwargs['start_date'] = start_date
|
||||||
kwargs['sums'] = Selling.objects.values('club__name').annotate(selling_sum=Sum(
|
kwargs['sums'] = Selling.objects.values('club__name').annotate(selling_sum=Sum(
|
||||||
Case(When(date__gte=start_date,
|
Case(When(date__gte=start_date,
|
||||||
@ -1011,7 +1086,7 @@ class InvoiceCallView(CounterAdminTabsMixin, TemplateView):
|
|||||||
)).exclude(selling_sum=None).order_by('-selling_sum')
|
)).exclude(selling_sum=None).order_by('-selling_sum')
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
class EticketListView(CounterAdminTabsMixin, CanEditPropMixin, ListView):
|
class EticketListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||||
"""
|
"""
|
||||||
A list view for the admins
|
A list view for the admins
|
||||||
"""
|
"""
|
||||||
@ -1029,7 +1104,7 @@ class EticketForm(forms.ModelForm):
|
|||||||
}
|
}
|
||||||
product = AutoCompleteSelectField('products', show_help_text=False, label=_("Product"), required=True)
|
product = AutoCompleteSelectField('products', show_help_text=False, label=_("Product"), required=True)
|
||||||
|
|
||||||
class EticketCreateView(CounterAdminTabsMixin, CanEditPropMixin, CreateView):
|
class EticketCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView):
|
||||||
"""
|
"""
|
||||||
Create an eticket
|
Create an eticket
|
||||||
"""
|
"""
|
||||||
@ -1038,7 +1113,7 @@ class EticketCreateView(CounterAdminTabsMixin, CanEditPropMixin, CreateView):
|
|||||||
form_class = EticketForm
|
form_class = EticketForm
|
||||||
current_tab = "etickets"
|
current_tab = "etickets"
|
||||||
|
|
||||||
class EticketEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView):
|
class EticketEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||||
"""
|
"""
|
||||||
Edit an eticket
|
Edit an eticket
|
||||||
"""
|
"""
|
||||||
@ -1109,6 +1184,13 @@ class EticketPDFView(CanViewMixin, DetailView):
|
|||||||
renderPDF.draw(d, p, 10.5 * cm - 130, 6.1 * cm)
|
renderPDF.draw(d, p, 10.5 * cm - 130, 6.1 * cm)
|
||||||
p.drawCentredString(10.5 * cm, 6 * cm, code)
|
p.drawCentredString(10.5 * cm, 6 * cm, code)
|
||||||
|
|
||||||
|
partners = ImageReader("core/static/core/img/partners.png")
|
||||||
|
width, height = partners.getSize()
|
||||||
|
size = max(width, height)
|
||||||
|
width = width * 2 / 3
|
||||||
|
height = height * 2 / 3
|
||||||
|
p.drawImage(partners, 0 * cm, 0 * cm, width, height)
|
||||||
|
|
||||||
p.showPage()
|
p.showPage()
|
||||||
p.save()
|
p.save()
|
||||||
return response
|
return response
|
||||||
|
BIN
doc/Comptes-rendus/CR 16.01.05.pdf
Normal file
BIN
doc/Comptes-rendus/CR 16.01.05.pdf
Normal file
Binary file not shown.
BIN
doc/Comptes-rendus/CR 16.11.10.pdf
Normal file
BIN
doc/Comptes-rendus/CR 16.11.10.pdf
Normal file
Binary file not shown.
BIN
doc/Comptes-rendus/CR 16.11.16.pdf
Normal file
BIN
doc/Comptes-rendus/CR 16.11.16.pdf
Normal file
Binary file not shown.
BIN
doc/Comptes-rendus/CR 16.12.1.pdf
Normal file
BIN
doc/Comptes-rendus/CR 16.12.1.pdf
Normal file
Binary file not shown.
BIN
doc/Comptes-rendus/CR 16.12.15.pdf
Normal file
BIN
doc/Comptes-rendus/CR 16.12.15.pdf
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user