Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
0b068d3e
Commit
0b068d3e
authored
Oct 26, 2016
by
Skia
Browse files
Improve file moderation
parent
9e328405
Pipeline
#422
passed with stage
in 2 minutes and 18 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
14 deletions
+32
-14
core/management/commands/populate.py
core/management/commands/populate.py
+9
-0
core/models.py
core/models.py
+7
-1
core/views/files.py
core/views/files.py
+2
-2
sith/settings.py
sith/settings.py
+14
-11
No files found.
core/management/commands/populate.py
View file @
0b068d3e
...
...
@@ -45,6 +45,7 @@ class Command(BaseCommand):
home_root
.
save
()
club_root
=
SithFile
(
parent
=
None
,
name
=
"clubs"
,
is_folder
=
True
,
owner
=
root
)
club_root
.
save
()
SithFile
(
parent
=
None
,
name
=
"SAS"
,
is_folder
=
True
,
owner
=
root
).
save
()
main_club
=
Club
(
id
=
1
,
name
=
settings
.
SITH_MAIN_CLUB
[
'name'
],
unix_name
=
settings
.
SITH_MAIN_CLUB
[
'unix_name'
],
address
=
settings
.
SITH_MAIN_CLUB
[
'address'
])
main_club
.
save
()
...
...
@@ -191,6 +192,14 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
PageRev
(
page
=
p
,
title
=
"README"
,
author
=
skia
,
content
=
rm
.
read
()).
save
()
# Subscription
## Root
s
=
Subscription
(
member
=
Subscriber
.
objects
.
filter
(
pk
=
root
.
pk
).
first
(),
subscription_type
=
list
(
settings
.
SITH_SUBSCRIPTIONS
.
keys
())[
0
],
payment_method
=
settings
.
SITH_SUBSCRIPTION_PAYMENT_METHOD
[
0
])
s
.
subscription_start
=
s
.
compute_start
()
s
.
subscription_end
=
s
.
compute_end
(
duration
=
settings
.
SITH_SUBSCRIPTIONS
[
s
.
subscription_type
][
'duration'
],
start
=
s
.
subscription_start
)
s
.
save
()
## Skia
s
=
Subscription
(
member
=
Subscriber
.
objects
.
filter
(
pk
=
skia
.
pk
).
first
(),
subscription_type
=
list
(
settings
.
SITH_SUBSCRIPTIONS
.
keys
())[
0
],
payment_method
=
settings
.
SITH_SUBSCRIPTION_PAYMENT_METHOD
[
0
])
...
...
core/models.py
View file @
0b068d3e
...
...
@@ -195,7 +195,13 @@ class User(AbstractBaseUser):
return
self
.
__dict__
def
is_in_group
(
self
,
group_name
):
"""If the user is in the group passed in argument (as string)"""
"""If the user is in the group passed in argument (as string or by id)"""
if
isinstance
(
group_name
,
int
):
# Handle the case where group_name is an ID
g
=
Group
.
objects
.
filter
(
id
=
group_name
).
first
()
if
g
:
group_name
=
g
.
name
else
:
return
False
if
group_name
==
settings
.
SITH_GROUPS
[
'public'
][
'name'
]:
return
True
if
group_name
==
settings
.
SITH_MAIN_MEMBERS_GROUP
:
# We check the subscription if asked
...
...
core/views/files.py
View file @
0b068d3e
...
...
@@ -19,13 +19,13 @@ import os
from
core.models
import
SithFile
from
core.views
import
CanViewMixin
,
CanEditMixin
,
CanEditPropMixin
,
CanCreateMixin
,
can_view
,
not_found
def
send_file
(
request
,
file_id
):
def
send_file
(
request
,
file_id
,
file_class
=
SithFile
):
"""
Send a file through Django without loading the whole file into
memory at once. The FileWrapper will turn the file object into an
iterator for chunks of 8KB.
"""
f
=
SithFile
.
objects
.
filter
(
id
=
file_id
).
first
()
f
=
file_class
.
objects
.
filter
(
id
=
file_id
).
first
()
if
f
is
None
or
f
.
is_folder
:
return
not_found
(
request
)
from
counter.models
import
Counter
...
...
sith/settings.py
View file @
0b068d3e
...
...
@@ -203,6 +203,19 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_HOST
=
"localhost"
EMAIL_PORT
=
25
# Below this line, only Sith-specific variables are defined
IS_OLD_MYSQL_PRESENT
=
False
OLD_MYSQL_INFOS
=
{
'host'
:
'ae-db'
,
'user'
:
"my_user"
,
'passwd'
:
"password"
,
'db'
:
"ae2-db"
,
'charset'
:
'utf8'
,
'use_unicode'
:
True
,
}
SITH_URL
=
"my.url.git.an"
SITH_NAME
=
"Sith website"
...
...
@@ -413,7 +426,7 @@ SITH_BARMAN_TIMEOUT=20
SITH_LAST_OPERATIONS_LIMIT
=
5
# Minutes for a counter to be inactive
SITH_COUNTER_MINUTE_INACTIVE
=
10
SITH_COUNTER_MINUTE_INACTIVE
=
10
# ET variables
SITH_EBOUTIC_ET_URL
=
"https://preprod-tpeweb.e-transactions.fr/cgi/MYchoix_pagepaiement.cgi"
...
...
@@ -432,16 +445,6 @@ SITH_LAUNDERETTE_PRICES = {
'DRYING'
:
0.75
,
}
IS_OLD_MYSQL_PRESENT
=
False
OLD_MYSQL_INFOS
=
{
'host'
:
'ae-db'
,
'user'
:
"my_user"
,
'passwd'
:
"password"
,
'db'
:
"ae2-db"
,
'charset'
:
'utf8'
,
'use_unicode'
:
True
,
}
try
:
from
.settings_custom
import
*
print
(
"Custom settings imported"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment