Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.web
Commits
d0206315
Commit
d0206315
authored
Oct 19, 2017
by
Philip ABBET
Browse files
Force 4-spaces indentation
parent
82f40e73
Pipeline
#13269
canceled with stage
Changes
166
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
beat/web/accounts/api.py
View file @
d0206315
...
...
@@ -393,7 +393,7 @@ class SuperviseeAddGodfatherView(BaseCreateSupervisionTrackViewSupervisee):
supervisee
=
supervisee
,
godfather
=
godfather
,
is_valid
=
False
,
)
)
#Assign key to supervision track
supervisiontrack
.
supervision_key
=
supervisee
.
profile
.
supervision_key
...
...
beat/web/accounts/forms.py
View file @
d0206315
...
...
@@ -36,4 +36,4 @@ class AccountSettingsForm(ModelForm):
'experiment_mail_notifications_enabled'
,
'database_notifications_enabled'
,
'environment_notifications_enabled'
,
]
]
beat/web/accounts/management/commands/block_rejected_users.py
View file @
d0206315
...
...
@@ -48,7 +48,7 @@ class Command(BaseCommand):
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'--noinput'
,
action
=
'store_false'
,
dest
=
'interactive'
,
default
=
False
,
help
=
(
'Tells Django to NOT prompt the user for input of any kind.'
))
help
=
(
'Tells Django to NOT prompt the user for input of any kind.'
))
def
handle
(
self
,
*
args
,
**
options
):
...
...
beat/web/accounts/management/commands/clean_blocked_users_expired_requests.py
View file @
d0206315
...
...
@@ -48,7 +48,7 @@ class Command(BaseCommand):
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'--noinput'
,
action
=
'store_false'
,
dest
=
'interactive'
,
default
=
False
,
help
=
(
'Tells Django to NOT prompt the user for input of any kind.'
))
help
=
(
'Tells Django to NOT prompt the user for input of any kind.'
))
def
handle
(
self
,
*
args
,
**
options
):
...
...
beat/web/accounts/management/commands/clean_invalid_users.py
View file @
d0206315
...
...
@@ -48,7 +48,7 @@ class Command(BaseCommand):
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'--noinput'
,
action
=
'store_false'
,
dest
=
'interactive'
,
default
=
False
,
help
=
(
'Tells Django to NOT prompt the user for input of any kind.'
))
help
=
(
'Tells Django to NOT prompt the user for input of any kind.'
))
def
handle
(
self
,
*
args
,
**
options
):
...
...
beat/web/accounts/management/commands/year_revalidation_users.py
View file @
d0206315
...
...
@@ -53,7 +53,7 @@ class Command(BaseCommand):
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'--noinput'
,
action
=
'store_false'
,
dest
=
'interactive'
,
default
=
False
,
help
=
(
'Tells Django to NOT prompt the user for input of any kind.'
))
help
=
(
'Tells Django to NOT prompt the user for input of any kind.'
))
def
handle
(
self
,
*
args
,
**
options
):
...
...
beat/web/accounts/models.py
View file @
d0206315
...
...
@@ -51,9 +51,9 @@ class SupervisionTrack(models.Model):
#_____ Fields __________
supervisee
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
,
related_name
=
'supervisors'
)
related_name
=
'supervisors'
)
godfather
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
,
related_name
=
'supervisees'
)
related_name
=
'supervisees'
)
is_valid
=
models
.
BooleanField
(
default
=
False
)
start_date
=
models
.
DateTimeField
(
null
=
True
,
blank
=
True
)
expiration_date
=
models
.
DateTimeField
(
null
=
True
,
blank
=
True
)
...
...
@@ -105,7 +105,7 @@ class Profile(models.Model):
def
_generate_current_supervision_key
(
self
):
length
=
40
return
''
.
join
(
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
for
_
in
range
(
length
))
in
range
(
length
))
@
receiver
(
post_save
,
sender
=
User
)
def
create_user_profile
(
sender
,
instance
,
created
,
**
kwargs
):
...
...
beat/web/accounts/tests.py
View file @
d0206315
...
...
@@ -99,7 +99,7 @@ class AccountTestCase(APITestCase):
start_date
=
now
,
expiration_date
=
now
+
expiration_date_delta
,
last_validation_date
=
now
)
)
#Assign key to supervision track
supervisiontrack
.
supervision_key
=
self
.
accepteduser
.
profile
.
supervision_key
...
...
@@ -125,7 +125,7 @@ class AccountTestCase(APITestCase):
start_date
=
now
,
expiration_date
=
now
+
expiration_date_delta
,
last_validation_date
=
now
)
)
#Assign key to supervision track
supervisiontrack
.
supervision_key
=
self
.
yearrevalidationuser
.
profile
.
supervision_key
...
...
beat/web/algorithms/admin.py
View file @
d0206315
...
...
@@ -31,7 +31,7 @@ from django.core.files.base import ContentFile
from
django.utils
import
six
from
..ui.forms
import
CodeMirrorPythonFileField
,
CodeMirrorRSTFileField
,
\
CodeMirrorJSONFileField
,
CodeMirrorJSONCharField
CodeMirrorJSONFileField
,
CodeMirrorJSONCharField
from
..common.texts
import
Messages
...
...
@@ -50,45 +50,45 @@ import simplejson as json
class
AlgorithmModelForm
(
forms
.
ModelForm
):
name
=
NameField
(
widget
=
forms
.
TextInput
(
attrs
=
dict
(
size
=
80
)),
help_text
=
Messages
[
'algo_name'
],
)
widget
=
forms
.
TextInput
(
attrs
=
dict
(
size
=
80
)),
help_text
=
Messages
[
'algo_name'
],
)
declaration_file
=
CodeMirrorJSONFileField
(
label
=
'Declaration'
,
help_text
=
Messages
[
'json'
],
)
label
=
'Declaration'
,
help_text
=
Messages
[
'json'
],
)
source_code_file
=
CodeMirrorPythonFileField
(
label
=
'Source code'
,
help_text
=
Messages
[
'code'
],
)
label
=
'Source code'
,
help_text
=
Messages
[
'code'
],
)
description_file
=
CodeMirrorRSTFileField
(
label
=
'Description'
,
required
=
False
,
allow_empty_file
=
True
,
help_text
=
Messages
[
'description'
],
)
label
=
'Description'
,
required
=
False
,
allow_empty_file
=
True
,
help_text
=
Messages
[
'description'
],
)
parameters
=
CodeMirrorJSONCharField
(
readonly
=
True
,
required
=
False
,
)
readonly
=
True
,
required
=
False
,
)
result_dataformat
=
CodeMirrorJSONCharField
(
readonly
=
True
,
required
=
False
,
)
readonly
=
True
,
required
=
False
,
)
class
Meta
:
model
=
AlgorithmModel
exclude
=
[]
widgets
=
{
'short_description'
:
forms
.
TextInput
(
attrs
=
dict
(
size
=
100
),
),
}
'short_description'
:
forms
.
TextInput
(
attrs
=
dict
(
size
=
100
),
),
}
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -156,7 +156,7 @@ rehash_algorithm.short_description = 'Rehash selected algorithms'
class
Algorithm
(
admin
.
ModelAdmin
):
list_display
=
(
'id'
,
'id'
,
'author'
,
'name'
,
'version'
,
...
...
@@ -168,17 +168,17 @@ class Algorithm(admin.ModelAdmin):
'fork_of'
,
'sharing'
,
'hash'
)
)
search_fields
=
[
'author__username'
,
'author__username'
,
'name'
,
'short_description'
,
'previous_version__author__username'
,
'previous_version__name'
,
'fork_of__author__username'
,
'fork_of__name'
]
]
list_filter
=
(
'sharing'
,
)
list_display_links
=
(
'id'
,
'name'
)
readonly_fields
=
(
'hash'
,
'splittable'
,
'short_description'
)
...
...
@@ -189,7 +189,7 @@ class Algorithm(admin.ModelAdmin):
actions
=
[
rehash_algorithm
,
]
]
form
=
AlgorithmModelForm
...
...
@@ -203,40 +203,40 @@ class Algorithm(admin.ModelAdmin):
fieldsets
=
(
(
None
,
dict
(
fields
=
(
'name'
,
'author'
,),
),
dict
(
fields
=
(
'name'
,
'author'
,),
),
),
(
'Documentation'
,
dict
(
classes
=
(
'collapse'
,),
fields
=
(
'short_description'
,
'description_file'
,),
),
dict
(
classes
=
(
'collapse'
,),
fields
=
(
'short_description'
,
'description_file'
,),
),
),
(
'Versioning'
,
dict
(
classes
=
(
'collapse'
,),
fields
=
(
'version'
,
'previous_version'
,
'fork_of'
),
),
dict
(
classes
=
(
'collapse'
,),
fields
=
(
'version'
,
'previous_version'
,
'fork_of'
),
),
),
(
'Sharing'
,
dict
(
classes
=
(
'collapse'
,),
fields
=
(
'sharing'
,
'shared_with'
,
'shared_with_team'
,
'usable_by'
,
'usable_by_team'
),
),
dict
(
classes
=
(
'collapse'
,),
fields
=
(
'sharing'
,
'shared_with'
,
'shared_with_team'
,
'usable_by'
,
'usable_by_team'
),
),
),
(
'Cached Information (read-only)'
,
dict
(
classes
=
(
'collapse'
,),
fields
=
(
'parameters'
,
'result_dataformat'
,
'referenced_libraries'
),
),
dict
(
classes
=
(
'collapse'
,),
fields
=
(
'parameters'
,
'result_dataformat'
,
'referenced_libraries'
),
),
),
(
'Definition'
,
dict
(
fields
=
(
'hash'
,
'splittable'
,
'declaration_file'
,
'language'
,
'source_code_file'
),
),
dict
(
fields
=
(
'hash'
,
'splittable'
,
'declaration_file'
,
'language'
,
'source_code_file'
),
),
),
)
)
def
get_form
(
self
,
request
,
obj
=
None
,
**
kwargs
):
if
obj
.
is_binary
():
...
...
beat/web/algorithms/api.py
View file @
d0206315
...
...
@@ -43,7 +43,7 @@ from ..code.api import ShareCodeView, RetrieveUpdateDestroyCodeView
from
..code.serializers
import
CodeDiffSerializer
from
..common.api
import
(
CheckContributionNameView
,
ListContributionView
,
ListCreateContributionView
)
ListCreateContributionView
)
from
..code.api
import
DiffView
...
...
@@ -112,7 +112,7 @@ class RetrieveUpdateDestroyAlgorithmsView(RetrieveUpdateDestroyCodeView):
if
modified
:
# Delete existing experiments using the algorithm (code changed)
experiments
=
list
(
set
(
map
(
lambda
x
:
x
.
experiment
,
algorithm
.
blocks
.
iterator
())))
algorithm
.
blocks
.
iterator
())))
for
experiment
in
experiments
:
experiment
.
delete
()
return
modified
,
algorithm
...
...
@@ -142,14 +142,14 @@ def binary(request, author_name, object_name, version=None):
# Retrieves the algorithm
if
version
:
algorithm
=
get_object_or_404
(
Algorithm
,
author__username__iexact
=
author_name
,
name__iexact
=
object_name
,
version
=
int
(
version
),
)
Algorithm
,
author__username__iexact
=
author_name
,
name__iexact
=
object_name
,
version
=
int
(
version
),
)
else
:
algorithm
=
Algorithm
.
objects
.
filter
(
author__username__iexact
=
author_name
,
name__iexact
=
object_name
).
order_by
(
'-version'
)
name__iexact
=
object_name
).
order_by
(
'-version'
)
if
not
algorithm
:
raise
Http404
()
else
:
...
...
beat/web/algorithms/api_urls.py
View file @
d0206315
...
...
@@ -31,49 +31,49 @@ import api
urlpatterns
=
[
url
(
r
'^$'
,
api
.
ListAlgorithmsView
.
as_view
(),
name
=
'all'
,
url
(
r
'^$'
,
api
.
ListAlgorithmsView
.
as_view
(),
name
=
'all'
,
),
url
(
r
'^check_name/$'
,
api
.
CheckAlgorithmNameView
.
as_view
(),
name
=
'check_name'
,
url
(
r
'^check_name/$'
,
api
.
CheckAlgorithmNameView
.
as_view
(),
name
=
'check_name'
,
),
url
(
r
'^diff/(?P<author1>\w+)/(?P<name1>[-\w]+)/(?P<version1>\d+)/(?P<author2>\w+)/(?P<name2>[-\w]+)/(?P<version2>\d+)/$'
,
api
.
DiffAlgorithmView
.
as_view
(),
name
=
'diff'
,
url
(
r
'^diff/(?P<author1>\w+)/(?P<name1>[-\w]+)/(?P<version1>\d+)/(?P<author2>\w+)/(?P<name2>[-\w]+)/(?P<version2>\d+)/$'
,
api
.
DiffAlgorithmView
.
as_view
(),
name
=
'diff'
,
),
url
(
r
'^(?P<author_name>\w+)/(?P<object_name>[-\w]+)/(?P<version>\d+)/share/$'
,
api
.
ShareAlgorithmView
.
as_view
(),
name
=
'share'
,
url
(
r
'^(?P<author_name>\w+)/(?P<object_name>[-\w]+)/(?P<version>\d+)/share/$'
,
api
.
ShareAlgorithmView
.
as_view
(),
name
=
'share'
,
),
url
(
r
'^(?P<author_name>\w+)/$'
,
api
.
ListCreateAlgorithmsView
.
as_view
(),
name
=
'list_create'
,
url
(
r
'^(?P<author_name>\w+)/$'
,
api
.
ListCreateAlgorithmsView
.
as_view
(),
name
=
'list_create'
,
),
url
(
r
'^(?P<author_name>\w+)/(?P<object_name>[-\w]+)/(?P<version>\d+)/$'
,
api
.
RetrieveUpdateDestroyAlgorithmsView
.
as_view
(),
name
=
'object'
,
url
(
r
'^(?P<author_name>\w+)/(?P<object_name>[-\w]+)/(?P<version>\d+)/$'
,
api
.
RetrieveUpdateDestroyAlgorithmsView
.
as_view
(),
name
=
'object'
,
),
url
(
r
'^(?P<author_name>\w+)/(?P<object_name>[-\w]+)/$'
,
api
.
RetrieveUpdateDestroyAlgorithmsView
.
as_view
(),
name
=
'object'
,
url
(
r
'^(?P<author_name>\w+)/(?P<object_name>[-\w]+)/$'
,
api
.
RetrieveUpdateDestroyAlgorithmsView
.
as_view
(),
name
=
'object'
,
),
url
(
r
'^(?P<author_name>\w+)/(?P<object_name>[-\w]+)/(?P<version>\d+)/binary/$'
,
api
.
binary
,
name
=
'binary'
,
url
(
r
'^(?P<author_name>\w+)/(?P<object_name>[-\w]+)/(?P<version>\d+)/binary/$'
,
api
.
binary
,
name
=
'binary'
,
),
url
(
r
'^(?P<author_name>\w+)/(?P<object_name>[-\w]+)/binary/$'
,
api
.
binary
,
name
=
'binary'
,
url
(
r
'^(?P<author_name>\w+)/(?P<object_name>[-\w]+)/binary/$'
,
api
.
binary
,
name
=
'binary'
,
),
]
]
beat/web/algorithms/apps.py
View file @
d0206315
...
...
@@ -36,7 +36,7 @@ class AlgorithmsConfig(CommonAppConfig):
super
(
AlgorithmsConfig
,
self
).
ready
()
from
.signals
import
(
create_endpoints
,
delete_endpoints
,
auto_delete_file_on_delete
,
auto_delete_file_on_change
)
auto_delete_file_on_delete
,
auto_delete_file_on_change
)
from
actstream
import
registry
registry
.
register
(
self
.
get_model
(
'Algorithm'
))
beat/web/algorithms/models.py
View file @
d0206315
...
...
@@ -111,35 +111,35 @@ class Algorithm(Code):
#_____ Fields __________
declaration_file
=
models
.
FileField
(
storage
=
AlgorithmStorage
(),
upload_to
=
get_contribution_declaration_filename
,
blank
=
True
,
null
=
True
,
max_length
=
200
,
db_column
=
'declaration'
)
storage
=
AlgorithmStorage
(),
upload_to
=
get_contribution_declaration_filename
,
blank
=
True
,
null
=
True
,
max_length
=
200
,
db_column
=
'declaration'
)
description_file
=
models
.
FileField
(
storage
=
AlgorithmStorage
(),
upload_to
=
get_contribution_description_filename
,
blank
=
True
,
null
=
True
,
max_length
=
200
,
db_column
=
'description'
)
storage
=
AlgorithmStorage
(),
upload_to
=
get_contribution_description_filename
,
blank
=
True
,
null
=
True
,
max_length
=
200
,
db_column
=
'description'
)
source_code_file
=
models
.
FileField
(
storage
=
AlgorithmStorage
(),
upload_to
=
get_contribution_source_code_filename
,
blank
=
True
,
null
=
True
,
max_length
=
200
,
db_column
=
'source_code'
)
storage
=
AlgorithmStorage
(),
upload_to
=
get_contribution_source_code_filename
,
blank
=
True
,
null
=
True
,
max_length
=
200
,
db_column
=
'source_code'
)
# Read-only parameters that are updated at every save(), if required
parameters
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
result_dataformat
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
splittable
=
models
.
BooleanField
(
default
=
False
,
help_text
=
'Defines if the code can be executed '
\
'in multiple instances'
)
'in multiple instances'
)
referenced_libraries
=
models
.
ManyToManyField
(
Library
,
blank
=
True
,
related_name
=
'used_by_algorithms'
,
...
...
@@ -153,27 +153,27 @@ class Algorithm(Code):
def
get_absolute_url
(
self
):
return
reverse
(
'algorithms:view'
,
'algorithms:view'
,
args
=
(
self
.
author
.
username
,
self
.
name
,
self
.
version
,),
)
)
def
get_api_update_url
(
self
):
'''Returns the endpoint to update this object'''
return
reverse
(
'api_algorithms:object'
,
'api_algorithms:object'
,
args
=
(
self
.
author
.
username
,
self
.
name
,
self
.
version
,),
)
)
def
get_api_share_url
(
self
):
'''Returns the endpoint to share this object'''
return
reverse
(
'api_algorithms:share'
,
'api_algorithms:share'
,
args
=
(
self
.
author
.
username
,
self
.
name
,
self
.
version
,),
)
)
def
environments
(
self
):
...
...
@@ -202,7 +202,7 @@ class Algorithm(Code):
envs
=
Environment
.
objects
.
filter
(
blocks__in
=
self
.
blocks
.
filter
(
Q
(
experiment__status
=
Experiment
.
DONE
)
|
\
((
~
Q
(
experiment__status
=
Experiment
.
DONE
))
&
Q
(
status
=
Block
.
DONE
))
)).
annotate
(
itemcount
=
Count
(
'id'
)).
order_by
(
'-creation_date'
).
distinct
()
)).
annotate
(
itemcount
=
Count
(
'id'
)).
order_by
(
'-creation_date'
).
distinct
()
return
[(
k
,
k
.
itemcount
)
for
k
in
envs
]
...
...
@@ -222,7 +222,7 @@ class Algorithm(Code):
"default_value"
:
details
.
get
(
'default'
),
"comment"
:
details
.
get
(
'description'
,
''
),
"type"
:
details
[
'type'
],
}
}
)
if
'choice'
in
details
:
...
...
beat/web/algorithms/serializers.py
View file @
d0206315
...
...
@@ -76,17 +76,17 @@ class AlgorithmSerializer(CodeSerializer):
def
get_inputs
(
self
,
obj
):
return
map
(
lambda
x
:
{
'name'
:
x
.
name
,
'name'
:
x
.
name
,
'dataformat'
:
x
.
dataformat
.
fullname
(),
'channel'
:
x
.
channel
},
obj
.
endpoints
.
filter
(
input
=
True
).
order_by
(
'name'
))
},
obj
.
endpoints
.
filter
(
input
=
True
).
order_by
(
'name'
))
def
get_outputs
(
self
,
obj
):
return
map
(
lambda
x
:
{
'name'
:
x
.
name
,
'name'
:
x
.
name
,
'dataformat'
:
x
.
dataformat
.
fullname
(),
'channel'
:
x
.
channel
,
},
obj
.
endpoints
.
filter
(
input
=
False
).
order_by
(
'name'
))
},
obj
.
endpoints
.
filter
(
input
=
False
).
order_by
(
'name'
))
def
get_referencing_experiments
(
self
,
obj
):
user
=
self
.
context
.
get
(
'user'
)
...
...
@@ -96,9 +96,9 @@ class AlgorithmSerializer(CodeSerializer):
# Put the pending experiments first
ordered_result
=
filter
(
lambda
x
:
x
[
'creation_date'
]
is
None
,
\
referencing_experiments
)
referencing_experiments
)
ordered_result
+=
filter
(
lambda
x
:
x
[
'creation_date'
]
is
not
None
,
\
referencing_experiments
)
referencing_experiments
)
return
ordered_result
...
...
beat/web/algorithms/signals.py
View file @
d0206315
...
...
@@ -106,18 +106,18 @@ def create_endpoints(sender, instance, **kwargs):
(
df_author
,
df_name
,
df_version
)
=
formatname
.
split
(
'/'
)
df
=
DataFormat
.
objects
.
get
(
author__username
=
df_author
,
name
=
df_name
,
version
=
df_version
,
)
author__username
=
df_author
,
name
=
df_name
,
version
=
df_version
,
)
endpoint
=
AlgorithmEndpoint
.
objects
.
filter
(
algorithm
=
instance
,
input
=
isinput
,
name
=
name
,
#channel = channel_name,
algorithm
=
instance
,
input
=
isinput
,
name
=
name
,
#channel = channel_name,
dataformat
=
df
,
)
)
if
not
endpoint
:
endpoint
=
AlgorithmEndpoint
()
...
...
beat/web/algorithms/templatetags/algorithm_tags.py
View file @
d0206315
...
...
@@ -51,11 +51,11 @@ def algorithm_table(context, objects, owner, panel_id):
'''
return
{
'request'
:
context
[
'request'
],
'request'
:
context
[
'request'
],
'objects'
:
objects
,
'owner'
:
owner
,
'panel_id'
:
panel_id
,
}
}
@
register
.
inclusion_tag
(
'algorithms/panels/actions.html'
,
takes_context
=
True
)
...
...
@@ -75,23 +75,23 @@ def algorithm_actions(context, obj, display_count):
'''
request
=
context
[
'request'
]
return
{
'request'
:
request
,
'request'
:
request
,
'object'
:
obj
,
'display_count'
:
display_count
,
'open_source'
:
obj
.
open_source
(
request
.
user
),
}
}
@
register
.
inclusion_tag
(
'algorithms/panels/editor.html'
,
takes_context
=
True
)
def
algorithm_editor
(
context
,
obj
):
request
=
context
[
'request'
]
return
{
'owner'
:
request
.
user
==
obj
.
author
,
'owner'
:
request
.
user
==
obj
.
author
,
'object'
:
obj
,