repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
ninuxorg/nodeshot | nodeshot/interop/open311/views.py | ServiceDefinitionList.get | def get(self, request, *args, **kwargs):
""" return list of open 311 services """
# init django rest framework specific stuff
serializer_class = self.get_serializer_class()
context = self.get_serializer_context()
# init empty list
services = []
# loop over each... | python | def get(self, request, *args, **kwargs):
""" return list of open 311 services """
# init django rest framework specific stuff
serializer_class = self.get_serializer_class()
context = self.get_serializer_context()
# init empty list
services = []
# loop over each... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# init django rest framework specific stuff",
"serializer_class",
"=",
"self",
".",
"get_serializer_class",
"(",
")",
"context",
"=",
"self",
".",
"get_serializer_co... | return list of open 311 services | [
"return",
"list",
"of",
"open",
"311",
"services"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/open311/views.py#L40-L60 |
ninuxorg/nodeshot | nodeshot/interop/open311/views.py | ServiceRequestList.get_serializer | def get_serializer(self, instance=None, data=None,
many=False, partial=False):
"""
Return the serializer instance that should be used for validating and
deserializing input, and for serializing output.
"""
serializers = {
'node': NodeRequestList... | python | def get_serializer(self, instance=None, data=None,
many=False, partial=False):
"""
Return the serializer instance that should be used for validating and
deserializing input, and for serializing output.
"""
serializers = {
'node': NodeRequestList... | [
"def",
"get_serializer",
"(",
"self",
",",
"instance",
"=",
"None",
",",
"data",
"=",
"None",
",",
"many",
"=",
"False",
",",
"partial",
"=",
"False",
")",
":",
"serializers",
"=",
"{",
"'node'",
":",
"NodeRequestListSerializer",
",",
"'vote'",
":",
"Vot... | Return the serializer instance that should be used for validating and
deserializing input, and for serializing output. | [
"Return",
"the",
"serializer",
"instance",
"that",
"should",
"be",
"used",
"for",
"validating",
"and",
"deserializing",
"input",
"and",
"for",
"serializing",
"output",
"."
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/open311/views.py#L141-L161 |
ninuxorg/nodeshot | nodeshot/interop/open311/views.py | ServiceRequestList.get | def get(self, request, *args, **kwargs):
""" Retrieve list of service requests """
if 'service_code' not in request.GET.keys():
return Response({ 'detail': _('A service code must be inserted') }, status=404)
service_code = request.GET['service_code']
if service_code not in ... | python | def get(self, request, *args, **kwargs):
""" Retrieve list of service requests """
if 'service_code' not in request.GET.keys():
return Response({ 'detail': _('A service code must be inserted') }, status=404)
service_code = request.GET['service_code']
if service_code not in ... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'service_code'",
"not",
"in",
"request",
".",
"GET",
".",
"keys",
"(",
")",
":",
"return",
"Response",
"(",
"{",
"'detail'",
":",
"_",
"(",
"'A... | Retrieve list of service requests | [
"Retrieve",
"list",
"of",
"service",
"requests"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/open311/views.py#L169-L231 |
ninuxorg/nodeshot | nodeshot/interop/open311/views.py | ServiceRequestList.post | def post(self, request, *args, **kwargs):
""" Post a service request (requires authentication) """
service_code = request.data['service_code']
if service_code not in SERVICES.keys():
return Response({ 'detail': _('Service not found') }, status=404)
serializers = {
... | python | def post(self, request, *args, **kwargs):
""" Post a service request (requires authentication) """
service_code = request.data['service_code']
if service_code not in SERVICES.keys():
return Response({ 'detail': _('Service not found') }, status=404)
serializers = {
... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"service_code",
"=",
"request",
".",
"data",
"[",
"'service_code'",
"]",
"if",
"service_code",
"not",
"in",
"SERVICES",
".",
"keys",
"(",
")",
":",
"retu... | Post a service request (requires authentication) | [
"Post",
"a",
"service",
"request",
"(",
"requires",
"authentication",
")"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/open311/views.py#L233-L274 |
ninuxorg/nodeshot | nodeshot/community/participation/apps.py | AppConfig.ready | def ready(self):
""" Add user info to ExtensibleNodeSerializer """
from nodeshot.core.nodes.base import ExtensibleNodeSerializer
from .models import Vote
from .serializers import (CommentRelationSerializer,
ParticipationSerializer)
ExtensibleNod... | python | def ready(self):
""" Add user info to ExtensibleNodeSerializer """
from nodeshot.core.nodes.base import ExtensibleNodeSerializer
from .models import Vote
from .serializers import (CommentRelationSerializer,
ParticipationSerializer)
ExtensibleNod... | [
"def",
"ready",
"(",
"self",
")",
":",
"from",
"nodeshot",
".",
"core",
".",
"nodes",
".",
"base",
"import",
"ExtensibleNodeSerializer",
"from",
".",
"models",
"import",
"Vote",
"from",
".",
"serializers",
"import",
"(",
"CommentRelationSerializer",
",",
"Part... | Add user info to ExtensibleNodeSerializer | [
"Add",
"user",
"info",
"to",
"ExtensibleNodeSerializer"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/participation/apps.py#L7-L77 |
ninuxorg/nodeshot | nodeshot/community/notifications/registrars/nodes.py | node_created_handler | def node_created_handler(sender, **kwargs):
""" send notification when a new node is created according to users's settings """
if kwargs['created']:
obj = kwargs['instance']
queryset = exclude_owner_of_node(obj)
create_notifications.delay(**{
"users": queryset,
"n... | python | def node_created_handler(sender, **kwargs):
""" send notification when a new node is created according to users's settings """
if kwargs['created']:
obj = kwargs['instance']
queryset = exclude_owner_of_node(obj)
create_notifications.delay(**{
"users": queryset,
"n... | [
"def",
"node_created_handler",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
"[",
"'created'",
"]",
":",
"obj",
"=",
"kwargs",
"[",
"'instance'",
"]",
"queryset",
"=",
"exclude_owner_of_node",
"(",
"obj",
")",
"create_notifications",
".",... | send notification when a new node is created according to users's settings | [
"send",
"notification",
"when",
"a",
"new",
"node",
"is",
"created",
"according",
"to",
"users",
"s",
"settings"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/registrars/nodes.py#L26-L36 |
ninuxorg/nodeshot | nodeshot/community/notifications/registrars/nodes.py | node_status_changed_handler | def node_status_changed_handler(**kwargs):
""" send notification when the status of a node changes according to users's settings """
obj = kwargs['instance']
obj.old_status = kwargs['old_status'].name
obj.new_status = kwargs['new_status'].name
queryset = exclude_owner_of_node(obj)
create_notific... | python | def node_status_changed_handler(**kwargs):
""" send notification when the status of a node changes according to users's settings """
obj = kwargs['instance']
obj.old_status = kwargs['old_status'].name
obj.new_status = kwargs['new_status'].name
queryset = exclude_owner_of_node(obj)
create_notific... | [
"def",
"node_status_changed_handler",
"(",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"kwargs",
"[",
"'instance'",
"]",
"obj",
".",
"old_status",
"=",
"kwargs",
"[",
"'old_status'",
"]",
".",
"name",
"obj",
".",
"new_status",
"=",
"kwargs",
"[",
"'new_statu... | send notification when the status of a node changes according to users's settings | [
"send",
"notification",
"when",
"the",
"status",
"of",
"a",
"node",
"changes",
"according",
"to",
"users",
"s",
"settings"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/registrars/nodes.py#L42-L62 |
ninuxorg/nodeshot | nodeshot/networking/links/models/topology.py | Topology.diff | def diff(self):
""" shortcut to netdiff.diff """
latest = self.latest
current = NetJsonParser(self.json())
return diff(current, latest) | python | def diff(self):
""" shortcut to netdiff.diff """
latest = self.latest
current = NetJsonParser(self.json())
return diff(current, latest) | [
"def",
"diff",
"(",
"self",
")",
":",
"latest",
"=",
"self",
".",
"latest",
"current",
"=",
"NetJsonParser",
"(",
"self",
".",
"json",
"(",
")",
")",
"return",
"diff",
"(",
"current",
",",
"latest",
")"
] | shortcut to netdiff.diff | [
"shortcut",
"to",
"netdiff",
".",
"diff"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/networking/links/models/topology.py#L51-L55 |
ninuxorg/nodeshot | nodeshot/networking/links/models/topology.py | Topology.json | def json(self):
""" returns a dict that represents a NetJSON NetworkGraph object """
nodes = []
links = []
for link in self.link_set.all():
if self.is_layer2:
source = link.interface_a.mac
destination = link.interface_b.mac
else:
... | python | def json(self):
""" returns a dict that represents a NetJSON NetworkGraph object """
nodes = []
links = []
for link in self.link_set.all():
if self.is_layer2:
source = link.interface_a.mac
destination = link.interface_b.mac
else:
... | [
"def",
"json",
"(",
"self",
")",
":",
"nodes",
"=",
"[",
"]",
"links",
"=",
"[",
"]",
"for",
"link",
"in",
"self",
".",
"link_set",
".",
"all",
"(",
")",
":",
"if",
"self",
".",
"is_layer2",
":",
"source",
"=",
"link",
".",
"interface_a",
".",
... | returns a dict that represents a NetJSON NetworkGraph object | [
"returns",
"a",
"dict",
"that",
"represents",
"a",
"NetJSON",
"NetworkGraph",
"object"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/networking/links/models/topology.py#L57-L88 |
ninuxorg/nodeshot | nodeshot/networking/links/models/topology.py | Topology.update | def update(self):
"""
Updates topology
Links are not deleted straightaway but set as "disconnected"
"""
from .link import Link # avoid circular dependency
diff = self.diff()
status = {
'added': 'active',
'removed': 'disconnected',
... | python | def update(self):
"""
Updates topology
Links are not deleted straightaway but set as "disconnected"
"""
from .link import Link # avoid circular dependency
diff = self.diff()
status = {
'added': 'active',
'removed': 'disconnected',
... | [
"def",
"update",
"(",
"self",
")",
":",
"from",
".",
"link",
"import",
"Link",
"# avoid circular dependency",
"diff",
"=",
"self",
".",
"diff",
"(",
")",
"status",
"=",
"{",
"'added'",
":",
"'active'",
",",
"'removed'",
":",
"'disconnected'",
",",
"'change... | Updates topology
Links are not deleted straightaway but set as "disconnected" | [
"Updates",
"topology",
"Links",
"are",
"not",
"deleted",
"straightaway",
"but",
"set",
"as",
"disconnected"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/networking/links/models/topology.py#L90-L120 |
ninuxorg/nodeshot | nodeshot/interop/sync/models/layer_external.py | LayerExternal.clean | def clean(self, *args, **kwargs):
"""
Call self.synchronizer.clean method
"""
if self.synchronizer_path != 'None' and self.config:
# call synchronizer custom clean
try:
self.synchronizer.load_config(self.config)
self.synchronizer.cl... | python | def clean(self, *args, **kwargs):
"""
Call self.synchronizer.clean method
"""
if self.synchronizer_path != 'None' and self.config:
# call synchronizer custom clean
try:
self.synchronizer.load_config(self.config)
self.synchronizer.cl... | [
"def",
"clean",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"synchronizer_path",
"!=",
"'None'",
"and",
"self",
".",
"config",
":",
"# call synchronizer custom clean",
"try",
":",
"self",
".",
"synchronizer",
".",
... | Call self.synchronizer.clean method | [
"Call",
"self",
".",
"synchronizer",
".",
"clean",
"method"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/models/layer_external.py#L72-L82 |
ninuxorg/nodeshot | nodeshot/interop/sync/models/layer_external.py | LayerExternal.save | def save(self, *args, **kwargs):
"""
call synchronizer "after_external_layer_saved" method
for any additional operation that must be executed after save
"""
after_save = kwargs.pop('after_save', True)
super(LayerExternal, self).save(*args, **kwargs)
# call after_e... | python | def save(self, *args, **kwargs):
"""
call synchronizer "after_external_layer_saved" method
for any additional operation that must be executed after save
"""
after_save = kwargs.pop('after_save', True)
super(LayerExternal, self).save(*args, **kwargs)
# call after_e... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"after_save",
"=",
"kwargs",
".",
"pop",
"(",
"'after_save'",
",",
"True",
")",
"super",
"(",
"LayerExternal",
",",
"self",
")",
".",
"save",
"(",
"*",
"args",
",",
... | call synchronizer "after_external_layer_saved" method
for any additional operation that must be executed after save | [
"call",
"synchronizer",
"after_external_layer_saved",
"method",
"for",
"any",
"additional",
"operation",
"that",
"must",
"be",
"executed",
"after",
"save"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/models/layer_external.py#L84-L101 |
ninuxorg/nodeshot | nodeshot/interop/sync/models/layer_external.py | LayerExternal.synchronizer | def synchronizer(self):
""" access synchronizer """
if not self.synchronizer_path or self.synchronizer_path == 'None' or not self.layer:
return False
# ensure data is up to date
if (self._synchronizer is not None and self._synchronizer_class.__name__ not in self.synchronizer_... | python | def synchronizer(self):
""" access synchronizer """
if not self.synchronizer_path or self.synchronizer_path == 'None' or not self.layer:
return False
# ensure data is up to date
if (self._synchronizer is not None and self._synchronizer_class.__name__ not in self.synchronizer_... | [
"def",
"synchronizer",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"synchronizer_path",
"or",
"self",
".",
"synchronizer_path",
"==",
"'None'",
"or",
"not",
"self",
".",
"layer",
":",
"return",
"False",
"# ensure data is up to date",
"if",
"(",
"self",
... | access synchronizer | [
"access",
"synchronizer"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/models/layer_external.py#L104-L115 |
ninuxorg/nodeshot | nodeshot/interop/sync/models/layer_external.py | LayerExternal.synchronizer_class | def synchronizer_class(self):
""" returns synchronizer class """
if not self.synchronizer_path or self.synchronizer_path == 'None' or not self.layer:
return False
# ensure data is up to date
if (self._synchronizer_class is not None and self._synchronizer_class.__name__ not in... | python | def synchronizer_class(self):
""" returns synchronizer class """
if not self.synchronizer_path or self.synchronizer_path == 'None' or not self.layer:
return False
# ensure data is up to date
if (self._synchronizer_class is not None and self._synchronizer_class.__name__ not in... | [
"def",
"synchronizer_class",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"synchronizer_path",
"or",
"self",
".",
"synchronizer_path",
"==",
"'None'",
"or",
"not",
"self",
".",
"layer",
":",
"return",
"False",
"# ensure data is up to date",
"if",
"(",
"sel... | returns synchronizer class | [
"returns",
"synchronizer",
"class"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/models/layer_external.py#L118-L129 |
ninuxorg/nodeshot | nodeshot/core/nodes/serializers.py | NodeSerializer.get_can_edit | def get_can_edit(self, obj):
""" returns true if user has permission to edit, false otherwise """
view = self.context.get('view')
request = copy(self.context.get('request'))
request._method = 'PUT'
try:
view.check_object_permissions(request, obj)
except (Permi... | python | def get_can_edit(self, obj):
""" returns true if user has permission to edit, false otherwise """
view = self.context.get('view')
request = copy(self.context.get('request'))
request._method = 'PUT'
try:
view.check_object_permissions(request, obj)
except (Permi... | [
"def",
"get_can_edit",
"(",
"self",
",",
"obj",
")",
":",
"view",
"=",
"self",
".",
"context",
".",
"get",
"(",
"'view'",
")",
"request",
"=",
"copy",
"(",
"self",
".",
"context",
".",
"get",
"(",
"'request'",
")",
")",
"request",
".",
"_method",
"... | returns true if user has permission to edit, false otherwise | [
"returns",
"true",
"if",
"user",
"has",
"permission",
"to",
"edit",
"false",
"otherwise"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/nodes/serializers.py#L28-L38 |
ninuxorg/nodeshot | nodeshot/core/nodes/serializers.py | ImageSerializer.get_details | def get_details(self, obj):
""" returns uri of API image resource """
args = {
'slug': obj.node.slug,
'pk': obj.pk
}
return reverse('api_node_image_detail',
kwargs=args,
request=self.context.get('request', None)) | python | def get_details(self, obj):
""" returns uri of API image resource """
args = {
'slug': obj.node.slug,
'pk': obj.pk
}
return reverse('api_node_image_detail',
kwargs=args,
request=self.context.get('request', None)) | [
"def",
"get_details",
"(",
"self",
",",
"obj",
")",
":",
"args",
"=",
"{",
"'slug'",
":",
"obj",
".",
"node",
".",
"slug",
",",
"'pk'",
":",
"obj",
".",
"pk",
"}",
"return",
"reverse",
"(",
"'api_node_image_detail'",
",",
"kwargs",
"=",
"args",
",",
... | returns uri of API image resource | [
"returns",
"uri",
"of",
"API",
"image",
"resource"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/nodes/serializers.py#L91-L99 |
ninuxorg/nodeshot | nodeshot/interop/sync/synchronizers/georss.py | GeoRss.parse | def parse(self):
""" parse data """
super(GeoRss, self).parse()
# support RSS and ATOM
tag_name = 'item' if '<item>' in self.data else 'entry'
self.parsed_data = self.parsed_data.getElementsByTagName(tag_name) | python | def parse(self):
""" parse data """
super(GeoRss, self).parse()
# support RSS and ATOM
tag_name = 'item' if '<item>' in self.data else 'entry'
self.parsed_data = self.parsed_data.getElementsByTagName(tag_name) | [
"def",
"parse",
"(",
"self",
")",
":",
"super",
"(",
"GeoRss",
",",
"self",
")",
".",
"parse",
"(",
")",
"# support RSS and ATOM",
"tag_name",
"=",
"'item'",
"if",
"'<item>'",
"in",
"self",
".",
"data",
"else",
"'entry'",
"self",
".",
"parsed_data",
"=",... | parse data | [
"parse",
"data"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/synchronizers/georss.py#L162-L169 |
ninuxorg/nodeshot | nodeshot/community/profiles/permissions.py | IsProfileOwner.has_permission | def has_permission(self, request, view):
""" applies to social-link-list """
if request.method == 'POST':
user = Profile.objects.only('id', 'username').get(username=view.kwargs['username'])
return request.user.id == user.id
return True | python | def has_permission(self, request, view):
""" applies to social-link-list """
if request.method == 'POST':
user = Profile.objects.only('id', 'username').get(username=view.kwargs['username'])
return request.user.id == user.id
return True | [
"def",
"has_permission",
"(",
"self",
",",
"request",
",",
"view",
")",
":",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"user",
"=",
"Profile",
".",
"objects",
".",
"only",
"(",
"'id'",
",",
"'username'",
")",
".",
"get",
"(",
"username",
"... | applies to social-link-list | [
"applies",
"to",
"social",
"-",
"link",
"-",
"list"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/permissions.py#L33-L39 |
ninuxorg/nodeshot | nodeshot/core/nodes/models/image.py | Image.delete | def delete(self, *args, **kwargs):
""" delete image when an image record is deleted """
try:
os.remove(self.file.file.name)
# image does not exist
except (OSError, IOError):
pass
super(Image, self).delete(*args, **kwargs) | python | def delete(self, *args, **kwargs):
""" delete image when an image record is deleted """
try:
os.remove(self.file.file.name)
# image does not exist
except (OSError, IOError):
pass
super(Image, self).delete(*args, **kwargs) | [
"def",
"delete",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"os",
".",
"remove",
"(",
"self",
".",
"file",
".",
"file",
".",
"name",
")",
"# image does not exist",
"except",
"(",
"OSError",
",",
"IOError",
")",
":... | delete image when an image record is deleted | [
"delete",
"image",
"when",
"an",
"image",
"record",
"is",
"deleted"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/nodes/models/image.py#L33-L40 |
ninuxorg/nodeshot | nodeshot/interop/oldimporter/models.py | OldLink.get_quality | def get_quality(self, type='etx'):
""" used to determine color of links"""
if type == 'etx':
if 0 < self.etx < 1.5:
quality = 1
elif self.etx < 3:
quality = 2
else:
quality = 3
elif type == 'dbm':
if -8... | python | def get_quality(self, type='etx'):
""" used to determine color of links"""
if type == 'etx':
if 0 < self.etx < 1.5:
quality = 1
elif self.etx < 3:
quality = 2
else:
quality = 3
elif type == 'dbm':
if -8... | [
"def",
"get_quality",
"(",
"self",
",",
"type",
"=",
"'etx'",
")",
":",
"if",
"type",
"==",
"'etx'",
":",
"if",
"0",
"<",
"self",
".",
"etx",
"<",
"1.5",
":",
"quality",
"=",
"1",
"elif",
"self",
".",
"etx",
"<",
"3",
":",
"quality",
"=",
"2",
... | used to determine color of links | [
"used",
"to",
"determine",
"color",
"of",
"links"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/oldimporter/models.py#L157-L173 |
ninuxorg/nodeshot | nodeshot/core/layers/models/layer.py | new_nodes_allowed_for_layer | def new_nodes_allowed_for_layer(self):
"""
ensure new nodes are allowed for this layer
"""
if not self.pk and self.layer and not self.layer.new_nodes_allowed:
raise ValidationError(_('New nodes are not allowed for this layer')) | python | def new_nodes_allowed_for_layer(self):
"""
ensure new nodes are allowed for this layer
"""
if not self.pk and self.layer and not self.layer.new_nodes_allowed:
raise ValidationError(_('New nodes are not allowed for this layer')) | [
"def",
"new_nodes_allowed_for_layer",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"pk",
"and",
"self",
".",
"layer",
"and",
"not",
"self",
".",
"layer",
".",
"new_nodes_allowed",
":",
"raise",
"ValidationError",
"(",
"_",
"(",
"'New nodes are not allowed ... | ensure new nodes are allowed for this layer | [
"ensure",
"new",
"nodes",
"are",
"allowed",
"for",
"this",
"layer"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/layers/models/layer.py#L138-L143 |
ninuxorg/nodeshot | nodeshot/core/layers/models/layer.py | nodes_minimum_distance_validation | def nodes_minimum_distance_validation(self):
"""
if minimum distance is specified, ensure node is not too close to other nodes;
"""
if self.layer and self.layer.nodes_minimum_distance:
minimum_distance = self.layer.nodes_minimum_distance
# TODO - lower priority: do this check only when c... | python | def nodes_minimum_distance_validation(self):
"""
if minimum distance is specified, ensure node is not too close to other nodes;
"""
if self.layer and self.layer.nodes_minimum_distance:
minimum_distance = self.layer.nodes_minimum_distance
# TODO - lower priority: do this check only when c... | [
"def",
"nodes_minimum_distance_validation",
"(",
"self",
")",
":",
"if",
"self",
".",
"layer",
"and",
"self",
".",
"layer",
".",
"nodes_minimum_distance",
":",
"minimum_distance",
"=",
"self",
".",
"layer",
".",
"nodes_minimum_distance",
"# TODO - lower priority: do t... | if minimum distance is specified, ensure node is not too close to other nodes; | [
"if",
"minimum",
"distance",
"is",
"specified",
"ensure",
"node",
"is",
"not",
"too",
"close",
"to",
"other",
"nodes",
";"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/layers/models/layer.py#L146-L155 |
ninuxorg/nodeshot | nodeshot/core/layers/models/layer.py | node_contained_in_layer_area_validation | def node_contained_in_layer_area_validation(self):
"""
if layer defines an area, ensure node coordinates are contained in the area
"""
# if area is a polygon ensure it contains the node
if self.layer and isinstance(self.layer.area, Polygon) and not self.layer.area.contains(self.geometry):
ra... | python | def node_contained_in_layer_area_validation(self):
"""
if layer defines an area, ensure node coordinates are contained in the area
"""
# if area is a polygon ensure it contains the node
if self.layer and isinstance(self.layer.area, Polygon) and not self.layer.area.contains(self.geometry):
ra... | [
"def",
"node_contained_in_layer_area_validation",
"(",
"self",
")",
":",
"# if area is a polygon ensure it contains the node",
"if",
"self",
".",
"layer",
"and",
"isinstance",
"(",
"self",
".",
"layer",
".",
"area",
",",
"Polygon",
")",
"and",
"not",
"self",
".",
... | if layer defines an area, ensure node coordinates are contained in the area | [
"if",
"layer",
"defines",
"an",
"area",
"ensure",
"node",
"coordinates",
"are",
"contained",
"in",
"the",
"area"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/layers/models/layer.py#L158-L164 |
ninuxorg/nodeshot | nodeshot/core/layers/models/layer.py | Layer.save | def save(self, *args, **kwargs):
"""
intercepts changes to is_published and fires layer_is_published_changed signal
"""
super(Layer, self).save(*args, **kwargs)
# if is_published of an existing layer changes
if self.pk and self.is_published != self._current_is_published:... | python | def save(self, *args, **kwargs):
"""
intercepts changes to is_published and fires layer_is_published_changed signal
"""
super(Layer, self).save(*args, **kwargs)
# if is_published of an existing layer changes
if self.pk and self.is_published != self._current_is_published:... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Layer",
",",
"self",
")",
".",
"save",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"# if is_published of an existing layer changes",
"if",
"self",
".",
... | intercepts changes to is_published and fires layer_is_published_changed signal | [
"intercepts",
"changes",
"to",
"is_published",
"and",
"fires",
"layer_is_published_changed",
"signal"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/layers/models/layer.py#L72-L91 |
ninuxorg/nodeshot | nodeshot/core/layers/models/layer.py | Layer.update_nodes_published | def update_nodes_published(self):
""" publish or unpublish nodes of current layer """
if self.pk:
self.node_set.all().update(is_published=self.is_published) | python | def update_nodes_published(self):
""" publish or unpublish nodes of current layer """
if self.pk:
self.node_set.all().update(is_published=self.is_published) | [
"def",
"update_nodes_published",
"(",
"self",
")",
":",
"if",
"self",
".",
"pk",
":",
"self",
".",
"node_set",
".",
"all",
"(",
")",
".",
"update",
"(",
"is_published",
"=",
"self",
".",
"is_published",
")"
] | publish or unpublish nodes of current layer | [
"publish",
"or",
"unpublish",
"nodes",
"of",
"current",
"layer"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/layers/models/layer.py#L114-L117 |
ninuxorg/nodeshot | nodeshot/community/notifications/views.py | NotificationList.get | def get(self, request, format=None):
""" get HTTP method """
action = request.query_params.get('action', 'unread')
# action can be only "unread" (default), "count" and "all"
action = action if action == 'count' or action == 'all' else 'unread'
# mark as read parameter, defaults t... | python | def get(self, request, format=None):
""" get HTTP method """
action = request.query_params.get('action', 'unread')
# action can be only "unread" (default), "count" and "all"
action = action if action == 'count' or action == 'all' else 'unread'
# mark as read parameter, defaults t... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"format",
"=",
"None",
")",
":",
"action",
"=",
"request",
".",
"query_params",
".",
"get",
"(",
"'action'",
",",
"'unread'",
")",
"# action can be only \"unread\" (default), \"count\" and \"all\"",
"action",
"=",
... | get HTTP method | [
"get",
"HTTP",
"method"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/views.py#L36-L46 |
ninuxorg/nodeshot | nodeshot/community/notifications/views.py | NotificationList.get_unread | def get_unread(self, request, notifications, mark_as_read):
"""
return unread notifications and mark as read
(unless read=false param is passed)
"""
notifications = notifications.filter(is_read=False)
serializer = UnreadNotificationSerializer(list(notifications), # evalu... | python | def get_unread(self, request, notifications, mark_as_read):
"""
return unread notifications and mark as read
(unless read=false param is passed)
"""
notifications = notifications.filter(is_read=False)
serializer = UnreadNotificationSerializer(list(notifications), # evalu... | [
"def",
"get_unread",
"(",
"self",
",",
"request",
",",
"notifications",
",",
"mark_as_read",
")",
":",
"notifications",
"=",
"notifications",
".",
"filter",
"(",
"is_read",
"=",
"False",
")",
"serializer",
"=",
"UnreadNotificationSerializer",
"(",
"list",
"(",
... | return unread notifications and mark as read
(unless read=false param is passed) | [
"return",
"unread",
"notifications",
"and",
"mark",
"as",
"read",
"(",
"unless",
"read",
"=",
"false",
"param",
"is",
"passed",
")"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/views.py#L48-L60 |
ninuxorg/nodeshot | nodeshot/community/notifications/views.py | NotificationList.get_count | def get_count(self, request, notifications, mark_as_read=False):
""" return count of unread notification """
return Response({'count': notifications.filter(is_read=False).count()}) | python | def get_count(self, request, notifications, mark_as_read=False):
""" return count of unread notification """
return Response({'count': notifications.filter(is_read=False).count()}) | [
"def",
"get_count",
"(",
"self",
",",
"request",
",",
"notifications",
",",
"mark_as_read",
"=",
"False",
")",
":",
"return",
"Response",
"(",
"{",
"'count'",
":",
"notifications",
".",
"filter",
"(",
"is_read",
"=",
"False",
")",
".",
"count",
"(",
")",... | return count of unread notification | [
"return",
"count",
"of",
"unread",
"notification"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/views.py#L62-L64 |
ninuxorg/nodeshot | nodeshot/community/notifications/views.py | NotificationList.get_all | def get_all(self, request, notifications, mark_as_read=False):
""" return all notifications with pagination """
return self.list(request, notifications) | python | def get_all(self, request, notifications, mark_as_read=False):
""" return all notifications with pagination """
return self.list(request, notifications) | [
"def",
"get_all",
"(",
"self",
",",
"request",
",",
"notifications",
",",
"mark_as_read",
"=",
"False",
")",
":",
"return",
"self",
".",
"list",
"(",
"request",
",",
"notifications",
")"
] | return all notifications with pagination | [
"return",
"all",
"notifications",
"with",
"pagination"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/views.py#L66-L68 |
ninuxorg/nodeshot | nodeshot/community/notifications/views.py | EmailNotificationSettings.get_object | def get_object(self, queryset=None):
""" get privacy settings of current user """
try:
obj = self.get_queryset()
except self.model.DoesNotExist:
raise Http404()
self.check_object_permissions(self.request, obj)
return obj | python | def get_object(self, queryset=None):
""" get privacy settings of current user """
try:
obj = self.get_queryset()
except self.model.DoesNotExist:
raise Http404()
self.check_object_permissions(self.request, obj)
return obj | [
"def",
"get_object",
"(",
"self",
",",
"queryset",
"=",
"None",
")",
":",
"try",
":",
"obj",
"=",
"self",
".",
"get_queryset",
"(",
")",
"except",
"self",
".",
"model",
".",
"DoesNotExist",
":",
"raise",
"Http404",
"(",
")",
"self",
".",
"check_object_... | get privacy settings of current user | [
"get",
"privacy",
"settings",
"of",
"current",
"user"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/views.py#L108-L115 |
ninuxorg/nodeshot | nodeshot/networking/links/models/link.py | Link.clean | def clean(self, *args, **kwargs):
"""
Custom validation
1. interface_a and interface_b mandatory except for planned links
2. planned links should have at least node_a and node_b filled in
3. dbm and noise fields can be filled only for radio links
4. interf... | python | def clean(self, *args, **kwargs):
"""
Custom validation
1. interface_a and interface_b mandatory except for planned links
2. planned links should have at least node_a and node_b filled in
3. dbm and noise fields can be filled only for radio links
4. interf... | [
"def",
"clean",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"status",
"!=",
"LINK_STATUS",
".",
"get",
"(",
"'planned'",
")",
":",
"if",
"self",
".",
"interface_a",
"is",
"None",
"or",
"self",
".",
"interfac... | Custom validation
1. interface_a and interface_b mandatory except for planned links
2. planned links should have at least node_a and node_b filled in
3. dbm and noise fields can be filled only for radio links
4. interface_a and interface_b must differ
5. inter... | [
"Custom",
"validation",
"1",
".",
"interface_a",
"and",
"interface_b",
"mandatory",
"except",
"for",
"planned",
"links",
"2",
".",
"planned",
"links",
"should",
"have",
"at",
"least",
"node_a",
"and",
"node_b",
"filled",
"in",
"3",
".",
"dbm",
"and",
"noise"... | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/networking/links/models/link.py#L89-L110 |
ninuxorg/nodeshot | nodeshot/networking/links/models/link.py | Link.save | def save(self, *args, **kwargs):
"""
Custom save does the following:
* determine link type if not specified
* automatically fill 'node_a' and 'node_b' fields if necessary
* draw line between two nodes
* fill shortcut properties node_a_name and node_b_name
... | python | def save(self, *args, **kwargs):
"""
Custom save does the following:
* determine link type if not specified
* automatically fill 'node_a' and 'node_b' fields if necessary
* draw line between two nodes
* fill shortcut properties node_a_name and node_b_name
... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"type",
":",
"if",
"self",
".",
"interface_a",
".",
"type",
"==",
"INTERFACE_TYPES",
".",
"get",
"(",
"'wireless'",
")",
":",
"self",
".",
... | Custom save does the following:
* determine link type if not specified
* automatically fill 'node_a' and 'node_b' fields if necessary
* draw line between two nodes
* fill shortcut properties node_a_name and node_b_name | [
"Custom",
"save",
"does",
"the",
"following",
":",
"*",
"determine",
"link",
"type",
"if",
"not",
"specified",
"*",
"automatically",
"fill",
"node_a",
"and",
"node_b",
"fields",
"if",
"necessary",
"*",
"draw",
"line",
"between",
"two",
"nodes",
"*",
"fill",
... | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/networking/links/models/link.py#L112-L165 |
ninuxorg/nodeshot | nodeshot/networking/links/models/link.py | Link.get_link | def get_link(cls, source, target, topology=None):
"""
Find link between source and target, (or vice versa, order is irrelevant).
:param source: ip or mac addresses
:param target: ip or mac addresses
:param topology: optional topology relation
:returns: Link object
... | python | def get_link(cls, source, target, topology=None):
"""
Find link between source and target, (or vice versa, order is irrelevant).
:param source: ip or mac addresses
:param target: ip or mac addresses
:param topology: optional topology relation
:returns: Link object
... | [
"def",
"get_link",
"(",
"cls",
",",
"source",
",",
"target",
",",
"topology",
"=",
"None",
")",
":",
"a",
"=",
"source",
"b",
"=",
"target",
"# ensure parameters are coherent",
"if",
"not",
"(",
"valid_ipv4",
"(",
"a",
")",
"and",
"valid_ipv4",
"(",
"b",... | Find link between source and target, (or vice versa, order is irrelevant).
:param source: ip or mac addresses
:param target: ip or mac addresses
:param topology: optional topology relation
:returns: Link object
:raises: LinkNotFound | [
"Find",
"link",
"between",
"source",
"and",
"target",
"(",
"or",
"vice",
"versa",
"order",
"is",
"irrelevant",
")",
".",
":",
"param",
"source",
":",
"ip",
"or",
"mac",
"addresses",
":",
"param",
"target",
":",
"ip",
"or",
"mac",
"addresses",
":",
"par... | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/networking/links/models/link.py#L168-L206 |
ninuxorg/nodeshot | nodeshot/networking/links/models/link.py | Link.get_or_create | def get_or_create(cls, source, target, cost, topology=None):
"""
Tries to find a link with get_link, creates a new link if link not found.
"""
try:
return cls.get_link(source, target, topology)
except LinkNotFound as e:
pass
# create link
l... | python | def get_or_create(cls, source, target, cost, topology=None):
"""
Tries to find a link with get_link, creates a new link if link not found.
"""
try:
return cls.get_link(source, target, topology)
except LinkNotFound as e:
pass
# create link
l... | [
"def",
"get_or_create",
"(",
"cls",
",",
"source",
",",
"target",
",",
"cost",
",",
"topology",
"=",
"None",
")",
":",
"try",
":",
"return",
"cls",
".",
"get_link",
"(",
"source",
",",
"target",
",",
"topology",
")",
"except",
"LinkNotFound",
"as",
"e"... | Tries to find a link with get_link, creates a new link if link not found. | [
"Tries",
"to",
"find",
"a",
"link",
"with",
"get_link",
"creates",
"a",
"new",
"link",
"if",
"link",
"not",
"found",
"."
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/networking/links/models/link.py#L222-L238 |
ninuxorg/nodeshot | nodeshot/networking/links/models/link.py | Link.ensure | def ensure(self, status, cost):
"""
ensure link properties correspond to the specified ones
perform save operation only if necessary
"""
changed = False
status_id = LINK_STATUS[status]
if self.status != status_id:
self.status = status_id
ch... | python | def ensure(self, status, cost):
"""
ensure link properties correspond to the specified ones
perform save operation only if necessary
"""
changed = False
status_id = LINK_STATUS[status]
if self.status != status_id:
self.status = status_id
ch... | [
"def",
"ensure",
"(",
"self",
",",
"status",
",",
"cost",
")",
":",
"changed",
"=",
"False",
"status_id",
"=",
"LINK_STATUS",
"[",
"status",
"]",
"if",
"self",
".",
"status",
"!=",
"status_id",
":",
"self",
".",
"status",
"=",
"status_id",
"changed",
"... | ensure link properties correspond to the specified ones
perform save operation only if necessary | [
"ensure",
"link",
"properties",
"correspond",
"to",
"the",
"specified",
"ones",
"perform",
"save",
"operation",
"only",
"if",
"necessary"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/networking/links/models/link.py#L280-L294 |
ninuxorg/nodeshot | nodeshot/community/mailing/admin.py | OutwardAdmin.send | def send(self, request, queryset):
"""
Send action available in change outward list
"""
send_outward_mails.delay(queryset)
# show message in the admin
messages.info(request, _('Message sent successfully'), fail_silently=True) | python | def send(self, request, queryset):
"""
Send action available in change outward list
"""
send_outward_mails.delay(queryset)
# show message in the admin
messages.info(request, _('Message sent successfully'), fail_silently=True) | [
"def",
"send",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"send_outward_mails",
".",
"delay",
"(",
"queryset",
")",
"# show message in the admin",
"messages",
".",
"info",
"(",
"request",
",",
"_",
"(",
"'Message sent successfully'",
")",
",",
"fa... | Send action available in change outward list | [
"Send",
"action",
"available",
"in",
"change",
"outward",
"list"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/mailing/admin.py#L33-L39 |
ninuxorg/nodeshot | nodeshot/community/mailing/views.py | ContactNode.post | def post(self, request, *args, **kwargs):
"""
Contact node owner.
"""
try:
self.get_object(**kwargs)
except Http404:
return Response({'detail': _('Not Found')}, status=404)
if not self.is_contactable():
return Response({'detail': _('Th... | python | def post(self, request, *args, **kwargs):
"""
Contact node owner.
"""
try:
self.get_object(**kwargs)
except Http404:
return Response({'detail': _('Not Found')}, status=404)
if not self.is_contactable():
return Response({'detail': _('Th... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"get_object",
"(",
"*",
"*",
"kwargs",
")",
"except",
"Http404",
":",
"return",
"Response",
"(",
"{",
"'detail'",
":",
"_",
... | Contact node owner. | [
"Contact",
"node",
"owner",
"."
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/mailing/views.py#L51-L91 |
ninuxorg/nodeshot | nodeshot/community/profiles/views.py | ProfileList.get | def get(self, request, *args, **kwargs):
""" return profile of current user if authenticated otherwise 401 """
serializer = self.serializer_reader_class
if request.user.is_authenticated():
return Response(serializer(request.user, context=self.get_serializer_context()).data)
e... | python | def get(self, request, *args, **kwargs):
""" return profile of current user if authenticated otherwise 401 """
serializer = self.serializer_reader_class
if request.user.is_authenticated():
return Response(serializer(request.user, context=self.get_serializer_context()).data)
e... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"serializer",
"=",
"self",
".",
"serializer_reader_class",
"if",
"request",
".",
"user",
".",
"is_authenticated",
"(",
")",
":",
"return",
"Response",
"(",
... | return profile of current user if authenticated otherwise 401 | [
"return",
"profile",
"of",
"current",
"user",
"if",
"authenticated",
"otherwise",
"401"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/views.py#L58-L64 |
ninuxorg/nodeshot | nodeshot/community/profiles/views.py | AccountLogin.post | def post(self, request, format=None):
""" authenticate """
serializer = self.serializer_class(data=request.data)
if serializer.is_valid():
login(request, serializer.instance)
if request.data.get('remember'):
# TODO: remember configurable
... | python | def post(self, request, format=None):
""" authenticate """
serializer = self.serializer_class(data=request.data)
if serializer.is_valid():
login(request, serializer.instance)
if request.data.get('remember'):
# TODO: remember configurable
... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"format",
"=",
"None",
")",
":",
"serializer",
"=",
"self",
".",
"serializer_class",
"(",
"data",
"=",
"request",
".",
"data",
")",
"if",
"serializer",
".",
"is_valid",
"(",
")",
":",
"login",
"(",
"re... | authenticate | [
"authenticate"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/views.py#L208-L226 |
ninuxorg/nodeshot | nodeshot/community/profiles/views.py | AccountPassword.post | def post(self, request, format=None):
""" validate password change operation and return result """
serializer_class = self.get_serializer_class()
serializer = serializer_class(data=request.data, instance=request.user)
if serializer.is_valid():
serializer.save()
r... | python | def post(self, request, format=None):
""" validate password change operation and return result """
serializer_class = self.get_serializer_class()
serializer = serializer_class(data=request.data, instance=request.user)
if serializer.is_valid():
serializer.save()
r... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"format",
"=",
"None",
")",
":",
"serializer_class",
"=",
"self",
".",
"get_serializer_class",
"(",
")",
"serializer",
"=",
"serializer_class",
"(",
"data",
"=",
"request",
".",
"data",
",",
"instance",
"=",... | validate password change operation and return result | [
"validate",
"password",
"change",
"operation",
"and",
"return",
"result"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/views.py#L277-L286 |
ninuxorg/nodeshot | nodeshot/interop/sync/synchronizers/base.py | BaseSynchronizer.sync | def sync(self):
"""
This is the method that does everything automatically (at least attempts to).
Steps:
0. Call "before_start" method (which might be implemented by children classes)
1. Retrieve data from external source
2. Parse the data
3. Save... | python | def sync(self):
"""
This is the method that does everything automatically (at least attempts to).
Steps:
0. Call "before_start" method (which might be implemented by children classes)
1. Retrieve data from external source
2. Parse the data
3. Save... | [
"def",
"sync",
"(",
"self",
")",
":",
"self",
".",
"before_start",
"(",
")",
"self",
".",
"retrieve_data",
"(",
")",
"self",
".",
"parse",
"(",
")",
"# TRICK: disable new_nodes_allowed_for_layer validation",
"try",
":",
"Node",
".",
"_additional_validation",
"."... | This is the method that does everything automatically (at least attempts to).
Steps:
0. Call "before_start" method (which might be implemented by children classes)
1. Retrieve data from external source
2. Parse the data
3. Save the data locally
4. Cal... | [
"This",
"is",
"the",
"method",
"that",
"does",
"everything",
"automatically",
"(",
"at",
"least",
"attempts",
"to",
")",
"."
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/synchronizers/base.py#L73-L109 |
ninuxorg/nodeshot | nodeshot/interop/sync/synchronizers/base.py | HttpRetrieverMixin.retrieve_data | def retrieve_data(self):
""" retrieve data from an HTTP URL """
# shortcuts for readability
url = self.config.get('url')
timeout = float(self.config.get('timeout', 10))
# perform HTTP request and store content
self.data = requests.get(url, verify=self.verify_ssl, timeout=... | python | def retrieve_data(self):
""" retrieve data from an HTTP URL """
# shortcuts for readability
url = self.config.get('url')
timeout = float(self.config.get('timeout', 10))
# perform HTTP request and store content
self.data = requests.get(url, verify=self.verify_ssl, timeout=... | [
"def",
"retrieve_data",
"(",
"self",
")",
":",
"# shortcuts for readability",
"url",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'url'",
")",
"timeout",
"=",
"float",
"(",
"self",
".",
"config",
".",
"get",
"(",
"'timeout'",
",",
"10",
")",
")",
"# p... | retrieve data from an HTTP URL | [
"retrieve",
"data",
"from",
"an",
"HTTP",
"URL"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/synchronizers/base.py#L131-L137 |
ninuxorg/nodeshot | nodeshot/interop/sync/synchronizers/base.py | XMLParserMixin.get_text | def get_text(item, tag, default=False):
""" returns text content of an xml tag """
try:
xmlnode = item.getElementsByTagName(tag)[0].firstChild
except IndexError as e:
if default is not False:
return default
else:
raise IndexErro... | python | def get_text(item, tag, default=False):
""" returns text content of an xml tag """
try:
xmlnode = item.getElementsByTagName(tag)[0].firstChild
except IndexError as e:
if default is not False:
return default
else:
raise IndexErro... | [
"def",
"get_text",
"(",
"item",
",",
"tag",
",",
"default",
"=",
"False",
")",
":",
"try",
":",
"xmlnode",
"=",
"item",
".",
"getElementsByTagName",
"(",
"tag",
")",
"[",
"0",
"]",
".",
"firstChild",
"except",
"IndexError",
"as",
"e",
":",
"if",
"def... | returns text content of an xml tag | [
"returns",
"text",
"content",
"of",
"an",
"xml",
"tag"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/synchronizers/base.py#L148-L162 |
ninuxorg/nodeshot | nodeshot/interop/sync/synchronizers/base.py | GenericGisSynchronizer._convert_item | def _convert_item(self, item):
"""
take a parsed item as input and returns a python dictionary
the keys will be saved into the Node model
either in their respective fields or in the hstore "data" field
:param item: object representing parsed item
"""
item = self.... | python | def _convert_item(self, item):
"""
take a parsed item as input and returns a python dictionary
the keys will be saved into the Node model
either in their respective fields or in the hstore "data" field
:param item: object representing parsed item
"""
item = self.... | [
"def",
"_convert_item",
"(",
"self",
",",
"item",
")",
":",
"item",
"=",
"self",
".",
"parse_item",
"(",
"item",
")",
"# name is required",
"if",
"not",
"item",
"[",
"'name'",
"]",
":",
"raise",
"Exception",
"(",
"'Expected property %s not found in item %s.'",
... | take a parsed item as input and returns a python dictionary
the keys will be saved into the Node model
either in their respective fields or in the hstore "data" field
:param item: object representing parsed item | [
"take",
"a",
"parsed",
"item",
"as",
"input",
"and",
"returns",
"a",
"python",
"dictionary",
"the",
"keys",
"will",
"be",
"saved",
"into",
"the",
"Node",
"model",
"either",
"in",
"their",
"respective",
"fields",
"or",
"in",
"the",
"hstore",
"data",
"field"... | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/synchronizers/base.py#L342-L431 |
ninuxorg/nodeshot | nodeshot/interop/sync/synchronizers/base.py | GenericGisSynchronizer.save | def save(self):
"""
save data into DB:
1. save new (missing) data
2. update only when needed
3. delete old data
4. generate report that will be printed
constraints:
* ensure new nodes do not take a name/slug which is already used
* validate... | python | def save(self):
"""
save data into DB:
1. save new (missing) data
2. update only when needed
3. delete old data
4. generate report that will be printed
constraints:
* ensure new nodes do not take a name/slug which is already used
* validate... | [
"def",
"save",
"(",
"self",
")",
":",
"self",
".",
"key_mapping",
"(",
")",
"# retrieve all items",
"items",
"=",
"self",
".",
"parsed_data",
"# init empty lists",
"added_nodes",
"=",
"[",
"]",
"changed_nodes",
"=",
"[",
"]",
"unmodified_nodes",
"=",
"[",
"]... | save data into DB:
1. save new (missing) data
2. update only when needed
3. delete old data
4. generate report that will be printed
constraints:
* ensure new nodes do not take a name/slug which is already used
* validate through django before saving
... | [
"save",
"data",
"into",
"DB",
":"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/synchronizers/base.py#L449-L596 |
ninuxorg/nodeshot | nodeshot/core/base/mixins.py | ACLMixin.get_queryset | def get_queryset(self):
"""
Returns only objects which are accessible to the current user.
If user is not authenticated all public objects will be returned.
Model must implement AccessLevelManager!
"""
return self.queryset.all().accessible_to(user=self.request.user) | python | def get_queryset(self):
"""
Returns only objects which are accessible to the current user.
If user is not authenticated all public objects will be returned.
Model must implement AccessLevelManager!
"""
return self.queryset.all().accessible_to(user=self.request.user) | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"return",
"self",
".",
"queryset",
".",
"all",
"(",
")",
".",
"accessible_to",
"(",
"user",
"=",
"self",
".",
"request",
".",
"user",
")"
] | Returns only objects which are accessible to the current user.
If user is not authenticated all public objects will be returned.
Model must implement AccessLevelManager! | [
"Returns",
"only",
"objects",
"which",
"are",
"accessible",
"to",
"the",
"current",
"user",
".",
"If",
"user",
"is",
"not",
"authenticated",
"all",
"public",
"objects",
"will",
"be",
"returned",
"."
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/base/mixins.py#L12-L19 |
ninuxorg/nodeshot | nodeshot/core/base/mixins.py | RevisionUpdate.put | def put(self, request, *args, **kwargs):
""" custom put method to support django-reversion """
with reversion.create_revision():
reversion.set_user(request.user)
reversion.set_comment('changed through the RESTful API from ip %s' % request.META['REMOTE_ADDR'])
return s... | python | def put(self, request, *args, **kwargs):
""" custom put method to support django-reversion """
with reversion.create_revision():
reversion.set_user(request.user)
reversion.set_comment('changed through the RESTful API from ip %s' % request.META['REMOTE_ADDR'])
return s... | [
"def",
"put",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"reversion",
".",
"create_revision",
"(",
")",
":",
"reversion",
".",
"set_user",
"(",
"request",
".",
"user",
")",
"reversion",
".",
"set_comment",... | custom put method to support django-reversion | [
"custom",
"put",
"method",
"to",
"support",
"django",
"-",
"reversion"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/base/mixins.py#L27-L32 |
ninuxorg/nodeshot | nodeshot/core/base/mixins.py | RevisionUpdate.patch | def patch(self, request, *args, **kwargs):
""" custom patch method to support django-reversion """
with reversion.create_revision():
reversion.set_user(request.user)
reversion.set_comment('changed through the RESTful API from ip %s' % request.META['REMOTE_ADDR'])
kwar... | python | def patch(self, request, *args, **kwargs):
""" custom patch method to support django-reversion """
with reversion.create_revision():
reversion.set_user(request.user)
reversion.set_comment('changed through the RESTful API from ip %s' % request.META['REMOTE_ADDR'])
kwar... | [
"def",
"patch",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"reversion",
".",
"create_revision",
"(",
")",
":",
"reversion",
".",
"set_user",
"(",
"request",
".",
"user",
")",
"reversion",
".",
"set_comment... | custom patch method to support django-reversion | [
"custom",
"patch",
"method",
"to",
"support",
"django",
"-",
"reversion"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/base/mixins.py#L34-L40 |
ninuxorg/nodeshot | nodeshot/core/base/mixins.py | RevisionCreate.post | def post(self, request, *args, **kwargs):
""" custom put method to support django-reversion """
with reversion.create_revision():
reversion.set_user(request.user)
reversion.set_comment('created through the RESTful API from ip %s' % request.META['REMOTE_ADDR'])
return ... | python | def post(self, request, *args, **kwargs):
""" custom put method to support django-reversion """
with reversion.create_revision():
reversion.set_user(request.user)
reversion.set_comment('created through the RESTful API from ip %s' % request.META['REMOTE_ADDR'])
return ... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"reversion",
".",
"create_revision",
"(",
")",
":",
"reversion",
".",
"set_user",
"(",
"request",
".",
"user",
")",
"reversion",
".",
"set_comment"... | custom put method to support django-reversion | [
"custom",
"put",
"method",
"to",
"support",
"django",
"-",
"reversion"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/base/mixins.py#L48-L53 |
ninuxorg/nodeshot | nodeshot/networking/hardware/models/device_to_model_rel.py | DeviceToModelRel.save | def save(self, *args, **kwargs):
""" when creating a new record fill CPU and RAM info if available """
adding_new = False
if not self.pk or (not self.cpu and not self.ram):
# if self.model.cpu is not empty
if self.model.cpu:
self.cpu = self.model.cpu
... | python | def save(self, *args, **kwargs):
""" when creating a new record fill CPU and RAM info if available """
adding_new = False
if not self.pk or (not self.cpu and not self.ram):
# if self.model.cpu is not empty
if self.model.cpu:
self.cpu = self.model.cpu
... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"adding_new",
"=",
"False",
"if",
"not",
"self",
".",
"pk",
"or",
"(",
"not",
"self",
".",
"cpu",
"and",
"not",
"self",
".",
"ram",
")",
":",
"# if self.model.cpu is n... | when creating a new record fill CPU and RAM info if available | [
"when",
"creating",
"a",
"new",
"record",
"fill",
"CPU",
"and",
"RAM",
"info",
"if",
"available"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/networking/hardware/models/device_to_model_rel.py#L24-L57 |
ninuxorg/nodeshot | nodeshot/core/websockets/registrars/nodes.py | disconnect | def disconnect():
""" disconnect signals """
post_save.disconnect(node_created_handler, sender=Node)
node_status_changed.disconnect(node_status_changed_handler)
pre_delete.disconnect(node_deleted_handler, sender=Node) | python | def disconnect():
""" disconnect signals """
post_save.disconnect(node_created_handler, sender=Node)
node_status_changed.disconnect(node_status_changed_handler)
pre_delete.disconnect(node_deleted_handler, sender=Node) | [
"def",
"disconnect",
"(",
")",
":",
"post_save",
".",
"disconnect",
"(",
"node_created_handler",
",",
"sender",
"=",
"Node",
")",
"node_status_changed",
".",
"disconnect",
"(",
"node_status_changed_handler",
")",
"pre_delete",
".",
"disconnect",
"(",
"node_deleted_h... | disconnect signals | [
"disconnect",
"signals"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/websockets/registrars/nodes.py#L42-L46 |
ninuxorg/nodeshot | nodeshot/core/websockets/registrars/nodes.py | reconnect | def reconnect():
""" reconnect signals """
post_save.connect(node_created_handler, sender=Node)
node_status_changed.connect(node_status_changed_handler)
pre_delete.connect(node_deleted_handler, sender=Node) | python | def reconnect():
""" reconnect signals """
post_save.connect(node_created_handler, sender=Node)
node_status_changed.connect(node_status_changed_handler)
pre_delete.connect(node_deleted_handler, sender=Node) | [
"def",
"reconnect",
"(",
")",
":",
"post_save",
".",
"connect",
"(",
"node_created_handler",
",",
"sender",
"=",
"Node",
")",
"node_status_changed",
".",
"connect",
"(",
"node_status_changed_handler",
")",
"pre_delete",
".",
"connect",
"(",
"node_deleted_handler",
... | reconnect signals | [
"reconnect",
"signals"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/websockets/registrars/nodes.py#L49-L53 |
ninuxorg/nodeshot | nodeshot/community/notifications/models/notification.py | Notification.clean | def clean(self, *args, **kwargs):
""" from_user and to_user must differ """
if self.from_user and self.from_user_id == self.to_user_id:
raise ValidationError(_('A user cannot send a notification to herself/himself')) | python | def clean(self, *args, **kwargs):
""" from_user and to_user must differ """
if self.from_user and self.from_user_id == self.to_user_id:
raise ValidationError(_('A user cannot send a notification to herself/himself')) | [
"def",
"clean",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"from_user",
"and",
"self",
".",
"from_user_id",
"==",
"self",
".",
"to_user_id",
":",
"raise",
"ValidationError",
"(",
"_",
"(",
"'A user cannot send a ... | from_user and to_user must differ | [
"from_user",
"and",
"to_user",
"must",
"differ"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/models/notification.py#L44-L47 |
ninuxorg/nodeshot | nodeshot/community/notifications/models/notification.py | Notification.save | def save(self, *args, **kwargs):
"""
custom save method to send email and push notification
"""
created = self.pk is None
# save notification to database only if user settings allow it
if self.check_user_settings(medium='web'):
super(Notification, self).save(... | python | def save(self, *args, **kwargs):
"""
custom save method to send email and push notification
"""
created = self.pk is None
# save notification to database only if user settings allow it
if self.check_user_settings(medium='web'):
super(Notification, self).save(... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"created",
"=",
"self",
".",
"pk",
"is",
"None",
"# save notification to database only if user settings allow it",
"if",
"self",
".",
"check_user_settings",
"(",
"medium",
"=",
"'... | custom save method to send email and push notification | [
"custom",
"save",
"method",
"to",
"send",
"email",
"and",
"push",
"notification"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/models/notification.py#L49-L61 |
ninuxorg/nodeshot | nodeshot/community/notifications/models/notification.py | Notification.send_email | def send_email(self):
""" send email notification according to user settings """
# send only if user notification setting is set to true
if self.check_user_settings():
send_mail(_(self.type), self.email_message, settings.DEFAULT_FROM_EMAIL, [self.to_user.email])
return Tr... | python | def send_email(self):
""" send email notification according to user settings """
# send only if user notification setting is set to true
if self.check_user_settings():
send_mail(_(self.type), self.email_message, settings.DEFAULT_FROM_EMAIL, [self.to_user.email])
return Tr... | [
"def",
"send_email",
"(",
"self",
")",
":",
"# send only if user notification setting is set to true",
"if",
"self",
".",
"check_user_settings",
"(",
")",
":",
"send_mail",
"(",
"_",
"(",
"self",
".",
"type",
")",
",",
"self",
".",
"email_message",
",",
"setting... | send email notification according to user settings | [
"send",
"email",
"notification",
"according",
"to",
"user",
"settings"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/models/notification.py#L67-L75 |
ninuxorg/nodeshot | nodeshot/community/notifications/models/notification.py | Notification.check_user_settings | def check_user_settings(self, medium='email'):
"""
Ensure user is ok with receiving this notification through the specified medium.
Available mediums are 'web' and 'email', while 'mobile' notifications will
hopefully be implemented in the future.
"""
# custom notification... | python | def check_user_settings(self, medium='email'):
"""
Ensure user is ok with receiving this notification through the specified medium.
Available mediums are 'web' and 'email', while 'mobile' notifications will
hopefully be implemented in the future.
"""
# custom notification... | [
"def",
"check_user_settings",
"(",
"self",
",",
"medium",
"=",
"'email'",
")",
":",
"# custom notifications are always sent",
"if",
"self",
".",
"type",
"==",
"'custom'",
":",
"return",
"True",
"try",
":",
"user_settings",
"=",
"getattr",
"(",
"self",
".",
"to... | Ensure user is ok with receiving this notification through the specified medium.
Available mediums are 'web' and 'email', while 'mobile' notifications will
hopefully be implemented in the future. | [
"Ensure",
"user",
"is",
"ok",
"with",
"receiving",
"this",
"notification",
"through",
"the",
"specified",
"medium",
".",
"Available",
"mediums",
"are",
"web",
"and",
"email",
"while",
"mobile",
"notifications",
"will",
"hopefully",
"be",
"implemented",
"in",
"th... | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/models/notification.py#L81-L122 |
ninuxorg/nodeshot | nodeshot/community/notifications/models/notification.py | Notification.email_message | def email_message(self):
""" compose complete email message text """
url = settings.SITE_URL
hello_text = __("Hi %s," % self.to_user.get_full_name())
action_text = __("\n\nMore details here: %s") % url
explain_text = __(
"This is an automatic notification sent from fr... | python | def email_message(self):
""" compose complete email message text """
url = settings.SITE_URL
hello_text = __("Hi %s," % self.to_user.get_full_name())
action_text = __("\n\nMore details here: %s") % url
explain_text = __(
"This is an automatic notification sent from fr... | [
"def",
"email_message",
"(",
"self",
")",
":",
"url",
"=",
"settings",
".",
"SITE_URL",
"hello_text",
"=",
"__",
"(",
"\"Hi %s,\"",
"%",
"self",
".",
"to_user",
".",
"get_full_name",
"(",
")",
")",
"action_text",
"=",
"__",
"(",
"\"\\n\\nMore details here: %... | compose complete email message text | [
"compose",
"complete",
"email",
"message",
"text"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/models/notification.py#L125-L135 |
ninuxorg/nodeshot | nodeshot/interop/sync/synchronizers/openwisp.py | OpenWisp.parse | def parse(self):
""" parse data """
super(OpenWisp, self).parse()
self.parsed_data = self.parsed_data.getElementsByTagName('item') | python | def parse(self):
""" parse data """
super(OpenWisp, self).parse()
self.parsed_data = self.parsed_data.getElementsByTagName('item') | [
"def",
"parse",
"(",
"self",
")",
":",
"super",
"(",
"OpenWisp",
",",
"self",
")",
".",
"parse",
"(",
")",
"self",
".",
"parsed_data",
"=",
"self",
".",
"parsed_data",
".",
"getElementsByTagName",
"(",
"'item'",
")"
] | parse data | [
"parse",
"data"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/synchronizers/openwisp.py#L10-L13 |
ninuxorg/nodeshot | nodeshot/community/profiles/models/emailconfirmation.py | EmailConfirmationManager.generate_key | def generate_key(self, email):
"""
Generate a new email confirmation key and return it.
"""
salt = sha1(str(random())).hexdigest()[:5]
return sha1(salt + email).hexdigest() | python | def generate_key(self, email):
"""
Generate a new email confirmation key and return it.
"""
salt = sha1(str(random())).hexdigest()[:5]
return sha1(salt + email).hexdigest() | [
"def",
"generate_key",
"(",
"self",
",",
"email",
")",
":",
"salt",
"=",
"sha1",
"(",
"str",
"(",
"random",
"(",
")",
")",
")",
".",
"hexdigest",
"(",
")",
"[",
":",
"5",
"]",
"return",
"sha1",
"(",
"salt",
"+",
"email",
")",
".",
"hexdigest",
... | Generate a new email confirmation key and return it. | [
"Generate",
"a",
"new",
"email",
"confirmation",
"key",
"and",
"return",
"it",
"."
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/models/emailconfirmation.py#L127-L132 |
ninuxorg/nodeshot | nodeshot/community/profiles/models/emailconfirmation.py | EmailConfirmationManager.create_emailconfirmation | def create_emailconfirmation(self, email_address):
"Create an email confirmation obj from the given email address obj"
confirmation_key = self.generate_key(email_address.email)
confirmation = self.create(
email_address=email_address,
created_at=now(),
key=conf... | python | def create_emailconfirmation(self, email_address):
"Create an email confirmation obj from the given email address obj"
confirmation_key = self.generate_key(email_address.email)
confirmation = self.create(
email_address=email_address,
created_at=now(),
key=conf... | [
"def",
"create_emailconfirmation",
"(",
"self",
",",
"email_address",
")",
":",
"confirmation_key",
"=",
"self",
".",
"generate_key",
"(",
"email_address",
".",
"email",
")",
"confirmation",
"=",
"self",
".",
"create",
"(",
"email_address",
"=",
"email_address",
... | Create an email confirmation obj from the given email address obj | [
"Create",
"an",
"email",
"confirmation",
"obj",
"from",
"the",
"given",
"email",
"address",
"obj"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/models/emailconfirmation.py#L134-L142 |
ninuxorg/nodeshot | nodeshot/core/metrics/signals.py | user_loggedin | def user_loggedin(sender, **kwargs):
""" collect metrics about user logins """
values = {
'value': 1,
'path': kwargs['request'].path,
'user_id': str(kwargs['user'].pk),
'username': kwargs['user'].username,
}
write('user_logins', values=values) | python | def user_loggedin(sender, **kwargs):
""" collect metrics about user logins """
values = {
'value': 1,
'path': kwargs['request'].path,
'user_id': str(kwargs['user'].pk),
'username': kwargs['user'].username,
}
write('user_logins', values=values) | [
"def",
"user_loggedin",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"values",
"=",
"{",
"'value'",
":",
"1",
",",
"'path'",
":",
"kwargs",
"[",
"'request'",
"]",
".",
"path",
",",
"'user_id'",
":",
"str",
"(",
"kwargs",
"[",
"'user'",
"]",
".... | collect metrics about user logins | [
"collect",
"metrics",
"about",
"user",
"logins"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/metrics/signals.py#L17-L25 |
ninuxorg/nodeshot | nodeshot/core/metrics/signals.py | user_deleted | def user_deleted(sender, **kwargs):
""" collect metrics about new users signing up """
if kwargs.get('created'):
write('user_variations', {'variation': 1}, tags={'action': 'created'})
write('user_count', {'total': User.objects.count()}) | python | def user_deleted(sender, **kwargs):
""" collect metrics about new users signing up """
if kwargs.get('created'):
write('user_variations', {'variation': 1}, tags={'action': 'created'})
write('user_count', {'total': User.objects.count()}) | [
"def",
"user_deleted",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"'created'",
")",
":",
"write",
"(",
"'user_variations'",
",",
"{",
"'variation'",
":",
"1",
"}",
",",
"tags",
"=",
"{",
"'action'",
":",
"'crea... | collect metrics about new users signing up | [
"collect",
"metrics",
"about",
"new",
"users",
"signing",
"up"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/metrics/signals.py#L36-L40 |
ninuxorg/nodeshot | nodeshot/community/participation/models/__init__.py | _node_rating_count | def _node_rating_count(self):
"""
Return node_rating_count record
or create it if it does not exist
usage:
node = Node.objects.get(pk=1)
node.rating_count
"""
try:
return self.noderatingcount
except ObjectDoesNotExist:
node_rating_count = NodeRatingCount(node=self)
... | python | def _node_rating_count(self):
"""
Return node_rating_count record
or create it if it does not exist
usage:
node = Node.objects.get(pk=1)
node.rating_count
"""
try:
return self.noderatingcount
except ObjectDoesNotExist:
node_rating_count = NodeRatingCount(node=self)
... | [
"def",
"_node_rating_count",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"noderatingcount",
"except",
"ObjectDoesNotExist",
":",
"node_rating_count",
"=",
"NodeRatingCount",
"(",
"node",
"=",
"self",
")",
"node_rating_count",
".",
"save",
"(",
")",... | Return node_rating_count record
or create it if it does not exist
usage:
node = Node.objects.get(pk=1)
node.rating_count | [
"Return",
"node_rating_count",
"record",
"or",
"create",
"it",
"if",
"it",
"does",
"not",
"exist"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/participation/models/__init__.py#L68-L82 |
ninuxorg/nodeshot | nodeshot/community/participation/models/__init__.py | _node_participation_settings | def _node_participation_settings(self):
"""
Return node_participation_settings record
or create it if it does not exist
usage:
node = Node.objects.get(pk=1)
node.participation_settings
"""
try:
return self.node_participation_settings
except ObjectDoesNotExist:
node_p... | python | def _node_participation_settings(self):
"""
Return node_participation_settings record
or create it if it does not exist
usage:
node = Node.objects.get(pk=1)
node.participation_settings
"""
try:
return self.node_participation_settings
except ObjectDoesNotExist:
node_p... | [
"def",
"_node_participation_settings",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"node_participation_settings",
"except",
"ObjectDoesNotExist",
":",
"node_participation_settings",
"=",
"NodeParticipationSettings",
"(",
"node",
"=",
"self",
")",
"node_par... | Return node_participation_settings record
or create it if it does not exist
usage:
node = Node.objects.get(pk=1)
node.participation_settings | [
"Return",
"node_participation_settings",
"record",
"or",
"create",
"it",
"if",
"it",
"does",
"not",
"exist"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/participation/models/__init__.py#L88-L102 |
ninuxorg/nodeshot | nodeshot/community/participation/models/__init__.py | _action_allowed | def _action_allowed(self, action):
"""
participation actions can be disabled on layer level, or disabled on a per node basis
"""
if getattr(self.layer.participation_settings, '{0}_allowed'.format(action)) is False:
return False
else:
return getattr(self.participation_settings, '{0}_a... | python | def _action_allowed(self, action):
"""
participation actions can be disabled on layer level, or disabled on a per node basis
"""
if getattr(self.layer.participation_settings, '{0}_allowed'.format(action)) is False:
return False
else:
return getattr(self.participation_settings, '{0}_a... | [
"def",
"_action_allowed",
"(",
"self",
",",
"action",
")",
":",
"if",
"getattr",
"(",
"self",
".",
"layer",
".",
"participation_settings",
",",
"'{0}_allowed'",
".",
"format",
"(",
"action",
")",
")",
"is",
"False",
":",
"return",
"False",
"else",
":",
"... | participation actions can be disabled on layer level, or disabled on a per node basis | [
"participation",
"actions",
"can",
"be",
"disabled",
"on",
"layer",
"level",
"or",
"disabled",
"on",
"a",
"per",
"node",
"basis"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/participation/models/__init__.py#L107-L114 |
ninuxorg/nodeshot | nodeshot/community/participation/models/__init__.py | create_node_rating_counts_settings | def create_node_rating_counts_settings(sender, **kwargs):
""" create node rating count and settings"""
created = kwargs['created']
node = kwargs['instance']
if created:
# create node_rating_count and settings
# task will be executed in background unless settings.CELERY_ALWAYS_EAGER is Tr... | python | def create_node_rating_counts_settings(sender, **kwargs):
""" create node rating count and settings"""
created = kwargs['created']
node = kwargs['instance']
if created:
# create node_rating_count and settings
# task will be executed in background unless settings.CELERY_ALWAYS_EAGER is Tr... | [
"def",
"create_node_rating_counts_settings",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"created",
"=",
"kwargs",
"[",
"'created'",
"]",
"node",
"=",
"kwargs",
"[",
"'instance'",
"]",
"if",
"created",
":",
"# create node_rating_count and settings",
"# task ... | create node rating count and settings | [
"create",
"node",
"rating",
"count",
"and",
"settings"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/participation/models/__init__.py#L147-L156 |
ninuxorg/nodeshot | nodeshot/community/participation/models/__init__.py | create_layer_rating_settings | def create_layer_rating_settings(sender, **kwargs):
""" create layer rating settings """
created = kwargs['created']
layer = kwargs['instance']
if created:
# create layer participation settings
# task will be executed in background unless settings.CELERY_ALWAYS_EAGER is True
# if... | python | def create_layer_rating_settings(sender, **kwargs):
""" create layer rating settings """
created = kwargs['created']
layer = kwargs['instance']
if created:
# create layer participation settings
# task will be executed in background unless settings.CELERY_ALWAYS_EAGER is True
# if... | [
"def",
"create_layer_rating_settings",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"created",
"=",
"kwargs",
"[",
"'created'",
"]",
"layer",
"=",
"kwargs",
"[",
"'instance'",
"]",
"if",
"created",
":",
"# create layer participation settings",
"# task will be... | create layer rating settings | [
"create",
"layer",
"rating",
"settings"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/participation/models/__init__.py#L160-L168 |
ninuxorg/nodeshot | nodeshot/community/profiles/models/profile.py | Profile.save | def save(self, *args, **kwargs):
"""
performs actions on create:
* ensure instance has usable password
* set default group
* keep in sync with email address model
"""
created = self.pk is None
sync_emailaddress = kwargs.pop('sync_emailaddress',... | python | def save(self, *args, **kwargs):
"""
performs actions on create:
* ensure instance has usable password
* set default group
* keep in sync with email address model
"""
created = self.pk is None
sync_emailaddress = kwargs.pop('sync_emailaddress',... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"created",
"=",
"self",
".",
"pk",
"is",
"None",
"sync_emailaddress",
"=",
"kwargs",
".",
"pop",
"(",
"'sync_emailaddress'",
",",
"True",
")",
"# ensure usable password",
"i... | performs actions on create:
* ensure instance has usable password
* set default group
* keep in sync with email address model | [
"performs",
"actions",
"on",
"create",
":",
"*",
"ensure",
"instance",
"has",
"usable",
"password",
"*",
"set",
"default",
"group",
"*",
"keep",
"in",
"sync",
"with",
"email",
"address",
"model"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/models/profile.py#L78-L105 |
ninuxorg/nodeshot | nodeshot/community/profiles/models/profile.py | Profile.needs_confirmation | def needs_confirmation(self):
"""
set is_active to False if needs email confirmation
"""
if EMAIL_CONFIRMATION:
self.is_active = False
self.save()
return True
else:
return False | python | def needs_confirmation(self):
"""
set is_active to False if needs email confirmation
"""
if EMAIL_CONFIRMATION:
self.is_active = False
self.save()
return True
else:
return False | [
"def",
"needs_confirmation",
"(",
"self",
")",
":",
"if",
"EMAIL_CONFIRMATION",
":",
"self",
".",
"is_active",
"=",
"False",
"self",
".",
"save",
"(",
")",
"return",
"True",
"else",
":",
"return",
"False"
] | set is_active to False if needs email confirmation | [
"set",
"is_active",
"to",
"False",
"if",
"needs",
"email",
"confirmation"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/models/profile.py#L124-L133 |
ninuxorg/nodeshot | nodeshot/community/profiles/models/profile.py | Profile.change_password | def change_password(self, new_password):
"""
Changes password and sends a signal
"""
self.set_password(new_password)
self.save()
password_changed.send(sender=self.__class__, user=self) | python | def change_password(self, new_password):
"""
Changes password and sends a signal
"""
self.set_password(new_password)
self.save()
password_changed.send(sender=self.__class__, user=self) | [
"def",
"change_password",
"(",
"self",
",",
"new_password",
")",
":",
"self",
".",
"set_password",
"(",
"new_password",
")",
"self",
".",
"save",
"(",
")",
"password_changed",
".",
"send",
"(",
"sender",
"=",
"self",
".",
"__class__",
",",
"user",
"=",
"... | Changes password and sends a signal | [
"Changes",
"password",
"and",
"sends",
"a",
"signal"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/models/profile.py#L135-L141 |
ninuxorg/nodeshot | nodeshot/community/participation/views.py | NodeRelationViewMixin.initial | def initial(self, request, *args, **kwargs):
"""
Custom initial method:
* ensure node exists and store it in an instance attribute
* change queryset to return only comments of current node
"""
super(NodeRelationViewMixin, self).initial(request, *args, **kwargs)
... | python | def initial(self, request, *args, **kwargs):
"""
Custom initial method:
* ensure node exists and store it in an instance attribute
* change queryset to return only comments of current node
"""
super(NodeRelationViewMixin, self).initial(request, *args, **kwargs)
... | [
"def",
"initial",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"NodeRelationViewMixin",
",",
"self",
")",
".",
"initial",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
"."... | Custom initial method:
* ensure node exists and store it in an instance attribute
* change queryset to return only comments of current node | [
"Custom",
"initial",
"method",
":",
"*",
"ensure",
"node",
"exists",
"and",
"store",
"it",
"in",
"an",
"instance",
"attribute",
"*",
"change",
"queryset",
"to",
"return",
"only",
"comments",
"of",
"current",
"node"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/participation/views.py#L15-L23 |
ninuxorg/nodeshot | nodeshot/community/notifications/models/user_settings.py | add_notifications | def add_notifications(myclass):
"""
Decorator which adds fields dynamically to User Notification Settings models.
Each of the keys in the TEXTS dictionary
are added as a field and DB column.
"""
for key, value in TEXTS.items():
# custom notifications cannot be disabled
if 'custo... | python | def add_notifications(myclass):
"""
Decorator which adds fields dynamically to User Notification Settings models.
Each of the keys in the TEXTS dictionary
are added as a field and DB column.
"""
for key, value in TEXTS.items():
# custom notifications cannot be disabled
if 'custo... | [
"def",
"add_notifications",
"(",
"myclass",
")",
":",
"for",
"key",
",",
"value",
"in",
"TEXTS",
".",
"items",
"(",
")",
":",
"# custom notifications cannot be disabled",
"if",
"'custom'",
"in",
"[",
"key",
",",
"value",
"]",
":",
"continue",
"field_type",
"... | Decorator which adds fields dynamically to User Notification Settings models.
Each of the keys in the TEXTS dictionary
are added as a field and DB column. | [
"Decorator",
"which",
"adds",
"fields",
"dynamically",
"to",
"User",
"Notification",
"Settings",
"models",
"."
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/models/user_settings.py#L7-L37 |
ninuxorg/nodeshot | nodeshot/community/profiles/serializers.py | LoginSerializer.validate | def validate(self, attrs):
""" checks if login credentials are correct """
user = authenticate(**self.user_credentials(attrs))
if user:
if user.is_active:
self.instance = user
else:
raise serializers.ValidationError(_("This account is curr... | python | def validate(self, attrs):
""" checks if login credentials are correct """
user = authenticate(**self.user_credentials(attrs))
if user:
if user.is_active:
self.instance = user
else:
raise serializers.ValidationError(_("This account is curr... | [
"def",
"validate",
"(",
"self",
",",
"attrs",
")",
":",
"user",
"=",
"authenticate",
"(",
"*",
"*",
"self",
".",
"user_credentials",
"(",
"attrs",
")",
")",
"if",
"user",
":",
"if",
"user",
".",
"is_active",
":",
"self",
".",
"instance",
"=",
"user",... | checks if login credentials are correct | [
"checks",
"if",
"login",
"credentials",
"are",
"correct"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/serializers.py#L89-L101 |
ninuxorg/nodeshot | nodeshot/community/profiles/serializers.py | SocialLinkSerializer.get_details | def get_details(self, obj):
""" return detail url """
return reverse('api_user_social_links_detail',
args=[obj.user.username, obj.pk],
request=self.context.get('request'),
format=self.context.get('format')) | python | def get_details(self, obj):
""" return detail url """
return reverse('api_user_social_links_detail',
args=[obj.user.username, obj.pk],
request=self.context.get('request'),
format=self.context.get('format')) | [
"def",
"get_details",
"(",
"self",
",",
"obj",
")",
":",
"return",
"reverse",
"(",
"'api_user_social_links_detail'",
",",
"args",
"=",
"[",
"obj",
".",
"user",
".",
"username",
",",
"obj",
".",
"pk",
"]",
",",
"request",
"=",
"self",
".",
"context",
".... | return detail url | [
"return",
"detail",
"url"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/serializers.py#L108-L113 |
ninuxorg/nodeshot | nodeshot/community/profiles/serializers.py | ProfileSerializer.get_location | def get_location(self, obj):
""" return user's location """
if not obj.city and not obj.country:
return None
elif obj.city and obj.country:
return '%s, %s' % (obj.city, obj.country)
elif obj.city or obj.country:
return obj.city or obj.country | python | def get_location(self, obj):
""" return user's location """
if not obj.city and not obj.country:
return None
elif obj.city and obj.country:
return '%s, %s' % (obj.city, obj.country)
elif obj.city or obj.country:
return obj.city or obj.country | [
"def",
"get_location",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"obj",
".",
"city",
"and",
"not",
"obj",
".",
"country",
":",
"return",
"None",
"elif",
"obj",
".",
"city",
"and",
"obj",
".",
"country",
":",
"return",
"'%s, %s'",
"%",
"(",
"o... | return user's location | [
"return",
"user",
"s",
"location"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/serializers.py#L147-L154 |
ninuxorg/nodeshot | nodeshot/community/profiles/serializers.py | ProfileCreateSerializer.validate_password_confirmation | def validate_password_confirmation(self, value):
""" password_confirmation check """
if value != self.initial_data['password']:
raise serializers.ValidationError(_('Password confirmation mismatch'))
return value | python | def validate_password_confirmation(self, value):
""" password_confirmation check """
if value != self.initial_data['password']:
raise serializers.ValidationError(_('Password confirmation mismatch'))
return value | [
"def",
"validate_password_confirmation",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"!=",
"self",
".",
"initial_data",
"[",
"'password'",
"]",
":",
"raise",
"serializers",
".",
"ValidationError",
"(",
"_",
"(",
"'Password confirmation mismatch'",
")",
"... | password_confirmation check | [
"password_confirmation",
"check"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/serializers.py#L201-L205 |
ninuxorg/nodeshot | nodeshot/community/profiles/serializers.py | ChangePasswordSerializer.validate_current_password | def validate_current_password(self, value):
""" current password check """
if self.instance and self.instance.has_usable_password() and not self.instance.check_password(value):
raise serializers.ValidationError(_('Current password is not correct'))
return value | python | def validate_current_password(self, value):
""" current password check """
if self.instance and self.instance.has_usable_password() and not self.instance.check_password(value):
raise serializers.ValidationError(_('Current password is not correct'))
return value | [
"def",
"validate_current_password",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"instance",
"and",
"self",
".",
"instance",
".",
"has_usable_password",
"(",
")",
"and",
"not",
"self",
".",
"instance",
".",
"check_password",
"(",
"value",
")",
"... | current password check | [
"current",
"password",
"check"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/serializers.py#L264-L268 |
ninuxorg/nodeshot | nodeshot/community/profiles/serializers.py | ChangePasswordSerializer.validate_password2 | def validate_password2(self, value):
""" password_confirmation check """
if value != self.initial_data['password1']:
raise serializers.ValidationError(_('Password confirmation mismatch'))
return value | python | def validate_password2(self, value):
""" password_confirmation check """
if value != self.initial_data['password1']:
raise serializers.ValidationError(_('Password confirmation mismatch'))
return value | [
"def",
"validate_password2",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"!=",
"self",
".",
"initial_data",
"[",
"'password1'",
"]",
":",
"raise",
"serializers",
".",
"ValidationError",
"(",
"_",
"(",
"'Password confirmation mismatch'",
")",
")",
"retu... | password_confirmation check | [
"password_confirmation",
"check"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/serializers.py#L270-L274 |
ninuxorg/nodeshot | nodeshot/community/profiles/serializers.py | ResetPasswordSerializer.validate_email | def validate_email(self, value):
""" ensure email is in the database """
if EMAIL_CONFIRMATION:
queryset = EmailAddress.objects.filter(email__iexact=value, verified=True)
else:
queryset = User.objects.get(email__iexact=value, is_active=True).count() == 0
if querys... | python | def validate_email(self, value):
""" ensure email is in the database """
if EMAIL_CONFIRMATION:
queryset = EmailAddress.objects.filter(email__iexact=value, verified=True)
else:
queryset = User.objects.get(email__iexact=value, is_active=True).count() == 0
if querys... | [
"def",
"validate_email",
"(",
"self",
",",
"value",
")",
":",
"if",
"EMAIL_CONFIRMATION",
":",
"queryset",
"=",
"EmailAddress",
".",
"objects",
".",
"filter",
"(",
"email__iexact",
"=",
"value",
",",
"verified",
"=",
"True",
")",
"else",
":",
"queryset",
"... | ensure email is in the database | [
"ensure",
"email",
"is",
"in",
"the",
"database"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/serializers.py#L285-L293 |
ninuxorg/nodeshot | nodeshot/community/profiles/serializers.py | ResetPasswordKeySerializer.update | def update(self, instance, validated_data):
""" change password """
instance.user.set_password(validated_data["password1"])
instance.user.full_clean()
instance.user.save()
# mark password reset object as reset
instance.reset = True
instance.full_clean()
in... | python | def update(self, instance, validated_data):
""" change password """
instance.user.set_password(validated_data["password1"])
instance.user.full_clean()
instance.user.save()
# mark password reset object as reset
instance.reset = True
instance.full_clean()
in... | [
"def",
"update",
"(",
"self",
",",
"instance",
",",
"validated_data",
")",
":",
"instance",
".",
"user",
".",
"set_password",
"(",
"validated_data",
"[",
"\"password1\"",
"]",
")",
"instance",
".",
"user",
".",
"full_clean",
"(",
")",
"instance",
".",
"use... | change password | [
"change",
"password"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/serializers.py#L312-L321 |
ninuxorg/nodeshot | nodeshot/networking/net/models/device.py | Device.save | def save(self, *args, **kwargs):
"""
Custom save method does the following:
* automatically inherit node coordinates and elevation
* save shortcuts if HSTORE is enabled
"""
custom_checks = kwargs.pop('custom_checks', True)
super(Device, self).save(*args, ... | python | def save(self, *args, **kwargs):
"""
Custom save method does the following:
* automatically inherit node coordinates and elevation
* save shortcuts if HSTORE is enabled
"""
custom_checks = kwargs.pop('custom_checks', True)
super(Device, self).save(*args, ... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"custom_checks",
"=",
"kwargs",
".",
"pop",
"(",
"'custom_checks'",
",",
"True",
")",
"super",
"(",
"Device",
",",
"self",
")",
".",
"save",
"(",
"*",
"args",
",",
"... | Custom save method does the following:
* automatically inherit node coordinates and elevation
* save shortcuts if HSTORE is enabled | [
"Custom",
"save",
"method",
"does",
"the",
"following",
":",
"*",
"automatically",
"inherit",
"node",
"coordinates",
"and",
"elevation",
"*",
"save",
"shortcuts",
"if",
"HSTORE",
"is",
"enabled"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/networking/net/models/device.py#L60-L99 |
ninuxorg/nodeshot | nodeshot/community/profiles/models/password_reset.py | PasswordResetManager.create_for_user | def create_for_user(self, user):
""" create password reset for specified user """
# support passing email address too
if type(user) is unicode:
from .profile import Profile as User
user = User.objects.get(email=user)
temp_key = token_generator.make_token(user)
... | python | def create_for_user(self, user):
""" create password reset for specified user """
# support passing email address too
if type(user) is unicode:
from .profile import Profile as User
user = User.objects.get(email=user)
temp_key = token_generator.make_token(user)
... | [
"def",
"create_for_user",
"(",
"self",
",",
"user",
")",
":",
"# support passing email address too",
"if",
"type",
"(",
"user",
")",
"is",
"unicode",
":",
"from",
".",
"profile",
"import",
"Profile",
"as",
"User",
"user",
"=",
"User",
".",
"objects",
".",
... | create password reset for specified user | [
"create",
"password",
"reset",
"for",
"specified",
"user"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/models/password_reset.py#L17-L41 |
ninuxorg/nodeshot | nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py | Command.handle | def handle(self, *args, **options):
""" execute synchronize command """
self.options = options
delete = False
try:
# blank line
self.stdout.write('\r\n')
# store verbosity level in instance attribute for later use
self.verbosity = int(self... | python | def handle(self, *args, **options):
""" execute synchronize command """
self.options = options
delete = False
try:
# blank line
self.stdout.write('\r\n')
# store verbosity level in instance attribute for later use
self.verbosity = int(self... | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"options",
"=",
"options",
"delete",
"=",
"False",
"try",
":",
"# blank line",
"self",
".",
"stdout",
".",
"write",
"(",
"'\\r\\n'",
")",
"# store verbosit... | execute synchronize command | [
"execute",
"synchronize",
"command"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py#L129-L173 |
ninuxorg/nodeshot | nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py | Command.prompt_layer_selection | def prompt_layer_selection(self, node, layers):
"""Ask user what to do when an old node is contained in more than one layer.
Possible answers are:
* use default layer (default answer if pressing enter)
* choose layer
* discard node
"""
valid = {
... | python | def prompt_layer_selection(self, node, layers):
"""Ask user what to do when an old node is contained in more than one layer.
Possible answers are:
* use default layer (default answer if pressing enter)
* choose layer
* discard node
"""
valid = {
... | [
"def",
"prompt_layer_selection",
"(",
"self",
",",
"node",
",",
"layers",
")",
":",
"valid",
"=",
"{",
"\"default\"",
":",
"\"default\"",
",",
"\"def\"",
":",
"\"default\"",
",",
"\"discard\"",
":",
"\"discard\"",
",",
"\"dis\"",
":",
"\"discard\"",
",",
"}"... | Ask user what to do when an old node is contained in more than one layer.
Possible answers are:
* use default layer (default answer if pressing enter)
* choose layer
* discard node | [
"Ask",
"user",
"what",
"to",
"do",
"when",
"an",
"old",
"node",
"is",
"contained",
"in",
"more",
"than",
"one",
"layer",
".",
"Possible",
"answers",
"are",
":",
"*",
"use",
"default",
"layer",
"(",
"default",
"answer",
"if",
"pressing",
"enter",
")",
"... | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py#L246-L293 |
ninuxorg/nodeshot | nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py | Command.check_status_mapping | def check_status_mapping(self):
""" ensure status map does not contain status values which are not present in DB """
self.verbose('checking status mapping...')
if not self.status_mapping:
self.message('no status mapping found')
return
for old_val, new_val in sel... | python | def check_status_mapping(self):
""" ensure status map does not contain status values which are not present in DB """
self.verbose('checking status mapping...')
if not self.status_mapping:
self.message('no status mapping found')
return
for old_val, new_val in sel... | [
"def",
"check_status_mapping",
"(",
"self",
")",
":",
"self",
".",
"verbose",
"(",
"'checking status mapping...'",
")",
"if",
"not",
"self",
".",
"status_mapping",
":",
"self",
".",
"message",
"(",
"'no status mapping found'",
")",
"return",
"for",
"old_val",
",... | ensure status map does not contain status values which are not present in DB | [
"ensure",
"status",
"map",
"does",
"not",
"contain",
"status",
"values",
"which",
"are",
"not",
"present",
"in",
"DB"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py#L299-L320 |
ninuxorg/nodeshot | nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py | Command.retrieve_nodes | def retrieve_nodes(self):
""" retrieve nodes from old mysql DB """
self.verbose('retrieving nodes from old mysql DB...')
self.old_nodes = list(OldNode.objects.all())
self.message('retrieved %d nodes' % len(self.old_nodes)) | python | def retrieve_nodes(self):
""" retrieve nodes from old mysql DB """
self.verbose('retrieving nodes from old mysql DB...')
self.old_nodes = list(OldNode.objects.all())
self.message('retrieved %d nodes' % len(self.old_nodes)) | [
"def",
"retrieve_nodes",
"(",
"self",
")",
":",
"self",
".",
"verbose",
"(",
"'retrieving nodes from old mysql DB...'",
")",
"self",
".",
"old_nodes",
"=",
"list",
"(",
"OldNode",
".",
"objects",
".",
"all",
"(",
")",
")",
"self",
".",
"message",
"(",
"'re... | retrieve nodes from old mysql DB | [
"retrieve",
"nodes",
"from",
"old",
"mysql",
"DB"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py#L325-L330 |
ninuxorg/nodeshot | nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py | Command.extract_users | def extract_users(self):
""" extract user info """
email_set = set()
users_dict = {}
self.verbose('going to extract user information from retrieved nodes...')
for node in self.old_nodes:
email_set.add(node.email)
if node.email not in users_dict:
... | python | def extract_users(self):
""" extract user info """
email_set = set()
users_dict = {}
self.verbose('going to extract user information from retrieved nodes...')
for node in self.old_nodes:
email_set.add(node.email)
if node.email not in users_dict:
... | [
"def",
"extract_users",
"(",
"self",
")",
":",
"email_set",
"=",
"set",
"(",
")",
"users_dict",
"=",
"{",
"}",
"self",
".",
"verbose",
"(",
"'going to extract user information from retrieved nodes...'",
")",
"for",
"node",
"in",
"self",
".",
"old_nodes",
":",
... | extract user info | [
"extract",
"user",
"info"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py#L332-L350 |
ninuxorg/nodeshot | nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py | Command.import_admins | def import_admins(self):
""" save admins to local DB """
self.message('saving admins into local DB')
saved_admins = []
for olduser in OldUser.objects.all():
try:
user = User.objects.get(Q(username=olduser.username) | Q(email=olduser.email))
excep... | python | def import_admins(self):
""" save admins to local DB """
self.message('saving admins into local DB')
saved_admins = []
for olduser in OldUser.objects.all():
try:
user = User.objects.get(Q(username=olduser.username) | Q(email=olduser.email))
excep... | [
"def",
"import_admins",
"(",
"self",
")",
":",
"self",
".",
"message",
"(",
"'saving admins into local DB'",
")",
"saved_admins",
"=",
"[",
"]",
"for",
"olduser",
"in",
"OldUser",
".",
"objects",
".",
"all",
"(",
")",
":",
"try",
":",
"user",
"=",
"User"... | save admins to local DB | [
"save",
"admins",
"to",
"local",
"DB"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py#L352-L390 |
ninuxorg/nodeshot | nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py | Command.import_users | def import_users(self):
""" save users to local DB """
self.message('saving users into local DB')
saved_users = self.saved_admins
# loop over all extracted unique email addresses
for email in self.email_set:
owner = self.users_dict[email].get('owner')
#... | python | def import_users(self):
""" save users to local DB """
self.message('saving users into local DB')
saved_users = self.saved_admins
# loop over all extracted unique email addresses
for email in self.email_set:
owner = self.users_dict[email].get('owner')
#... | [
"def",
"import_users",
"(",
"self",
")",
":",
"self",
".",
"message",
"(",
"'saving users into local DB'",
")",
"saved_users",
"=",
"self",
".",
"saved_admins",
"# loop over all extracted unique email addresses",
"for",
"email",
"in",
"self",
".",
"email_set",
":",
... | save users to local DB | [
"save",
"users",
"to",
"local",
"DB"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py#L392-L486 |
ninuxorg/nodeshot | nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py | Command.import_nodes | def import_nodes(self):
""" import nodes into local DB """
self.message('saving nodes into local DB...')
saved_nodes = []
# loop over all old node and create new nodes
for old_node in self.old_nodes:
# if this old node is unconfirmed skip to next cycle
i... | python | def import_nodes(self):
""" import nodes into local DB """
self.message('saving nodes into local DB...')
saved_nodes = []
# loop over all old node and create new nodes
for old_node in self.old_nodes:
# if this old node is unconfirmed skip to next cycle
i... | [
"def",
"import_nodes",
"(",
"self",
")",
":",
"self",
".",
"message",
"(",
"'saving nodes into local DB...'",
")",
"saved_nodes",
"=",
"[",
"]",
"# loop over all old node and create new nodes",
"for",
"old_node",
"in",
"self",
".",
"old_nodes",
":",
"# if this old nod... | import nodes into local DB | [
"import",
"nodes",
"into",
"local",
"DB"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py#L488-L564 |
ninuxorg/nodeshot | nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py | Command.check_deleted_nodes | def check_deleted_nodes(self):
""" delete imported nodes that are not present in the old database """
imported_nodes = Node.objects.filter(data__contains=['imported'])
deleted_nodes = []
for node in imported_nodes:
if OldNode.objects.filter(pk=node.pk).count() == 0:
... | python | def check_deleted_nodes(self):
""" delete imported nodes that are not present in the old database """
imported_nodes = Node.objects.filter(data__contains=['imported'])
deleted_nodes = []
for node in imported_nodes:
if OldNode.objects.filter(pk=node.pk).count() == 0:
... | [
"def",
"check_deleted_nodes",
"(",
"self",
")",
":",
"imported_nodes",
"=",
"Node",
".",
"objects",
".",
"filter",
"(",
"data__contains",
"=",
"[",
"'imported'",
"]",
")",
"deleted_nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"imported_nodes",
":",
"if",
"O... | delete imported nodes that are not present in the old database | [
"delete",
"imported",
"nodes",
"that",
"are",
"not",
"present",
"in",
"the",
"old",
"database"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/oldimporter/management/commands/import_old_nodeshot.py#L566-L582 |
ninuxorg/nodeshot | nodeshot/community/notifications/signals.py | create_settings | def create_settings(sender, **kwargs):
""" create user notification settings on user creation """
created = kwargs['created']
user = kwargs['instance']
if created:
UserWebNotificationSettings.objects.create(user=user)
UserEmailNotificationSettings.objects.create(user=user) | python | def create_settings(sender, **kwargs):
""" create user notification settings on user creation """
created = kwargs['created']
user = kwargs['instance']
if created:
UserWebNotificationSettings.objects.create(user=user)
UserEmailNotificationSettings.objects.create(user=user) | [
"def",
"create_settings",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"created",
"=",
"kwargs",
"[",
"'created'",
"]",
"user",
"=",
"kwargs",
"[",
"'instance'",
"]",
"if",
"created",
":",
"UserWebNotificationSettings",
".",
"objects",
".",
"create",
... | create user notification settings on user creation | [
"create",
"user",
"notification",
"settings",
"on",
"user",
"creation"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/signals.py#L11-L17 |
ninuxorg/nodeshot | nodeshot/community/profiles/apps.py | AppConfig.ready | def ready(self):
""" Add user info to ExtensibleNodeSerializer """
from nodeshot.core.nodes.base import ExtensibleNodeSerializer
from .serializers import ProfileRelationSerializer
ExtensibleNodeSerializer.add_relationship(
name='user',
serializer=ProfileRelationS... | python | def ready(self):
""" Add user info to ExtensibleNodeSerializer """
from nodeshot.core.nodes.base import ExtensibleNodeSerializer
from .serializers import ProfileRelationSerializer
ExtensibleNodeSerializer.add_relationship(
name='user',
serializer=ProfileRelationS... | [
"def",
"ready",
"(",
"self",
")",
":",
"from",
"nodeshot",
".",
"core",
".",
"nodes",
".",
"base",
"import",
"ExtensibleNodeSerializer",
"from",
".",
"serializers",
"import",
"ProfileRelationSerializer",
"ExtensibleNodeSerializer",
".",
"add_relationship",
"(",
"nam... | Add user info to ExtensibleNodeSerializer | [
"Add",
"user",
"info",
"to",
"ExtensibleNodeSerializer"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/profiles/apps.py#L7-L16 |
ninuxorg/nodeshot | nodeshot/interop/sync/synchronizers/geojson.py | GeoJson.parse | def parse(self):
""" parse geojson and ensure is collection """
try:
self.parsed_data = json.loads(self.data)
except UnicodeError as e:
self.parsed_data = json.loads(self.data.decode('latin1'))
except Exception as e:
raise Exception('Error while conver... | python | def parse(self):
""" parse geojson and ensure is collection """
try:
self.parsed_data = json.loads(self.data)
except UnicodeError as e:
self.parsed_data = json.loads(self.data.decode('latin1'))
except Exception as e:
raise Exception('Error while conver... | [
"def",
"parse",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"parsed_data",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"data",
")",
"except",
"UnicodeError",
"as",
"e",
":",
"self",
".",
"parsed_data",
"=",
"json",
".",
"loads",
"(",
"self",
"... | parse geojson and ensure is collection | [
"parse",
"geojson",
"and",
"ensure",
"is",
"collection"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/synchronizers/geojson.py#L11-L23 |
ninuxorg/nodeshot | nodeshot/core/base/serializers.py | DynamicRelationshipsMixin.add_relationship | def add_relationship(_class, name,
view_name=None, lookup_field=None,
serializer=None, many=False, queryset=None,
function=None):
""" adds a relationship to serializer
:param name: relationship name (dictionary key)
:type... | python | def add_relationship(_class, name,
view_name=None, lookup_field=None,
serializer=None, many=False, queryset=None,
function=None):
""" adds a relationship to serializer
:param name: relationship name (dictionary key)
:type... | [
"def",
"add_relationship",
"(",
"_class",
",",
"name",
",",
"view_name",
"=",
"None",
",",
"lookup_field",
"=",
"None",
",",
"serializer",
"=",
"None",
",",
"many",
"=",
"False",
",",
"queryset",
"=",
"None",
",",
"function",
"=",
"None",
")",
":",
"if... | adds a relationship to serializer
:param name: relationship name (dictionary key)
:type name: str
:param view_name: view name as specified in urls.py
:type view_name: str
:param lookup_field: lookup field, usually slug or id/pk
:type lookup_field: str
:param seria... | [
"adds",
"a",
"relationship",
"to",
"serializer",
":",
"param",
"name",
":",
"relationship",
"name",
"(",
"dictionary",
"key",
")",
":",
"type",
"name",
":",
"str",
":",
"param",
"view_name",
":",
"view",
"name",
"as",
"specified",
"in",
"urls",
".",
"py"... | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/base/serializers.py#L44-L84 |
ninuxorg/nodeshot | nodeshot/interop/sync/synchronizers/cnml.py | Cnml.parse | def parse(self):
""" parse data """
url = self.config.get('url')
self.cnml = CNMLParser(url)
self.parsed_data = self.cnml.getNodes() | python | def parse(self):
""" parse data """
url = self.config.get('url')
self.cnml = CNMLParser(url)
self.parsed_data = self.cnml.getNodes() | [
"def",
"parse",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'url'",
")",
"self",
".",
"cnml",
"=",
"CNMLParser",
"(",
"url",
")",
"self",
".",
"parsed_data",
"=",
"self",
".",
"cnml",
".",
"getNodes",
"(",
")"
] | parse data | [
"parse",
"data"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/synchronizers/cnml.py#L130-L134 |
ninuxorg/nodeshot | nodeshot/community/notifications/management/commands/purge_notifications.py | Command.retrieve_old_notifications | def retrieve_old_notifications(self):
"""
Retrieve notifications older than X days, where X is specified in settings
"""
date = ago(days=DELETE_OLD)
return Notification.objects.filter(added__lte=date) | python | def retrieve_old_notifications(self):
"""
Retrieve notifications older than X days, where X is specified in settings
"""
date = ago(days=DELETE_OLD)
return Notification.objects.filter(added__lte=date) | [
"def",
"retrieve_old_notifications",
"(",
"self",
")",
":",
"date",
"=",
"ago",
"(",
"days",
"=",
"DELETE_OLD",
")",
"return",
"Notification",
".",
"objects",
".",
"filter",
"(",
"added__lte",
"=",
"date",
")"
] | Retrieve notifications older than X days, where X is specified in settings | [
"Retrieve",
"notifications",
"older",
"than",
"X",
"days",
"where",
"X",
"is",
"specified",
"in",
"settings"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/management/commands/purge_notifications.py#L12-L19 |
ninuxorg/nodeshot | nodeshot/community/notifications/management/commands/purge_notifications.py | Command.handle | def handle(self, *args, **options):
""" Purge notifications """
# retrieve layers
notifications = self.retrieve_old_notifications()
count = len(notifications)
if count > 0:
self.output('found %d notifications to purge...' % count)
notifications.delete()
... | python | def handle(self, *args, **options):
""" Purge notifications """
# retrieve layers
notifications = self.retrieve_old_notifications()
count = len(notifications)
if count > 0:
self.output('found %d notifications to purge...' % count)
notifications.delete()
... | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"# retrieve layers",
"notifications",
"=",
"self",
".",
"retrieve_old_notifications",
"(",
")",
"count",
"=",
"len",
"(",
"notifications",
")",
"if",
"count",
">",
"0",
"... | Purge notifications | [
"Purge",
"notifications"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/management/commands/purge_notifications.py#L24-L35 |
ninuxorg/nodeshot | nodeshot/interop/sync/tasks.py | push_changes_to_external_layers | def push_changes_to_external_layers(node, external_layer, operation):
"""
Sync other applications through their APIs by performing updates, adds or deletes.
This method is designed to be performed asynchronously, avoiding blocking the user
when he changes data on the local DB.
:param node: the node... | python | def push_changes_to_external_layers(node, external_layer, operation):
"""
Sync other applications through their APIs by performing updates, adds or deletes.
This method is designed to be performed asynchronously, avoiding blocking the user
when he changes data on the local DB.
:param node: the node... | [
"def",
"push_changes_to_external_layers",
"(",
"node",
",",
"external_layer",
",",
"operation",
")",
":",
"# putting the model inside prevents circular imports",
"# subsequent imports go and look into sys.modules before reimporting the module again",
"# so performance is not affected",
"fr... | Sync other applications through their APIs by performing updates, adds or deletes.
This method is designed to be performed asynchronously, avoiding blocking the user
when he changes data on the local DB.
:param node: the node which should be updated on the external layer.
:type node: Node model instanc... | [
"Sync",
"other",
"applications",
"through",
"their",
"APIs",
"by",
"performing",
"updates",
"adds",
"or",
"deletes",
".",
"This",
"method",
"is",
"designed",
"to",
"be",
"performed",
"asynchronously",
"avoiding",
"blocking",
"the",
"user",
"when",
"he",
"changes... | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/tasks.py#L18-L43 |
ninuxorg/nodeshot | nodeshot/core/websockets/tasks.py | send_message | def send_message(message, pipe='public'):
"""
writes message to pipe
"""
if pipe not in ['public', 'private']:
raise ValueError('pipe argument can be only "public" or "private"')
else:
pipe = pipe.upper()
pipe_path = PUBLIC_PIPE if pipe == 'PUBLIC' else PRIVATE_PIPE
# creat... | python | def send_message(message, pipe='public'):
"""
writes message to pipe
"""
if pipe not in ['public', 'private']:
raise ValueError('pipe argument can be only "public" or "private"')
else:
pipe = pipe.upper()
pipe_path = PUBLIC_PIPE if pipe == 'PUBLIC' else PRIVATE_PIPE
# creat... | [
"def",
"send_message",
"(",
"message",
",",
"pipe",
"=",
"'public'",
")",
":",
"if",
"pipe",
"not",
"in",
"[",
"'public'",
",",
"'private'",
"]",
":",
"raise",
"ValueError",
"(",
"'pipe argument can be only \"public\" or \"private\"'",
")",
"else",
":",
"pipe",
... | writes message to pipe | [
"writes",
"message",
"to",
"pipe"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/websockets/tasks.py#L6-L21 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.