ucsschool.http_api.import_api package#
Subpackages#
Submodules#
ucsschool.http_api.import_api.admin module#
Django Admin
- class ucsschool.http_api.import_api.admin.UserQueryFilterMixin[source]#
Bases:
object- ordering = ('-id',)#
- class ucsschool.http_api.import_api.admin.ProxyModelFilterMixin[source]#
Bases:
object- readonly_fields = ('text_loaded',)#
- class ucsschool.http_api.import_api.admin.UserImportJobAdmin(model, admin_site)[source]#
Bases:
UserQueryFilterMixin,ModelAdmin- list_display = ('id', 'school', 'status', 'principal', 'dryrun', 'user_role')#
- search_fields = ('id', 'school__name', 'source_uid', 'status', 'principal__username', 'user_role')#
- list_filter = ('school__name', 'status', 'principal', 'dryrun', 'user_role')#
- ordering = ('-id',)#
- property media#
- class ucsschool.http_api.import_api.admin.LogFileAdmin(model, admin_site)[source]#
Bases:
ProxyModelFilterMixin,ModelAdmin- property media#
- class ucsschool.http_api.import_api.admin.PasswordsFileAdmin(model, admin_site)[source]#
Bases:
ProxyModelFilterMixin,ModelAdmin- property media#
- class ucsschool.http_api.import_api.admin.SummaryFileAdmin(model, admin_site)[source]#
Bases:
ProxyModelFilterMixin,ModelAdmin- property media#
- class ucsschool.http_api.import_api.admin.TaskMetaAdmin(model, admin_site)[source]#
Bases:
UserQueryFilterMixin,ModelAdmin- ordering = ('-id',)#
- get_queryset(request)[source]#
Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.
- property media#
ucsschool.http_api.import_api.apps module#
App registry
ucsschool.http_api.import_api.constants module#
Constants
ucsschool.http_api.import_api.http_api_import_frontend module#
UCS@school import frontend class
- class ucsschool.http_api.import_api.http_api_import_frontend.HttpApiImportFrontend(import_job, task, logger)[source]#
Bases:
UserImportCommandLineFake cmdline import frontend class. Simulates argparse results and starts import.
- http_api_specific_config = 'user_import_http-api.json'#
- import_initiator = 'HTTP API'#
- reader_class = 'ucsschool.importer.reader.http_api_csv_reader.HttpApiCsvReader'#
- property configuration_files#
User import configuration files.
- static make_job_state(description, percentage=0, done=0, total=0, celery_task_state='STARTED', **kwargs)[source]#
ucsschool.http_api.import_api.import_logging module#
Logging configuration for the HTTP API
ucsschool.http_api.import_api.models module#
Database / Resource models
- class ucsschool.http_api.import_api.models.Role(name, displayName)[source]#
Bases:
Model- name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- displayName#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod update_from_ldap()[source]#
Update Role objects from LDAP. Currently static values are used and no LDAP query is done. This might change in the future.
- Returns:
None
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- objects = <django.db.models.manager.Manager object>#
- class ucsschool.http_api.import_api.models.School(name, displayName)[source]#
Bases:
Model- name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- displayName#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod update_from_ldap(ou_str=None)[source]#
Update one or all School objects from OUs in LDAP.
- Parameters:
ou_str (str) – name of School object to update, all will be updated if None
- Returns:
None
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- objects = <django.db.models.manager.Manager object>#
- userimportjob_set#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- class ucsschool.http_api.import_api.models.TextArtifact(id, path, text)[source]#
Bases:
Model- path#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- text#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- userimportjob_log_file#
Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Place.restaurantis aReverseOneToOneDescriptorinstance.
- userimportjob_password_file#
Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Place.restaurantis aReverseOneToOneDescriptorinstance.
- userimportjob_summary_file#
Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Place.restaurantis aReverseOneToOneDescriptorinstance.
- class ucsschool.http_api.import_api.models.Logfile(id, path, text)[source]#
Bases:
TextArtifact- exception DoesNotExist#
Bases:
DoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- class ucsschool.http_api.import_api.models.PasswordsFile(id, path, text)[source]#
Bases:
TextArtifact- exception DoesNotExist#
Bases:
DoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- class ucsschool.http_api.import_api.models.SummaryFile(id, path, text)[source]#
Bases:
TextArtifact- exception DoesNotExist#
Bases:
DoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- class ucsschool.http_api.import_api.models.UserImportJob(id, dryrun, principal, school, source_uid, status, user_role, task_id, result, log_file, password_file, summary_file, basedir, date_created, input_file)[source]#
Bases:
Model- dryrun#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- principal#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- school#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- source_uid#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- status#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- user_role#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- task_id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- result#
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.placeis aForwardOneToOneDescriptorinstance.
- log_file#
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.placeis aForwardOneToOneDescriptorinstance.
- password_file#
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.placeis aForwardOneToOneDescriptorinstance.
- summary_file#
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.placeis aForwardOneToOneDescriptorinstance.
- basedir#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- date_created#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- input_file#
The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:
>>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size
Assign a file object on assignment so you can do:
>>> with open('/path/to/hello.world') as f: ... instance.file = File(f)
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- get_next_by_date_created(*, field=<django.db.models.fields.DateTimeField: date_created>, is_next=True, **kwargs)#
- get_previous_by_date_created(*, field=<django.db.models.fields.DateTimeField: date_created>, is_next=False, **kwargs)#
- get_status_display(*, field=<django.db.models.fields.CharField: status>)#
- get_user_role_display(*, field=<django.db.models.fields.CharField: user_role>)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- log_file_id#
- objects = <django.db.models.manager.Manager object>#
- password_file_id#
- principal_id#
- result_id#
- school_id#
- summary_file_id#
ucsschool.http_api.import_api.serializers module#
Model/HTTP-API Serializers
- class ucsschool.http_api.import_api.serializers.TaskResultSerializer(*args, **kwargs)[source]#
Bases:
HyperlinkedModelSerializerWhen a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object.
- class ucsschool.http_api.import_api.serializers.UsernameField(*args, **kwargs)[source]#
Bases:
CharFieldReduce a Django user object to its username string.
When a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object.
- class ucsschool.http_api.import_api.serializers.UserImportJobCreationValidator(request)[source]#
Bases:
object
- class ucsschool.http_api.import_api.serializers.UserImportJobSerializer(*args, **kwargs)[source]#
Bases:
HyperlinkedModelSerializerWhen a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object.
- class Meta[source]#
Bases:
object- model#
alias of
UserImportJob
- fields = ('id', 'url', 'date_created', 'dryrun', 'input_file', 'principal', 'result', 'school', 'status', 'user_role', 'log_file', 'password_file', 'summary_file')#
- read_only_fields = ('id', 'created', 'status', 'result', 'principal', 'source_uid')#
- class ucsschool.http_api.import_api.serializers.TextArtifactSerializer(*args, **kwargs)[source]#
Bases:
HyperlinkedModelSerializerWhen a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object.
- class ucsschool.http_api.import_api.serializers.LogFileSerializer(*args, **kwargs)[source]#
Bases:
TextArtifactSerializerWhen a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object.
- class ucsschool.http_api.import_api.serializers.PasswordFileSerializer(*args, **kwargs)[source]#
Bases:
TextArtifactSerializerWhen a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object.
- class ucsschool.http_api.import_api.serializers.SummarySerializer(*args, **kwargs)[source]#
Bases:
TextArtifactSerializerWhen a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object.
- class ucsschool.http_api.import_api.serializers.RoleSerializer(*args, **kwargs)[source]#
Bases:
HyperlinkedModelSerializerWhen a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object.
ucsschool.http_api.import_api.tasks module#
Celery tasks
ucsschool.http_api.import_api.utils module#
Diverse helper functions.
ucsschool.http_api.import_api.views module#
Django Views
- class ucsschool.http_api.import_api.views.UserImportJobFilter(data=None, queryset=None, *, request=None, prefix=None)[source]#
Bases:
FilterSetUsed to filter the principal field by ‘username’ (DjangoFilterBackend works automatically only on pk).
- class Meta[source]#
Bases:
object- model#
alias of
UserImportJob
- fields = ['id', 'dryrun', 'principal', 'school', 'source_uid', 'status', 'user_role']#
- base_filters = {'dryrun': <django_filters.rest_framework.filters.BooleanFilter object>, 'id': <django_filters.filters.NumberFilter object>, 'principal': <django_filters.filters.CharFilter object>, 'school': <django_filters.filters.ModelChoiceFilter object>, 'source_uid': <django_filters.filters.CharFilter object>, 'status': <django_filters.filters.MultipleChoiceFilter object>, 'user_role': <django_filters.filters.ChoiceFilter object>}#
- declared_filters = {'principal': <django_filters.filters.CharFilter object>, 'status': <django_filters.filters.MultipleChoiceFilter object>}#
- class ucsschool.http_api.import_api.views.RoleFilterBackend[source]#
Bases:
BaseFilterBackendUsed to list only Roles the user has any permissions on.
- filter_s = '(&(objectClass=ucsschoolImportGroup)(ucsschoolImportRole=*)(ucsschoolImportSchool={})(memberUid=%s))'#
- filter_attrs = ('ucsschoolImportRole', 'ucsschoolImportSchool')#
- class ucsschool.http_api.import_api.views.SchoolFilterBackend[source]#
Bases:
BaseFilterBackendUsed to list only Schools the user has any permissions on.
- filter_s = '(&(objectClass=ucsschoolImportGroup)(ucsschoolImportRole=*)(ucsschoolImportSchool=*)(memberUid=%s))'#
- filter_attrs = ('ucsschoolImportSchool',)#
- class ucsschool.http_api.import_api.views.UserImportJobFilterBackend[source]#
Bases:
BaseFilterBackendUsed to list only ImportJobs the user has any permissions on.
- filter_s = '(&(objectClass=ucsschoolImportGroup)(ucsschoolImportRole=*)(ucsschoolImportSchool=*)(memberUid=%s))'#
- filter_attrs = ('ucsschoolImportRole', 'ucsschoolImportSchool')#
- class ucsschool.http_api.import_api.views.RoleViewPermission[source]#
Bases:
BasePermissionUsed to read only Role objects the user has any permissions on.
- class ucsschool.http_api.import_api.views.SchoolViewPermission[source]#
Bases:
BasePermissionUsed to read only School objects the user has any permissions on.
- class ucsschool.http_api.import_api.views.TextArtifactViewPermission[source]#
Bases:
BasePermissionUsed to read only TextArtifact objects (LogFile, PasswordsFile, SummaryFile) the user has any permissions on.
- class ucsschool.http_api.import_api.views.UserImportJobViewPermission[source]#
Bases:
BasePermissionUsed to read only UserImport objects the user has any permissions on.
- class ucsschool.http_api.import_api.views.UserImportJobViewSet(**kwargs)[source]#
Bases:
CreateModelMixin,RetrieveModelMixin,ListModelMixin,GenericViewSetManage Import jobs.
Only GET and POST are allowed.
In a POST request source_uid, dryrun, input_file and school are mandatory.
source_uid is of type string
dryrun is of type boolean
input_file has to be the key for a multipart-encoded file upload
school must be an absolute URI from /{version}/schools/
user_role must be one of staff, student, teacher, teacher_and_staff
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- queryset#
- serializer_class#
alias of
UserImportJobSerializer
- filter_backends = (<class 'ucsschool.http_api.import_api.views.UserImportJobFilterBackend'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'rest_framework.filters.OrderingFilter'>)#
- filterset_class#
alias of
UserImportJobFilter
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'ucsschool.http_api.import_api.views.UserImportJobViewPermission'>)#
- ordering_fields = ('id', 'school', 'source_uid', 'status', 'principal', 'dryrun', 'date_created')#
- basename = None#
- description = None#
- detail = None#
- name = None#
- suffix = None#
- class ucsschool.http_api.import_api.views.SubResourceMixin[source]#
Bases:
object- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'ucsschool.http_api.import_api.views.TextArtifactViewPermission'>)#
- serializer_class#
alias of
TextArtifact
- class ucsschool.http_api.import_api.views.LogFileViewSet(**kwargs)[source]#
Bases:
SubResourceMixin,ReadOnlyModelViewSetLog file of import job.
Only GET is allowed.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- serializer_class#
alias of
LogFileSerializer
- basename = None#
- description = None#
- detail = None#
- name = None#
- suffix = None#
- class ucsschool.http_api.import_api.views.PasswordsViewSet(**kwargs)[source]#
Bases:
SubResourceMixin,ReadOnlyModelViewSetNew users password file of import job.
Only GET is allowed.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- serializer_class#
alias of
PasswordFileSerializer
- basename = None#
- description = None#
- detail = None#
- name = None#
- suffix = None#
- class ucsschool.http_api.import_api.views.SummaryViewSet(**kwargs)[source]#
Bases:
SubResourceMixin,ReadOnlyModelViewSetSummary file of import job.
Only GET is allowed.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- serializer_class#
alias of
SummarySerializer
- basename = None#
- description = None#
- detail = None#
- name = None#
- suffix = None#
- class ucsschool.http_api.import_api.views.RoleViewSet(**kwargs)[source]#
Bases:
ReadOnlyModelViewSetRead-only list of Roles.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- queryset#
- serializer_class#
alias of
RoleSerializer
- filter_backends = (<class 'ucsschool.http_api.import_api.views.RoleFilterBackend'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'rest_framework.filters.OrderingFilter'>)#
- filterset_fields = ('name', 'displayName')#
- ordering_fields = ('name', 'displayName')#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'ucsschool.http_api.import_api.views.RoleViewPermission'>)#
- basename = None#
- description = None#
- detail = None#
- name = None#
- suffix = None#
- class ucsschool.http_api.import_api.views.SchoolViewSet(**kwargs)[source]#
Bases:
ReadOnlyModelViewSetRead-only list of Schools (OUs).
roles provides navigation to a list of roles the connected user has permissions on the respective
school. * user_imports provides navigation to start an import for the respective school.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- queryset#
- serializer_class#
alias of
SchoolSerializer
- filter_backends = (<class 'ucsschool.http_api.import_api.views.SchoolFilterBackend'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'rest_framework.filters.OrderingFilter'>)#
- filterset_fields = ('name', 'displayName')#
- ordering_fields = ('name', 'displayName')#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'ucsschool.http_api.import_api.views.SchoolViewPermission'>)#
- roles(request, *args, **kwargs)[source]#
schools/{ou}/roles/
Roles the connecting user has at this school.
- basename = None#
- description = None#
- detail = None#
- name = None#
- suffix = None#