58 Commits

Author SHA1 Message Date
Martin Bley
99eaafff00 - getSeason() only for staff members
- new view staff()
- updated bootstrap to version 3.4.1
- updated jquery to 3.6.3
- changed container layout in main view 'matchday'
2023-04-02 21:24:20 +02:00
Martin Bley
446a55f3e5 New design and renaming for the blog which now named chat 2022-10-04 17:29:21 +02:00
Martin Bley
2f970d6eb4 fix for clean logout 2022-09-18 17:59:08 +02:00
Martin Bley
c1deabc692 fix for clean logout 2022-09-18 17:57:38 +02:00
Martin Bley
fb3e425471 fix for clean logout 2022-09-18 17:48:33 +02:00
Martin Bley
46bc47f046 Added migrations do tipp app 2022-09-18 13:59:06 +02:00
Martin Bley
8db2774f7c Added new file for lib deps 2022-09-18 13:54:36 +02:00
Martin Bley
272498b4ce Revised templates 2022-09-18 13:26:47 +02:00
Martin Bley
12323615c7 First import of migration to python 3 2022-09-18 13:24:58 +02:00
9d6857cfe2 „AUTHORS“ ändern 2022-01-05 19:38:04 +01:00
Martin Bley
565bb3963e Fixed issue #15 2016-12-21 11:04:30 +01:00
3b2deb865e Merge branch 'iss07' (about) 2016-11-23 18:52:20 +01:00
a221c0e37d Fixed iss#07 (About) 2016-11-23 18:48:33 +01:00
de3e844089 Fixed ticket #14 2016-11-23 17:58:37 +01:00
72be0aebdb Sorted mate table 2016-10-06 21:04:19 +02:00
929b540753 Changed width of TippForm to be able to see the values 2016-10-06 11:33:15 +02:00
b44d31d128 Fix of iss11 2016-10-06 11:20:49 +02:00
26833e389a No output in mate list 2016-10-06 10:45:18 +02:00
ffed1ef6e8 Fixed issue #13 2016-10-06 09:59:26 +02:00
db5ece431b Work on issue 11 2016-09-22 17:31:19 +02:00
20ef745b3f Uncomitted changes 2016-09-22 16:37:05 +02:00
45293586a7 Fixed issues in getSeason() 2016-08-20 13:58:35 +02:00
8f9398ced5 Don't know 2016-07-17 11:48:14 +02:00
589884c4be Fixed long lines 2016-06-24 16:11:43 +02:00
5c3c56ecc3 Implemented selection of mandants when posting blog items 2016-06-23 15:03:12 +02:00
6042838f28 Fixed getSeason() and update() in views.py 2016-06-23 10:51:12 +02:00
c2eede9500 Implemented mandant based blog posts 2016-06-17 22:37:43 +02:00
e3ef06a41a Minor changes 2016-06-14 12:49:10 +02:00
9be82123da Better update() using a nother query 2016-06-13 21:27:31 +02:00
911b19068c Renewed get_current_md() based on OL method 2016-06-11 17:09:13 +02:00
c02f137c0b fixed some issues regarding template 2016-06-10 17:54:59 +02:00
538f6262fd modified for EURO 2016 2016-06-10 17:36:02 +02:00
4b2f7e4641 Finished templates for new HTTP method 2016-06-08 08:15:54 +02:00
d99eee4751 Merge branch 'iss02' 2016-06-07 18:20:35 +02:00
5a0a1daa39 finished import function 2016-06-07 18:19:22 +02:00
20f0a836e5 new url for import added 2016-06-07 17:24:15 +02:00
c0eb583a69 import function created 2016-06-07 17:22:28 +02:00
7292957497 Don't know 2016-06-07 16:52:22 +02:00
62ec42297d Removed title and slug field from blogpost model and db 2016-02-25 09:37:03 +01:00
5b033803a8 Merge branch 'master' into iss02 2016-02-25 08:36:08 +01:00
364166d84b Fixed 'None' items in mate table 2016-02-24 16:00:34 +01:00
de904d4ad4 Fixed 'None' items in charts 2016-02-24 15:36:00 +01:00
7c66399c8f Some blank lines 2016-02-24 14:37:07 +01:00
6332b49eac Fixed Ticket#01 2016-02-15 18:02:39 +01:00
ae3d3d2c12 gitignore modified 2016-02-11 18:49:04 +01:00
de0b82d575 Fix for ticket #4 (charts) 2016-02-07 12:20:39 +01:00
59b0e742d0 added null constraint to Post::title model 2016-02-05 16:48:16 +01:00
853dba350e readded __init__.py 2016-01-29 16:09:13 +01:00
5c5e5fac8a deleted files 2016-01-29 14:12:55 +01:00
18d235ca31 Added comment 2016-01-25 07:58:55 +01:00
a0f30729c5 Final test 2016-01-20 19:45:57 +01:00
e7956269f1 yet another test 2016-01-20 19:42:47 +01:00
944ecc8d0a gitignore 2016-01-20 19:22:27 +01:00
root
ecde9aaa67 Test on master 2016-01-20 19:17:16 +01:00
0c48fd85aa Just another test 2016-01-20 19:10:35 +01:00
8e12bb0a51 Just a test 2016-01-20 19:03:01 +01:00
91faecae56 added .gitignored 2016-01-20 18:47:22 +01:00
20803dcca8 added lic and authors 2016-01-20 18:25:58 +01:00
33 changed files with 1999 additions and 773 deletions

10
.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
*.pyc
*.swp
bin/
manage.py
media/
old_stuff/
static/
templates/blogindex.html-media
tippy/static/
warnings.txt

1
AUTHORS Normal file
View File

@@ -0,0 +1 @@
Martin Bley <dev@mb-oss.de>

6
CHANGELOG Normal file
View File

@@ -0,0 +1,6 @@
- getSeason() only for staff members
- new view staff()
- updated bootstrap to version 3.4.1
- updated jquery to 3.6.3
- changed container layout in main view 'matchday'

674
COPYING Normal file
View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
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.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<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>.

16
TipPy/asgi.py Normal file
View File

@@ -0,0 +1,16 @@
"""
ASGI config for TipPy project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TipPy.settings')
application = get_asgi_application()

146
TipPy/settings.py Normal file
View File

@@ -0,0 +1,146 @@
"""
Django settings for TipPy project.
Generated by 'django-admin startproject' using Django 4.0.6.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-jiw8js(^@d)no7tv(oq+ugl3kj=f8@j-kz3bj530&!%!$cjqj9'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'tipp'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'TipPy.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates']
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'TipPy.wsgi.application'
WSGI_APPLICATION = 'TipPy.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'tippy',
'USER': 'tippy',
'PASSWORD': 'tippy',
'HOST': 'localhost',
'PORT': '5432',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/
LANGUAGE_CODE = 'de-de'
TIME_ZONE = 'Europe/Berlin'
USE_I18N = True
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
if not DEBUG:
STATIC_ROOT = ''
STATICFILES_DIRS = [
#os.path.join(BASE_DIR, 'static/'),
]
# STATIC_ROOT=os.path.join(BASE_DIR,"static/")
# STATIC_URL = 'static/'
# STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), ]
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# Redirect on logout
LOGOUT_REDIRECT_URL = "home"

8
TipPy/urls.py Normal file
View File

@@ -0,0 +1,8 @@
from django.contrib import admin, auth
from django.urls import include, path, re_path
urlpatterns = [
path('', include('tipp.urls')),
path('admin/', admin.site.urls),
]

16
TipPy/wsgi.py Normal file
View File

@@ -0,0 +1,16 @@
"""
WSGI config for TipPy project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TipPy.settings')
application = get_wsgi_application()

6
requirements.txt Normal file
View File

@@ -0,0 +1,6 @@
Django~=4.1.7
psycopg2~=2.9.5
suds~=1.1.2
Pillow~=9.4.0
pytz~=2023.2
urllib3~=1.26.15

29
templates/about.html Normal file
View File

@@ -0,0 +1,29 @@
{% extends "base.html" %}
{% load i18n static %}
{% load humanize %}
{% block head %}
<script type="text/javascript" src="{% static 'javascript/tippy.js' %}"></script>
{% endblock %}
{% block nav %}
{% include "nav.html" with ls=ls season=season %}
{% endblock %}
{% block body %}
<div id="content-main">
<div class="row">
<div class="col-md-7">
<h2>Über TipPy</h2>
<p>TipPy ist eine responsive Web-Applikation für Tippspiele mit
einem "Mobile-First-Ansatz" . Unterstützt werden alle auf
<a href="http://www.OpenLigaDB.de">OpenLigaDB</a> bereitgestellten
Sportarten und Ligen.
TipPy wurde in <a href="http://www.python.org">Python</a> umgesetzt
und benutzt die Frameworks <a href="http://www.django.org">Django</a>
als Web Application Framework, und Twitters <a href="www.getbootstrap.com">
Bootstrap</a> für CSS.</p>
</div>
</div>
</div>
{% endblock %}

View File

@@ -16,13 +16,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap -->
<link href="{{ STATIC_URL }}css/bootstrap.min.css" rel="stylesheet">
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
<!-- Bootstrap-Theme -->
<link href="{{ STATIC_URL }}css/bootstrap-theme.min.css" rel="stylesheet">
<link href="{% static 'css/bootstrap-theme.min.css' %}" rel="stylesheet">
<!-- Bootstrap-Theme -->
<link href="{{ STATIC_URL }}css/tippy-bootstrap.css" rel="stylesheet">
<link href="{% static 'css/tippy-bootstrap.css' %}" rel="stylesheet">
<!-- Unterstützung für Media Queries und HTML5-Elemente im Internet Explorer über HTML5 shim und Respond.js -->
<!-- ACHTUNG: Respond.js funktioniert nicht, wenn du die Seite über file:// aufrufst -->
@@ -36,9 +36,9 @@
<body>
<!-- jQuery (wird für Bootstrap JavaScript-Plugins benötigt) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<!-- Binde alle kompilierten Plugins zusammen ein (wie hier unten) oder such dir einzelne Dateien nach Bedarf aus -->
<script src="{{ STATIC_URL }}js/bootstrap.min.js"></script>
<script src="{% static 'js/bootstrap.min.js'%}"></script>
{% block nav %}{% endblock %}
@@ -51,8 +51,13 @@
<div class="container-fluid">
<div class="row">
<div class="col-md-7">
<p>© Martin Bley, 2014-2015 | Dank an <a href="http://openligadb.de">OpenLigaDB</a> für
die Bereitstellung der Spielergebnisse.</p>
<p>
<div class="pull-left">
© Martin Bley, 2014-2023 | Dank an
<a href="http://openligadb.de">OpenLigaDB</a> für die Bereitstellung der
Spielergebnisse.
</div>
</p>
</div>
</div>
</div>

View File

@@ -2,15 +2,15 @@
{% load i18n static %}
{% load humanize %}
{% block head %}
<title> TipPy Blog</title>
<title> TipPy Blog</title>
{% endblock %}
{% block nav %}
{% include "nav.html" with ls=ls season=season %}
{% include "nav.html" with ls=ls season=season %}
{% endblock %}
{% block body %}
<div id="content-main">
<div id="content-main">
<div class="row">
<div class="col-md-7">
<h2>TipPy Blog</h2>
@@ -19,26 +19,29 @@
</p>
</div>
</div>
<ul class="media-list">
{% for post, avatar in posts %}
<div class="row">
<div class="col-md-7">
<div class="panel panel-default">
<div class="panel-heading">
{{post.author.first_name}} schrieb {{post.created|naturaltime}},
<a href="{{post.get_absolute_url}}">{{post.title}}</a>
</div>
<div class="panel-body">
<li class="media">
<a href="#" class="pull-left">
{% if avatar %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic" src="/media/{{avatar}}" />
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic"
src="/media/{{ avatar }}"/>
{% else %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic" src="/media/profiles/dummy.png" />
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic"
src="/media/profiles/dummy.png"/>
{% endif %}
{{post.content|safe}}
</div>
</div>
</div>
</a>
<div class="media-body">
<span class="text-muted pull-right">
<small class="text-muted">{{ post.created|naturaltime }}</small>
</span>
<strong class="text-success">{{ post.author.first_name }}</strong>
<p>{{ post.content|safe }}</p>
</div>
</li>
{% endfor %}
</ul>
<div class="row">
<div class="col-md-7">
<nav>
@@ -68,5 +71,5 @@
</nav>
</div>
</div>
</div>
</div>
{% endblock %}

28
templates/chat.xhtml Normal file
View File

@@ -0,0 +1,28 @@
{% load humanize %}
<hr>
<p class="text-left">
<a class="btn btn-default" href="/blog/newpost" role="button">neuer Post</a>
</p>
<ul class="media-list">
{% for post, avatar in posts %}
<li class="media">
<a href="#" class="pull-left">
{% if avatar %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic"
src="/media/{{ avatar }}"/>
{% else %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic"
src="/media/profiles/dummy.png"/>
{% endif %}
</a>
<div class="media-body">
<span class="text-muted pull-right">
<small class="text-muted">{{ post.created|naturaltime }}</small>
</span>
<strong class="text-success">{{ post.author.first_name }}</strong>
<p>{{ post.content|safe }}</p>
</div>
</li>
{% endfor %}
</ul>

View File

@@ -1,33 +0,0 @@
{% extends "base.html" %}
{% load url from future %}
{% comment %}
Main page to authenticate users.
{% endcomment %}
{% block head %}
<title>TipPy | Login</title>
{% endblock %}
{% block nav %}
{% include "nav_login.html" with ls=ls season=season %}
{% endblock %}
{% block body %}
{% if form.errors %}
<div class="row">
<p>Benutzename und Passwort passen nicht zusammen. Bitte versuche es noch einmal.</p>
</div>
{% endif %}
<div class="row">
<div class="col-md-3">
<form class="form-signin" role="form" method="post" action="{% url 'django.contrib.auth.views.login' %}">
<h2 class="form-signin-heading">Bitte melde dich an</h2>
{% csrf_token %}
<input class="form-control" type="text" autofocus="" required="" name="{{form.username.html_name}}" placeholder="Anmeldename" />
<input class="form-control" type="password" required="" placeholder="Passwort" name="{{form.password.html_name}}" />
<button class="btn btn-lg btn-primary btn-block" type="submit">Anmelden</button>
<input type="hidden" name="next" value="{{ next }}" />
</form>
</div>
</div>
{% endblock %}

View File

@@ -2,47 +2,27 @@
{% load i18n static %}
{% load humanize %}
{% block head %}
<script type="text/javascript" src="{{ STATIC_URL }}javascript/tippy.js"></script>
<script type="text/javascript" src="{% static 'javascript/tippy.js' %}"></script>
{% endblock %}
{% block nav %}
{% include "nav.html" with ls=ls season=season %}
{% include "nav.html" with ls=ls season=season %}
{% endblock %}
{% block body %}
<div id="content-main">
<div id="content-main">
<div class="row">
<div class="col-md-7">
<h2>Neueste Nachrichten</h2>
<p class="text-right">
<a class="btn btn-default" href="/blog/1" role="button">zum Blog</a>
</p>
{% for post, avatar in posts %}
<div class="panel panel-default">
<div class="panel-heading">
{{post.author.first_name}} schrieb {{post.created|naturaltime}},
<a href="{{post.get_absolute_url}}">{{post.title}}</a>
</div>
<div class="panel-body">
{% if avatar %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic" src="/media/{{avatar}}" />
{% else %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic" src="/media/profiles/dummy.png" />
{% endif %}
{{post.content|safe}}
</div>
</div>
{% endfor %}
</div>
</div>
<div class="row">
<div class="col-md-7">
<h2>Deine Tipps</h2>
<div class="col-md-6">
<h3>Deine Tipps</h3>
<nav>
<ul class="pager">
<li data-toggle="tooltip" title="{% trans 'previous' %}" class="previous"><a href="/matchday/{{ ls }}/{{ season }}/{{ cur_md|add:"-1"|stringformat:"02i" }}"><span aria-hidden="true">&larr;</span></a></li>
{{ cur_md }}. Spieltag
<li data-toggle="tooltip" title="{% trans 'next' %}" class="next"><a href="/matchday/{{ ls }}/{{ season }}/{{ cur_md|add:"1"|stringformat:"02i" }}"><span aria-hidden="true">&rarr;</span></a></li>
<li data-toggle="tooltip" title="{% trans 'previous' %}" class="previous"><a
href="/matchday/{{ ls }}/{{ season }}/{{ cur_md|add:"-1"|stringformat:"02i" }}"><span
aria-hidden="true">&larr;</span></a></li>
{{ md_name }}
<li data-toggle="tooltip" title="{% trans 'next' %}" class="next"><a
href="/matchday/{{ ls }}/{{ season }}/{{ cur_md|add:"1"|stringformat:"02i" }}"><span
aria-hidden="true">&rarr;</span></a></li>
</ul>
</nav>
<form role="form" action="" method="post">{% csrf_token %}
@@ -52,23 +32,33 @@
<th>Anstoß</th>
<th>Heim</th>
<th>Gast</th>
<th>Erg.></th>
<th>Erg.</th>
<th colspan="2">Tipp</th>
</tr>
{% for match in matches %}
{% if match.started and not match.finished %}
<tr class="danger">{% else %}<tr>{% endif %}
<tr class="danger">{% else %}
<tr>{% endif %}
<td>{{ match.matchDateTime }}</td>
<td><img src="{{ STATIC_URL}}{{ match.iconTeam1 }}" />
{% if match.iconURLTeam1 != "" %}
<td><img src="{{ match.iconURLTeam1 }}" width="20"/>
{% else %}
<td><img src="{{ STATIC_URL }}{{ match.iconTeam1 }}"/>
{% endif %}
<span class="hidden-xs"> {{ match.nameTeam1 }}</span>
<span class="visible-xs"> {{ match.abbrTeam1 }}</span>
</td>
<td><img src="{{ STATIC_URL}}{{ match.iconTeam2 }}" />
{% if match.iconURLTeam1 != "" %}
<td><img src="{{ match.iconURLTeam2 }}" width="20"/>
{% else %}
<td><img src="{{ STATIC_URL }}{{ match.iconTeam2 }}"/>
{% endif %}
<span class="hidden-xs"> {{ match.nameTeam2 }}</span>
<span class="visible-xs"> {{ match.abbrTeam2 }}</span>
</td>
<td>{{ match.matchResult }}</td>
<td>{{ match.tippFormTeam1 }}</td><td>{{ match.tippFormTeam2 }}</td>
<td>{{ match.tippFormTeam1 }}</td>
<td>{{ match.tippFormTeam2 }}</td>
</tr>
{% endfor %}
</table>
@@ -77,33 +67,49 @@
<span class="glyphicon glyphicon-saved" aria-hidden="true"></span> Tipps abgeben
</button>
</form>
</div>
</div>
<div class="row">
<div class="col-md-7">
<h2>Mitspieler</h2>
{% for mandant, list in mandant_dict.items %}
<h3>Mitspieler {{ mandant }}</h3>
<div class="table-responsive">
<table class="table table-hover table-condensed">
<tr>
<th>Tipper</th>
<th>Gesamt</th>
{% for match in matches %}
<th><img src="{{ STATIC_URL }}{{ match.iconTeam1 }}" /><br /><br />
<img src="{{ STATIC_URL }}{{ match.iconTeam2 }}" /></th>
<th>
{% if match.iconURLTeam1 != "" %}
<img src="{{ match.iconURLTeam1 }}" width="20"/>
{% else %}
<img src="{{ STATIC_URL }}{{ match.iconTeam1 }}"/>
{% endif %}
<br/><br/>
{% if match.iconURLTeam2 != "" %}
<img src="{{ match.iconURLTeam2 }}" width="20"/>
{% else %}
<img src="{{ STATIC_URL }}{{ match.iconTeam2 }}"/>
{% endif %}
</th>
{% endfor %}
</tr>
{% for mate in tipp_mates %}
{% for mate in list %}
<tr>
<td>{{ mate.mate }}</td>
<td>{{ mate.mate.first_name }}</td>
<td>{{ mate.sum_score }}</td>
{% for tipp in mate.tipps %}
<td>{{ tipp }}</td>
{% endfor %}
</tr>
{% endfor %}
</tr>
</table>
</div>
{% endfor %}
</div>
<div class="col-md-6">
<h3>Chat</h3>
{% block chat %}
{% include "chat.xhtml" with posts=posts %}
{% endblock %}
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -9,13 +9,16 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">TipPy 1.0</span>
<a class="navbar-brand" href="/about">TipPy 1.0</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="/">Tipps</a></li>
<li><a href="/charts/{{ ls }}/{{ season }}{% if pos %}/{{ pos }}{% endif %}">Bestenliste</a></li>
<li><a href="/blog/1">Blog</a></li>
{% if request.user.is_active and request.user.is_staff %}
<li><a href="/staff">Staff</a></li>
{% endif %}
</ul>
<ul class="nav navbar-nav navbar-right">
{% if has_refresh %}
@@ -32,7 +35,7 @@
<ul class="dropdown-menu">
<li><a href="/accounts/profile/{{user.id}}">Profil ändern</a></li>
<li><a href="/accounts/password_change/">Passwort ändern</a></li>
<li><a href="/logout">Abmelden</a></li>
<li><a href="/accounts/logout">Abmelden</a></li>
</ul>
</li>
</ul>

View File

@@ -1,19 +1,19 @@
{% extends "base.html" %}
{% load i18n static %}
{% block head %}
<title> TipPy Blog</title>
<title> TipPy Blog</title>
{% endblock %}
{% block nav %}
{% include "nav.html" with ls=ls season=season %}
{% include "nav.html" with ls=ls season=season %}
{% endblock %}
{% block body %}
<div id="content-main">
{% if form.errors %}
<div id="content-main">
{% if form_bp.errors %}
<div>
<p class="errornote">
{% if form.errors.items|length == 1 %}
{% if form_bp.errors.items|length == 1 %}
{% trans "Please correct the error below." %}
{% else %}
{% trans "Please correct the errors below." %}
@@ -24,17 +24,19 @@
<div class="col-md-8">
<form class="form-horizontal" action="" method="post">{% csrf_token %}
<div class="form-group">
{{form.title.errors}}
<label for="id_title" class="col-sm-4 control-label required">{% trans 'Title' %}</label>
{{ form_bp.content.errors }}
<div class="col-sm-5">
<input id="id_title" maxlength="32" name="title" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
{{form.content.errors}}
<label for="id_content" class="col-sm-4 control-label required">{% trans 'Content' %}</label>
<div class="col-sm-5">
<textarea class="form-control" maxlength="256" rows="2" id="id_content" name="content"></textarea>
<div class="panel-body">
<textarea class="form-control" placeholder="Schreibe einen Kommentar..." id="id_content"
name="content" maxlength="100" rows="2"></textarea>
{% if cnt_mandants > 1 %}
{{ form_mandants.mandants.label_tag }}
{% for choice in form_mandants.mandants %}
<label for="{{ choice.id_for_label }}">
{{ choice.tag }} {{ choice.choice_label }}
</label>
{% endfor %}
{% endif %}
</div>
</div>
<div class="form-group">
@@ -45,5 +47,12 @@
</form>
</div>
</div>
</div>
{% if debug %}
<div class="row">
<div class="col-md-8">
<p>{{ debug }}</p>
</div>
</div>
{% endif %}
</div>
{% endblock %}

View File

@@ -1,5 +1,6 @@
{% extends "base.html" %}
{% load url from future %}
{% load admin_urls %}
{% comment %}
Main page to authenticate users.
{% endcomment %}
@@ -20,7 +21,7 @@
{% endif %}
<div class="row">
<div class="col-md-3">
<form class="form-signin" role="form" method="post" action="{% url 'django.contrib.auth.views.login' %}">
<form class="form-signin" role="form" method="post" action="{% url 'login' %}">
<h2 class="form-signin-heading">Bitte melde dich an</h2>
{% csrf_token %}
<input class="form-control" type="text" autofocus="" required="" name="{{form.username.html_name}}" placeholder="Anmeldename" />

34
templates/staff.html Normal file
View File

@@ -0,0 +1,34 @@
{% extends "base.html" %}
{% load i18n static %}
{% load humanize %}
{% block head %}
<script type="text/javascript" src="{% static 'javascript/tippy.js' %}"></script>
{% endblock %}
{% block nav %}
{% include "nav.html" with ls=ls season=season %}
{% endblock %}
{% block body %}
<div id="content-main">
<div class="row">
<div class="col-md-12">
<h3>Wettbewerbe</h3>
{% for comp in competitions %}
{{ comp }}<br/>
{% endfor %}
<h3></h3>
</div>
</div>
{% if debug %}
<div class="row">
<div class="col-md-12">
<h2 class="form-signin-heading">{% trans 'Debug' %}</h2>
{% for line in debug %}
<p>{{ line }}</p>
{% endfor %}
</div>
</div>
{% endif %}
</div>
{% endblock %}

View File

@@ -1,21 +1,37 @@
from tipp.models import Team, Match, Tipp, Score, Mandant, RelUserMandant, Competition, Post, UserProfile
# -*- coding: utf-8 -*-
"""
Copyright (c) 2015-2016 by Martin Bley (martin@mb-oss.de)
This file is part of TipPy.
TipPy 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.
TipPy 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 TipPy. If not, see <http://www.gnu.org/licenses/>.
"""
from tipp.models import *
from django.contrib import admin
class PostAdmin(admin.ModelAdmin):
# fields display on change list
list_display = ['title']
list_display = ['content']
# fields to filter the change list with
list_filter = ['published', 'created']
# fields to search in change list
search_fields = ['title', 'content']
search_fields = ['content']
# enable the date drill down on change list
date_hierarchy = 'created'
# enable the save buttons on top on change form
save_on_top = True
# prepopulate the slug from the title - big timesaver!
prepopulated_fields = {"slug": ("title",)}
admin.site.register(Team)
admin.site.register(Match)
@@ -25,4 +41,5 @@ admin.site.register(Score)
admin.site.register(RelUserMandant)
admin.site.register(Competition)
admin.site.register(Post, PostAdmin)
admin.site.register(RelPostMandant)

View File

@@ -1,32 +1,63 @@
# -*- coding: utf-8 -*-
"""
Copyright (c) 2015-2016 by Martin Bley (martin@mb-oss.de)
This file is part of TipPy.
TipPy 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.
TipPy 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 TipPy. If not, see <http://www.gnu.org/licenses/>.
"""
from django import forms
from django.forms import ModelForm
from django.contrib.auth.models import User
from django.core.files.images import get_image_dimensions
from tipp.models import Match, Competition, Post, UserProfile
from tipp.models import Match, Competition, Post, UserProfile, \
Mandant, RelUserMandant
class NumberInput(forms.TextInput):
input_type = 'number'
class TippForm(forms.Form):
tippTeam1 = forms.IntegerField(required=True,widget=NumberInput(attrs={
tippTeam1 = forms.IntegerField(required=True,widget=NumberInput(
attrs={
'cols': '2',
'min': '0', 'max': '99', 'step': '1',
'class':'form-inline',
'role': 'form'}
'role': 'form'
}
))
tippTeam2 = forms.IntegerField(required=True,widget=NumberInput(attrs={
tippTeam2 = forms.IntegerField(required=True,widget=NumberInput(
attrs={
'cols': '2',
'min': '0', 'max': '99', 'step': '1',
'class':'form-inline',
'role': 'form'}
'role': 'form'
}
))
tippTeam1.widget.attrs['style'] = "width:35px"
tippTeam2.widget.attrs['style'] = "width:35px"
tippTeam1.widget.attrs['style'] = "width:45px"
tippTeam2.widget.attrs['style'] = "width:45px"
class BlogpostForm(ModelForm):
class Meta:
model = Post
fields = ['title', 'content']
fields = ['content']
class MandantsForm(forms.Form):
mandants = forms.MultipleChoiceField(
label= "Posten in",
widget=forms.CheckboxSelectMultiple({'checked':'checked'})
)
class UserForm(forms.ModelForm):
class Meta:

View File

@@ -0,0 +1,146 @@
# Generated by Django 4.0.6 on 2022-07-14 15:15
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Competition',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('leagueShortcut', models.CharField(max_length=32)),
('leagueName', models.CharField(max_length=128)),
('season', models.CharField(max_length=4)),
],
),
migrations.CreateModel(
name='Mandant',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=32, unique=True)),
('description', models.CharField(max_length=255)),
],
),
migrations.CreateModel(
name='Post',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('content', models.TextField()),
('published', models.BooleanField(default=True)),
('created', models.DateTimeField(auto_now_add=True)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-created'],
},
),
migrations.CreateModel(
name='Team',
fields=[
('teamID', models.IntegerField(primary_key=True, serialize=False, unique=True)),
('name', models.CharField(max_length=200)),
('icon', models.FileField(upload_to='images/team_logos/')),
('abbr', models.CharField(max_length=3)),
('iconURL', models.CharField(max_length=2000)),
],
options={
'managed': True,
},
),
migrations.CreateModel(
name='UserProfile',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('avatar', models.ImageField(blank=True, upload_to='profiles/')),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Score',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('exact_high', models.PositiveSmallIntegerField()),
('exact', models.PositiveSmallIntegerField()),
('diff', models.PositiveSmallIntegerField()),
('tendency', models.PositiveSmallIntegerField()),
('client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tipp.mandant')),
],
),
migrations.CreateModel(
name='Match',
fields=[
('matchID', models.IntegerField(primary_key=True, serialize=False, unique=True)),
('matchDateTime', models.DateTimeField()),
('group', models.IntegerField()),
('matchday', models.IntegerField()),
('matchday_name', models.CharField(max_length=128)),
('pointsTeam1', models.SmallIntegerField()),
('pointsTeam2', models.SmallIntegerField()),
('finished', models.BooleanField()),
('season', models.CharField(max_length=4)),
('leagueShortcut', models.CharField(max_length=12)),
('idTeam1', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='tipp.team')),
('idTeam2', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='tipp.team')),
],
),
migrations.CreateModel(
name='Tipp',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('pointsTeam1', models.PositiveSmallIntegerField()),
('pointsTeam2', models.PositiveSmallIntegerField()),
('score', models.PositiveIntegerField(blank=True, null=True)),
('matchID', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tipp.match')),
('tipperID', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'unique_together': {('matchID', 'tipperID')},
},
),
migrations.CreateModel(
name='RelUserMandant',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mandant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tipp.mandant')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'unique_together': {('user', 'mandant')},
},
),
migrations.CreateModel(
name='RelPostMandant',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mandant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tipp.mandant')),
('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tipp.post')),
],
options={
'unique_together': {('post', 'mandant')},
},
),
migrations.CreateModel(
name='chart',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('points', models.PositiveSmallIntegerField()),
('diff', models.SmallIntegerField()),
('games', models.PositiveSmallIntegerField()),
('competition', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tipp.competition')),
('team', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tipp.team')),
],
options={
'unique_together': {('team', 'competition')},
},
),
]

View File

View File

@@ -1,38 +1,75 @@
from django.db import models
from django.core.urlresolvers import reverse
# -*- coding: utf-8 -*-
"""
Copyright (c) 2015-2016 by Martin Bley (martin@mb-oss.de)
This file is part of TipPy.
TipPy 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.
TipPy 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 TipPy. If not, see <http://www.gnu.org/licenses/>.
"""
from django.contrib.auth.models import User
from django.db import models
class UserProfile(models.Model):
user = models.OneToOneField(User)
user = models.OneToOneField(
User,
on_delete=models.CASCADE
)
avatar = models.ImageField(upload_to="profiles/", blank=True)
def __unicode__(self):
return self.user.username
class Competition(models.Model):
leagueShortcut = models.CharField(max_length=32)
leagueName = models.CharField(max_length=128)
season = models.CharField(max_length=4)
def __unicode__(self):
return(self.leagueShortcut)
return (self.leagueShortcut)
class Team(models.Model):
teamID = models.IntegerField(unique=True, primary_key=True)
name = models.CharField(max_length=200)
icon = models.FileField(upload_to="images/team_logos/")
abbr = models.CharField(max_length=3)
iconURL = models.CharField(max_length=2000)
def __unicode__(self):
return self.name
class Meta:
managed = True
app_label = 'tipp'
class Match(models.Model):
matchID = models.IntegerField(unique=True,primary_key=True)
matchID = models.IntegerField(unique=True, primary_key=True)
matchDateTime = models.DateTimeField()
group = models.IntegerField()
matchday = models.IntegerField()
idTeam1 = models.ForeignKey(Team, related_name='+')
idTeam2 = models.ForeignKey(Team, related_name='+')
matchday_name = models.CharField(max_length=128)
idTeam1 = models.ForeignKey(
Team, related_name='+',
on_delete=models.CASCADE
)
idTeam2 = models.ForeignKey(
Team, related_name='+',
on_delete=models.CASCADE
)
pointsTeam1 = models.SmallIntegerField()
pointsTeam2 = models.SmallIntegerField()
finished = models.BooleanField()
@@ -40,41 +77,59 @@ class Match(models.Model):
leagueShortcut = models.CharField(max_length=12)
def __unicode__(self):
"""
return (str(self.matchID) +
str(Team.objects.get(teamID=int(self.idTeam1)).values(name)) + " - " +
str(Team.objects.get(teamID=int(self.idTeam2)).values(name)))
"""
return (str(self.matchID))
class Tipp(models.Model):
matchID = models.ForeignKey(Match)
tipperID = models.ForeignKey(User)
matchID = models.ForeignKey(
Match,
on_delete=models.CASCADE
)
tipperID = models.ForeignKey(
User,
on_delete=models.CASCADE
)
pointsTeam1 = models.PositiveSmallIntegerField()
pointsTeam2 = models.PositiveSmallIntegerField()
score = models.PositiveIntegerField(blank=True, null=True)
score = models.PositiveIntegerField(
blank=True, null=True
)
class Meta:
unique_together = ("matchID", "tipperID")
class Mandant(models.Model):
name = models.CharField(max_length=32, unique=True)
description = models.CharField(max_length=255)
def __unicode__(self):
return self.name
class Score(models.Model):
client = models.ForeignKey(Mandant)
client = models.ForeignKey(
Mandant,
on_delete=models.CASCADE
)
exact_high = models.PositiveSmallIntegerField()
exact = models.PositiveSmallIntegerField()
diff = models.PositiveSmallIntegerField()
tendency = models.PositiveSmallIntegerField()
def __unicode__(self):
return str(self.client)
class chart(models.Model):
team = models.ForeignKey(Team)
competition = models.ForeignKey(Competition)
team = models.ForeignKey(
Team,
on_delete=models.CASCADE
)
competition = models.ForeignKey(
Competition,
on_delete=models.CASCADE
)
points = models.PositiveSmallIntegerField()
diff = models.SmallIntegerField()
games = models.PositiveSmallIntegerField()
@@ -82,30 +137,52 @@ class chart(models.Model):
class Meta:
unique_together = ("team", "competition")
class RelUserMandant(models.Model):
user = models.ForeignKey(User)
mandant = models.ForeignKey(Mandant)
user = models.ForeignKey(
User,
on_delete=models.CASCADE
)
mandant = models.ForeignKey(
Mandant,
on_delete=models.CASCADE
)
class Meta:
unique_together = ("user", "mandant")
def __unicode__(self):
return (str(self.user) + " -> " + str(self.mandant))
class Post(models.Model):
title = models.CharField(max_length=255)
slug = models.SlugField(unique=True, max_length=255)
content = models.TextField()
published = models.BooleanField(default=True)
created = models.DateTimeField(auto_now_add=True)
author = models.ForeignKey(User)
author = models.ForeignKey(
User,
on_delete=models.CASCADE
)
class Meta:
ordering = ['-created']
def __unicode__(self):
return u'%s' % self.title
def get_absolute_url(self):
return reverse('tipp.views.blogpost', args=[self.slug])
return u'%s' % self.created
class RelPostMandant(models.Model):
post = models.ForeignKey(
Post,
on_delete=models.CASCADE
)
mandant = models.ForeignKey(
Mandant,
on_delete=models.CASCADE
)
class Meta:
unique_together = ("post", "mandant")
def __unicode__(self):
return (str(self.post) + " -> " + str(self.mandant))

57
tipp/openliga.py Executable file → Normal file
View File

@@ -1,22 +1,30 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2013 by Martin Bley <martin@mb-oss.de>
# Copyright (c) 2015-2016 by Martin Bley (martin@mb-oss.de)
#
# tippy.py is free software: you can redistribute it and/or modify
# This file is part of TipPy.
#
# TipPy 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.
#
# tippy.py is distributed in the hope that it will be useful,
# TipPy 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 tippy.py. If not, see <http://www.gnu.org/licenses/>.
# along with TipPy. If not, see <http://www.gnu.org/licenses/>.
#
import locale
import urllib.error
import urllib.parse
import urllib.request
from suds.client import Client
import sys, locale, suds, urllib2, psycopg2
class OpenLiga(object):
version = "0.1"
@@ -35,34 +43,51 @@ class OpenLiga(object):
# get a SUDS client object
if self.proxyurl is None:
try:
self.client = suds.client.Client('http://www.openligadb.de/Webservices/Sportsdata.asmx?WSDL')
except (urllib2.URLError):
self.client = Client(
'http://www.openligadb.de/'
+ 'Webservices/Sportsdata.asmx?WSDL')
except (urllib.error.URLError):
self.error += "Connect to webservice failed."
else:
try:
t = suds.transport.http.HttpTransport()
proxy = urllib2.ProxyHandler({'http':proxyurl})
opener = urllib2.build_opener(proxy)
proxy = urllib.request.ProxyHandler({'http': proxyurl})
opener = urllib.request.build_opener(proxy)
t.urlopener = opener
self.client = suds.client.Client('http://www.openligadb.de/Webservices/Sportsdata.asmx?WSDL', transport=t)
except urllib2.URLError as e:
self.error += "Connect to webservice failed (via proxy " + proxyurl + "): " + str(e) + "\n"
self.client = suds.client.Client(
'http://www.openligadb.de/Webservices/'
+ 'Sportsdata.asmx?WSDL', transport=t)
except urllib.error.URLError as e:
self.error += "Connect to webservice failed " \
+ "(via proxy " + proxyurl + "): " + str(e) + "\n"
def getSeason(self, season, league='bl1'):
""" Get the whole season.
Args: season and league shortcut (optional)
"""
return(self.client.service.GetMatchdataByLeagueSaison(leagueShortcut=league,leagueSaison=season))
return (self.client.service.GetMatchdataByLeagueSaison(
leagueShortcut=league, leagueSaison=season)
)
def getMatchday(self, season, matchdaynumber, league='bl1'):
""" Get matchday.
Args: season, matchdaynumber and league shortcut (optional)
"""
return(self.client.service.GetMatchdataByGroupLeagueSaison(groupOrderID=matchdaynumber,leagueShortcut=league,leagueSaison=season))
return (self.client.service.GetMatchdataByGroupLeagueSaison(
groupOrderID=matchdaynumber,
leagueShortcut=league,
leagueSaison=season)
)
def getTeams(self, season, league='bl1'):
return(self.client.service.GetTeamsByLeagueSaison(leagueShortcut=league,leagueSaison=season))
return (self.client.service.GetTeamsByLeagueSaison(
leagueShortcut=league,
leagueSaison=season)
)
def getCurrentGroup(self, league):
return (self.client.service.GetCurrentGroup(
leagueShortcut=league)
)

View File

@@ -1,6 +1,6 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
This file demonstrates writing tests using the unittest module.
These will pass when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""

View File

@@ -1,3 +0,0 @@
from tipp.models import Match

33
tipp/urls.py Normal file
View File

@@ -0,0 +1,33 @@
from django.contrib.auth import views as auth_views
from django.urls import re_path
from django.conf.urls import include
from django.conf import settings
from django.conf.urls.static import static
from . import views
urlpatterns = [
re_path(r'^$', views.home, name='home'),
re_path(r'^getSeason/(?P<ls>.*)/(?P<season>\d{4})$',
views.getSeason),
re_path(r'^update/(?P<ls>.*)/(?P<season>\d{4})/(?P<cur_md>\d{2})$',
views.update, name='update'),
re_path(r'^matchday/(?P<ls>.{3,})/(?P<season>\d{4})/(?P<matchday>\d{2})$',
views.matchday, name='matchday'),
re_path(r'^charts/(?P<ls>\w{3,})/(?P<season>\d{4})$', views.charts,
name='charts'),
re_path(r'^charts/(?P<ls>\w{3,})/(?P<season>\d{4})/(?P<pos>\w{1,})$',
views.charts, name='charts'),
re_path(r'^accounts/profile/(\d+)', views.profile),
re_path(r'^accounts/', include('django.contrib.auth.urls')),
re_path(r'^blog/newpost$', views.newBlogpost),
re_path(r'^blog/(?P<page>\d)$', views.blogindex),
re_path(r'^about$', views.about),
re_path(r'^staff', views.staff),
re_path(r'^accounts/login/', auth_views.LoginView.as_view()),
re_path(r'^accounts/logout/', auth_views.LogoutView.as_view())
]
# Redirect on logout
LOGOUT_REDIRECT_URL = "home"
if settings.DEBUG is True:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View File

@@ -1,39 +1,63 @@
# -*- coding: utf-8 -*-
from django.http import HttpResponse
from django.shortcuts import render_to_response, redirect, render, get_object_or_404
from django.contrib.auth import authenticate, login
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.contrib.auth.views import password_reset, password_reset_confirm
from django.core.context_processors import csrf
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.core.paginator import Paginator, InvalidPage, EmptyPage, PageNotAnInteger
from django.utils import timezone
from django.utils.text import slugify
from django.db.models import Sum
from django.conf import settings
"""
Copyright (c) 2015-2016 by Martin Bley (dev@mb-oss.de)
This file is part of TipPy.
TipPy 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.
TipPy 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 TipPy. If not, see <http://www.gnu.org/licenses/>.
"""
import os
from os.path import join as pjoin
from tipp.models import *
from tipp.forms import *
from openliga import *
from datetime import datetime
import django.shortcuts
import pytz
from PIL import Image as PImage
import urllib2, pytz, os
from django.conf import settings
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import login_required
from django.core.exceptions import ObjectDoesNotExist
from django.core.paginator import Paginator, EmptyPage, \
PageNotAnInteger
from django.db.models import Sum
from django.http import HttpResponseRedirect
from django.utils import timezone
from tipp.forms import *
from tipp.models import *
from tipp.openliga import *
timezoneLocal = pytz.timezone('Europe/Berlin')
def about(request):
return django.shortcuts.render(request, 'about.html')
@login_required
def home(request):
ls = get_current_ls()
season = get_current_season()
md = get_current_md(ls)
return redirect("matchday",
ls = ls,
season = season,
matchday=str(get_current_md(ls, season)).zfill(2)
return django.shortcuts.redirect("matchday",
ls=ls,
season=season,
matchday=str(md).zfill(2)
)
@login_required
def profile(request, pk):
user = User.objects.get(id=pk)
@@ -49,25 +73,19 @@ def profile(request, pk):
# If it's a HTTP POST, we're interested in processing form data.
if request.method == 'POST':
# Attempt to grab information from the raw form information.
# Note that we make use of both UserForm and UserProfileForm.
user_form = UserForm(data=request.POST, instance=user)
profile_form = UserProfileForm(data=request.POST, instance=profile)
profile_form = UserProfileForm(
data=request.POST, instance=profile
)
# If the two forms are valid...
if user_form.is_valid() and profile_form.is_valid():
# Save the user's form data to the database.
user = user_form.save()
# Now sort out the UserProfile instance.
# Since we need to set the user attribute ourselves, we set commit=False.
# This delays saving the model until we're ready to avoid integrity problems.
profile = profile_form.save(commit=False)
profile.user = user
# Did the user provide a profile picture?
# If so, we need to get it from the input form and put it in the UserProfile model.
if 'avatar' in request.FILES:
profile.avatar = request.FILES['avatar']
# Now we save the UserProfile model instance.
@@ -76,46 +94,109 @@ def profile(request, pk):
# create thumbnail
imfn = pjoin(settings.MEDIA_ROOT, profile.avatar.name)
im = PImage.open(imfn)
im.thumbnail((50,50), PImage.ANTIALIAS)
im.thumbnail((50, 50), PImage.ANTIALIAS)
im.save(settings.MEDIA_ROOT + profile.avatar.name)
if 'avatar-clear' in request.POST:
if 'on' in request.POST['avatar-clear']:
image = pjoin(settings.MEDIA_ROOT, img)
debug.append('Is the image ' + str(image) + ' a regular file? ' + str(os.path.isfile(image)))
debug.append('Is the image ' + str(image)
+ ' a regular file? '
+ str(os.path.isfile(image))
)
if os.path.isfile(image):
os.remove(image)
profile.save()
for item in request.POST:
debug.append(str(item) + " -> " + str(request.POST[item]))
debug.append(str(item) + " -> "
+ str(request.POST[item])
)
# Invalid form or forms - mistakes or something else?
# Print problems to the terminal.
# They'll also be shown to the user.
else:
print user_form.errors, profile_form.errors
print(
user_form.errors,
profile_form.errors
)
return redirect( '/accounts/profile/' + str(user.id) )
# Not a HTTP POST, so we render our form using two ModelForm instances.
# These forms will be blank, ready for user input.
return django.shortcuts.redirect('/accounts/profile/' + str(user.id))
# Not a HTTP POST, so we render our form using two ModelForm
# instances. These forms will be blank, ready for user input.
else:
user_form = UserForm(
initial={ 'last_name': user.last_name,
initial={'last_name': user.last_name,
'first_name': user.first_name,
'email': user.email },
'email': user.email},
instance=user
)
profile_form = UserProfileForm(instance=profile)
return render(request, 'registration/profile.html', {
return django.shortcuts.render(request, 'registration/profile.html', {
'user_form': user_form,
'profile_form': profile_form,
'debug': debug,
'img': img}
)
@staff_member_required
def staff(request):
season = get_current_season(),
""" get available competitions """
competitions = Competition.objects.filter(season=season).order_by('leagueName')
return django.shortcuts.render(request, 'staff.html', {'competitions': competitions})
@staff_member_required
def getSeason(request, ls, season):
ol = OpenLiga()
teams = ol.getTeams(str(season), ls)
season = ol.getSeason(str(season), ls)
return_vals = []
for team in teams[0]:
t = Team(
teamID=team['teamID'],
name=team['teamName'],
iconURL=team['teamIconURL']
)
"""
check if object exits and do insert if not
"""
try:
to = Team.objects.get(teamID=int(t.teamID))
if to.iconURL is None:
t.save(update_fields=['iconURL'])
except Team.DoesNotExist:
t.save()
for match in season[0]:
m = Match(matchID=match['matchID'],
matchDateTime=match['matchDateTime'],
group=int(match['groupID']),
matchday=int(match['groupOrderID']),
matchday_name=match['groupName'],
idTeam1=Team.objects.get(teamID=int(match['idTeam1'])),
idTeam2=Team.objects.get(teamID=int(match['idTeam2'])),
pointsTeam1=match['pointsTeam1'],
pointsTeam2=match['pointsTeam2'],
finished=bool(match['matchIsFinished']),
season=match['leagueSaison'],
leagueShortcut=match['leagueShortcut']
)
m.save()
return django.shortcuts.redirect("matchday",
ls=ls,
season=get_current_season(),
matchday=str(get_current_md(ls)).zfill(2)
)
@login_required
def update(request, ls, season, cur_md):
"""
@@ -124,7 +205,7 @@ def update(request, ls, season, cur_md):
"""
ol = OpenLiga()
md_matches = ol.getMatchday(str(season), int(cur_md) ,ls)
md_matches = ol.getMatchday(str(season), int(cur_md), ls)
# Achtung: DateTimeField prüfen
for match in md_matches[0]:
@@ -132,43 +213,57 @@ def update(request, ls, season, cur_md):
matchResults = match['matchResults']
try:
for result in matchResults[0]:
if result['resultName'] == "Endergebnis":
pointsTeam1=int(result['pointsTeam1'])
pointsTeam2=int(result['pointsTeam2'])
elif result['resultName'] == "Halbzeitergebnis":
pointsTeam1=int(result['pointsTeam1'])
pointsTeam2=int(result['pointsTeam2'])
except:
pointsTeam1=-1
pointsTeam2=-1
if result['resultName'] == "Halbzeit":
pointsTeam1 = int(result['pointsTeam1'])
pointsTeam2 = int(result['pointsTeam2'])
elif result['resultName'] == "Endergebnis":
pointsTeam1 = int(result['pointsTeam1'])
pointsTeam2 = int(result['pointsTeam2'])
break
elif str(result['resultName']) == u"nach Verlängerung":
pointsTeam1 = int(result['pointsTeam1'])
pointsTeam2 = int(result['pointsTeam2'])
else:
pointsTeam1 = -1
pointsTeam2 = -1
m = Match(matchID=unicode(match['matchID']),
matchDateTime=datetime.strptime(unicode(match['matchDateTime']), '%Y-%m-%d %H:%M:%S'),
group=int(match['groupID']),
matchday=int(match['groupOrderID']),
idTeam1=Team.objects.get(teamID=int(match['idTeam1'])),
idTeam2=Team.objects.get(teamID=int(match['idTeam2'])),
except:
pointsTeam1 = -1
pointsTeam2 = -1
m = Match(matchID=match['matchID'],
matchDateTime=match['matchDateTime'],
pointsTeam1=pointsTeam1,
pointsTeam2=pointsTeam2,
finished=bool(match['matchIsFinished']),
season=match['leagueSaison'],
leagueShortcut=match['leagueShortcut']
)
m.save()
pointsTeam1=-1
pointsTeam2=-1
m.save(update_fields=['matchDateTime', 'pointsTeam1', 'pointsTeam2', 'finished'])
pointsTeam1 = -1
pointsTeam2 = -1
""" evaluate scores """
scores = Score.objects.get(client=Mandant.objects.get(name='huse'))
finished_matches=Match.objects.filter(finished=True)
# evaluate scores
""" get mandants current user is related """
mandants = RelUserMandant.objects.filter(user=request.user). \
values_list('mandant', flat=True)
# scores = Score.objects.get(client=Mandant.objects.get(name='huse'))
scores = Score.objects.get(client=mandants[0])
finished_matches = Match.objects.filter(
finished=True,
leagueShortcut=ls,
season=season,
matchday=cur_md
)
for match in finished_matches:
tipps = Tipp.objects.filter(matchID=match.matchID)
for tipp in tipps:
score = 0
goals_total = match.pointsTeam1 + match.pointsTeam2
""" Tipp is acurate """
if (tipp.pointsTeam1 == match.pointsTeam1 and tipp.pointsTeam2 == match.pointsTeam2):
# Tipp is acurate
if (tipp.pointsTeam1 == match.pointsTeam1
and tipp.pointsTeam2 == match.pointsTeam2):
if goals_total >= 5:
score = scores.exact_high
else:
@@ -178,28 +273,28 @@ def update(request, ls, season, cur_md):
tipp.save()
continue
""" who won? """
# who won?
winnerReal = None
if match.pointsTeam1 > match.pointsTeam2:
winnerReal = 1
elif (match.pointsTeam2 > match.pointsTeam1):
elif match.pointsTeam2 > match.pointsTeam1:
winnerReal = 2
elif (match.pointsTeam1 == match.pointsTeam2):
elif match.pointsTeam1 == match.pointsTeam2:
winnerReal = 0
winnerTipp = None
if tipp.pointsTeam1 > tipp.pointsTeam2:
winnerTipp = 1
elif (tipp.pointsTeam2 > tipp.pointsTeam1):
elif tipp.pointsTeam2 > tipp.pointsTeam1:
winnerTipp = 2
elif (tipp.pointsTeam1 == tipp.pointsTeam2):
elif tipp.pointsTeam1 == tipp.pointsTeam2:
winnerTipp = 0
diffReal = match.pointsTeam1 - match.pointsTeam2
diffTipp = tipp.pointsTeam1 - tipp.pointsTeam2
if ( winnerTipp == winnerReal ):
if ( diffTipp == diffReal ):
if winnerTipp == winnerReal:
if diffTipp == diffReal:
score = scores.diff
else:
score = scores.tendency
@@ -212,29 +307,40 @@ def update(request, ls, season, cur_md):
tipp.save()
continue
return redirect("matchday", ls=ls, season=season, matchday=cur_md)
return django.shortcuts.redirect("matchday",
ls=ls,
season=season,
matchday=cur_md
)
@login_required
def matchday(request, ls, season, matchday, template_name='md.html'):
update(request, ls, season, matchday)
debug = ''
debug += "Debugging: "
has_refresh = True
""" get matchday closest to current date """
md_matches = Match.objects.filter(leagueShortcut=ls, season=season, matchday=int(matchday)).order_by('matchDateTime')
""" get matches of the matchday """
md_matches = Match.objects.filter(leagueShortcut=ls, season=season,
matchday=int(matchday)).order_by('matchDateTime')
""" get the current user """
user = User.objects.get(username=request.user.username)
""" get mandants current user is related """
mandants = RelUserMandant.objects.filter(user=request.user).values_list('mandant', flat=True)
mandants = RelUserMandant.objects.filter(user=request.user). \
values_list('mandant', flat=True)
""" get mates """
tipp_mates = []
mandant_dict = {}
for m in mandants:
mandant = Mandant.objects.get(id=m)
mandant_dict[mandant.description] = []
rs = RelUserMandant.objects.filter(mandant=m)
for r in rs:
tipp_mates.append({
mandant_dict[mandant.description].append({
'mate': r.user,
'tipps': [],
'sum_score': 0
@@ -251,7 +357,8 @@ def matchday(request, ls, season, matchday, template_name='md.html'):
check if Tipp already exists
"""
try:
tipp = Tipp.objects.get(tipperID=user.id,matchID=match.matchID)
tipp = Tipp.objects.get(tipperID=user.id,
matchID=match.matchID)
except ObjectDoesNotExist:
tipp = None
@@ -273,7 +380,7 @@ def matchday(request, ls, season, matchday, template_name='md.html'):
else:
""" do INSERT """
tipp = Tipp( matchID=match,
tipp = Tipp(matchID=match,
tipperID=user,
pointsTeam1=data['tippTeam1'],
pointsTeam2=data['tippTeam2'])
@@ -283,27 +390,33 @@ def matchday(request, ls, season, matchday, template_name='md.html'):
if tipp is not None:
f = TippForm(prefix=str(match.matchID),
initial={'tippTeam1': tipp.pointsTeam1, 'tippTeam2': tipp.pointsTeam2}
initial={'tippTeam1': tipp.pointsTeam1,
'tippTeam2': tipp.pointsTeam2}
)
else:
f = TippForm(prefix=str(match.matchID))
item = {}
item['matchDateTime'] = (match.matchDateTime.astimezone(timezoneLocal).strftime('%a %d.%m, %H:%M'))
item['matchDateTime'] = (match.matchDateTime.
astimezone(timezoneLocal).strftime('%a %d.%m, %H:%M'))
item['iconTeam1']= str(match.idTeam1.icon)
item['nameTeam1']= str(match.idTeam1)
item['abbrTeam1']= str(match.idTeam1.abbr)
item['iconTeam1'] = str(match.idTeam1.icon)
item['iconURLTeam1'] = str(match.idTeam1.iconURL)
item['nameTeam1'] = str(match.idTeam1.name)
item['abbrTeam1'] = str(match.idTeam1.abbr)
item['iconTeam2'] = str(match.idTeam2.icon)
item['nameTeam2'] = str(match.idTeam2)
item['abbrTeam2']= str(match.idTeam2.abbr)
item['iconURLTeam2'] = str(match.idTeam2.iconURL)
item['nameTeam2'] = str(match.idTeam2.name)
item['abbrTeam2'] = str(match.idTeam2.abbr)
item['started'] = match_started
item['finished'] = match.finished
item['md_name'] = match.matchday_name
if (match.pointsTeam1 == -1 or match.pointsTeam2 == -1):
item['matchResult'] = "-:-"
else:
item['matchResult'] = str(match.pointsTeam1) + ":" + str(match.pointsTeam2)
item['matchResult'] = str(match.pointsTeam1) + ":" \
+ str(match.pointsTeam2)
item['tippFormTeam1'] = f['tippTeam1']
item['tippFormTeam2'] = f['tippTeam2']
@@ -312,11 +425,21 @@ def matchday(request, ls, season, matchday, template_name='md.html'):
f.fields['tippTeam1'].widget.attrs['disabled'] = True
f.fields['tippTeam2'].widget.attrs['disabled'] = True
for mate in tipp_mates:
""" get tipps from mates """
for mandant in mandant_dict:
for mate in mandant_dict[mandant]:
try:
matetipp = Tipp.objects.get(tipperID=mate['mate'],matchID=match.matchID)
matetipp = Tipp.objects.get(tipperID=mate['mate'],
matchID=match.matchID)
if match_started is True:
mate['tipps'].append(str(matetipp.pointsTeam1) + ":" + str(matetipp.pointsTeam2) + "(" + str(matetipp.score) + ")")
if matetipp.score is None:
score = u'\u231B'
else:
score = matetipp.score
mate['tipps'].append(str(matetipp.pointsTeam1)
+ ":" + str(matetipp.pointsTeam2)
+ "(" + str(score) + ")")
if match.finished is True:
mate['sum_score'] += matetipp.score
else:
@@ -324,50 +447,74 @@ def matchday(request, ls, season, matchday, template_name='md.html'):
except Exception as e:
mate['tipps'].append(u'\u2717')
""" sort items in mandant_dict by score """
mandant_dict[mandant] = sorted(mandant_dict[mandant],
key=lambda k: k['sum_score'], reverse=True)
matches.append(item)
# get the newest blogposts
pm = RelPostMandant.objects.filter(mandant__in=mandants). \
values_list('post', flat=True)
posts = []
for post in Post.objects.filter(published=True)[:2]:
for post in Post.objects.filter(id__in=pm, published=True)[:5]:
try:
avatar = UserProfile.objects.get(user_id=post.author_id).avatar.name
avatar = UserProfile.objects.get(user_id=post.author_id). \
avatar.name
except:
avatar = None
posts.append( (post, avatar) )
posts.append((post, avatar))
return render(request, 'md.html', {
#'debug': debug,
#'mds_season': mds_in_season,
try:
cur_group = matches[0]['md_name']
except:
cur_group = "N/A"
debug += str(mandant_dict)
return django.shortcuts.render(request, 'md.html', {
'debug': debug,
# 'mds_season': mds_in_season,
'cur_md': matchday,
'md_name': cur_group,
'matches': matches,
'ls': ls,
'season': season,
'username': user,
'tipp_mates': sorted(tipp_mates, key=lambda k: k['sum_score'], reverse=True),
'mandant_dict': mandant_dict,
# 'tipp_mates': sorted(tipp_mates, key=lambda k: k['sum_score'],
# reverse=True),
'posts': posts,
'has_refresh': has_refresh
})
@login_required
def charts(request, ls, season, pos='default', template_name='charts.html'):
def charts(request, ls, season, pos='default',
template_name='charts.html'):
debug = ''
if pos == 'default':
if get_current_md(ls, season) < 18:
if get_current_md(ls) < 18:
pos = 'hin'
matches = Match.objects.filter(leagueShortcut=ls, season=season, matchday__lte=17)
matches = Match.objects.filter(leagueShortcut=ls,
season=season, matchday__lte=17)
else:
pos = 'rueck'
matches = Match.objects.filter(leagueShortcut=ls, season=season, matchday__gte=18)
matches = Match.objects.filter(leagueShortcut=ls,
season=season, matchday__gte=18)
elif pos == 'hin':
matches = Match.objects.filter(leagueShortcut=ls, season=season, matchday__lte=17)
matches = Match.objects.filter(leagueShortcut=ls,
season=season, matchday__lte=17)
elif pos == 'rueck':
matches = Match.objects.filter(leagueShortcut=ls, season=season, matchday__gte=18)
matches = Match.objects.filter(leagueShortcut=ls,
season=season, matchday__gte=18)
else:
matches = Match.objects.filter(leagueShortcut=ls, season=season)
# get mandants of current user
mandants = RelUserMandant.objects.filter(user=request.user).values_list('mandant', flat=True)
mandants = RelUserMandant.objects.filter(user=request.user). \
values_list('mandant', flat=True)
# main loop
mandant_dict = {}
@@ -375,20 +522,26 @@ def charts(request, ls, season, pos='default', template_name='charts.html'):
mandant = Mandant.objects.get(id=m)
# get users
users = RelUserMandant.objects.filter(mandant=m).values_list('user', flat=True)
users = RelUserMandant.objects.filter(mandant=m). \
values_list('user', flat=True)
user_dict = {}
for userid in users:
# get user object, then fetch matches for user
user = User.objects.get(id=userid)
score = Tipp.objects.filter(matchID__in=matches, tipperID=user).aggregate(Sum('score'))
score = Tipp.objects.filter(matchID__in=matches,
tipperID=user).aggregate(Sum('score'))
if score['score__sum'] is None:
user_dict[user.first_name] = 0
else:
user_dict[user.first_name] = score['score__sum']
mandant_dict[mandant.name] = sorted(user_dict.items(), key=lambda x: x[1], reverse=True)
mandant_dict[mandant.name] = sorted(user_dict.items(),
key=lambda x: x[1], reverse=True)
return render(request, template_name, {
#'debug': debug,
return django.shortcuts.render(request, template_name, {
# 'debug': debug,
'mandant_dict': mandant_dict,
'season': season,
'ls': ls,
@@ -399,73 +552,91 @@ def charts(request, ls, season, pos='default', template_name='charts.html'):
@login_required
def blogindex(request, page):
# get the blog posts that are published
# and related to mandant
mandants = RelUserMandant.objects.filter(user=request.user). \
values_list('mandant', flat=True)
posts = RelPostMandant.objects.filter(mandant__in=mandants). \
values_list('post', flat=True)
post_list = []
for post in Post.objects.filter(published=True):
for post in Post.objects.filter(published=True, id__in=posts):
try:
avatar = UserProfile.objects.get(user_id=post.author_id).avatar.name
avatar = UserProfile.objects.get(user_id=post.author_id). \
avatar.name
except:
avatar = None
post_list.append( (post, avatar) )
post_list.append((post, avatar))
p = Paginator(post_list, 5)
try:
posts = p.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
posts = p.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
posts = p.page(p.num_pages)
# now return the rendered template
return render(request, 'blogindex.html', {
return django.shortcuts.render(request, 'blogindex.html', {
'posts': posts,
'ls': get_current_ls(),
'season': get_current_season(),
'page': page
})
@login_required
def blogpost(request, slug):
# get the Post object
post = get_object_or_404(Post, slug=slug)
# now return the rendered template
return render(request, 'blogpost.html', {
'post': post,
'ls': get_current_ls(),
'season': get_current_season()
})
@login_required
def newBlogpost(request):
"""
if this is a POST request we need to process the form data
"""
debug = ''
has_mandant = False
mandants = RelUserMandant.objects.filter(user=request.user). \
values_list('mandant', flat=True)
choices = []
if mandants.count() > 1:
has_mandant = True
for m in Mandant.objects.filter(id__in=mandants):
choices.append((m.name, m.description))
if request.method == 'POST':
# create form instance and populate it with data from the request
form = BlogpostForm(request.POST)
# check whether it's valid:
if form.is_valid():
# process the data
data = form.cleaned_data
slug = slugify(data['title'])
p = Post(author_id=request.user.id, slug=slug, title=data['title'], content=data['content'])
form_bp = BlogpostForm(request.POST)
if has_mandant is True:
form_mandant = MandantsForm(request.POST)
form_mandant.fields["mandants"].choices = choices
if form_bp.is_valid():
data = form_bp.cleaned_data
p = Post(author_id=request.user.id, content=data['content'])
p.save()
# ...
# redirect to a new URL:
return redirect( '/blog/1')
# if a GET (or any other method) we'll create a blank form
if has_mandant is True and form_mandant.is_valid():
data = form_mandant.cleaned_data
for m in data['mandants']:
debug += str(m) + " "
m = RelPostMandant(post=p,
mandant=Mandant.objects.get(name=m))
m.save()
else:
m = RelPostMandant(post=p,
mandant=Mandant.objects.get(id=mandants[0]))
m.save()
return django.shortcuts.redirect('/blog/1')
blogpostForm = BlogpostForm()
return render(request, 'newblogpost.html', {
'form': blogpostForm,
form_mandant = MandantsForm()
form_mandant.fields["mandants"].choices = choices
cnt_mandants = len(choices)
return django.shortcuts.render(request, 'newblogpost.html', {
'debug': debug,
'form_bp': blogpostForm,
'form_mandants': form_mandant,
'cnt_mandants': cnt_mandants,
'ls': get_current_ls(),
'season': get_current_season()
})
def logout(request):
"""
Log users out and re-direct them to the main page.
@@ -473,14 +644,28 @@ def logout(request):
logout(request)
return HttpResponseRedirect('/')
def get_current_md(ls,season):
""" get current matchday """
current_md = Match.objects.filter(leagueShortcut=ls, season=season, finished=False).order_by('matchday').values_list('matchday', flat=True).distinct()[0]
return(current_md)
def get_current_md(ls):
"""
get current matchday()
returns dict with keys
['groupName']
['groupOrderID']
['groupID']
"""
try:
ol = OpenLiga()
cur_md = ol.getCurrentGroup(ls)
except:
cur_md = {'groupName': u"1. Spieltag", 'groupOrderID': 1}
return (cur_md['groupOrderID'])
def get_current_ls():
return("bl1")
return ("bl1")
def get_current_season():
return("2015")
return ("2022")

View File

@@ -1,188 +0,0 @@
"""
Django settings for tippy project.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Django settings for tippy project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
('Martin Bley', 'martin@mb-oss.de'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django_tippy',
'USER': 'tippy',
'PASSWORD': 'tippy',
'HOST': 'localhost',
'PORT': '5432',
}
}
# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.4/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ['*']
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'Europe/Berlin'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'de-de'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
#STATIC_ROOT = '/opt/TipPy/TipPy/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'static/')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
#'/opt/TipPy/TipPy/tipp/static/',
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = '-7%ge^nl1b0t0694%ws&amp;0$ft_lo)j4l1f-qv#ku^=$)s(sw6us'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'tippy.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'tippy.wsgi.application'
TEMPLATE_DIRS = (
[os.path.join(BASE_DIR, 'templates')]
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'tipp',
)
# URL of the login page.
LOGIN_URL = '/login'
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
EMAIL_USE_TLS = True
EMAIL_HOST = 'hermes.mb-oss.de'
EMAIL_PORT = 25
EMAIL_HOST_USER = 'tippy@mb-oss.de'
#EMAIL_HOST_PASSWORD = 'p@ssword'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
SESSION_COOKIE_AGE = 7200
AUTH_PROFILE_MODULE = 'tippy.UserProfile'

View File

@@ -1,37 +0,0 @@
from django.conf.urls import patterns, include, url
from django.conf import settings
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
url(r'^$', 'tipp.views.home', name='home'),
url(r'^login$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}),
url(r'^logout$', 'django.contrib.auth.views.logout', {'next_page': '/'}),
url(r'^update/(?P<ls>.*)/(?P<season>\d{4})/(?P<cur_md>\d{2})$', 'tipp.views.update', name='update'),
url(r'^matchday/(?P<ls>.{3,})/(?P<season>\d{4})/(?P<matchday>\d{2})$', 'tipp.views.matchday', name='matchday'),
url(r'^charts/(?P<ls>\w{3,})/(?P<season>\d{4})$', 'tipp.views.charts', name='charts'),
url(r'^charts/(?P<ls>\w{3,})/(?P<season>\d{4})/(?P<pos>\w{1,})$', 'tipp.views.charts', name='charts'),
url(r'^accounts/profile/(\d+)', 'tipp.views.profile'),
url(r'^accounts/', include('django.contrib.auth.urls')),
url(r'^blog/newpost$', 'tipp.views.newBlogpost'),
url(r'^blog/(?P<page>\d)$', 'tipp.views.blogindex'),
url(r'^blog/(?P<slug>[\w\-]+)', 'tipp.views.blogpost'),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
if settings.DEBUG:
urlpatterns += patterns('',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT,
}),
)

View File

@@ -1,28 +0,0 @@
"""
WSGI config for tippy project.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tippy.settings")
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)