pomodorr.frames package

Submodules

pomodorr.frames.admin module

class pomodorr.frames.admin.DateFrameAdmin(model, admin_site)

Bases: django.contrib.admin.options.ModelAdmin

fieldsets = [(None, {'fields': ['start', 'end', 'frame_type', 'task']})]
get_queryset(request)

Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.

is_finished(instance)
list_display = ('__str__', 'frame_type', 'start', 'end', 'duration', 'task', 'is_finished')
list_filter = ('frame_type', <class 'pomodorr.frames.admin.IsFinishedFilter'>)
property media
search_fields = ('frame_type', 'task__name', 'start', 'end')
class pomodorr.frames.admin.IsFinishedFilter(request, params, model, model_admin)

Bases: django.contrib.admin.filters.SimpleListFilter

lookup_choices = (('1', 'Yes'), ('0', 'No'))
lookups(request, model_admin)

Must be overridden to return a list of tuples (value, verbose value)

parameter_name = 'is_finished'
queryset(request, queryset)

Return the filtered queryset.

title = 'is_finished status'

pomodorr.frames.api module

class pomodorr.frames.api.DateFrameListView(**kwargs)

Bases: rest_framework.viewsets.GenericViewSet, rest_framework.mixins.ListModelMixin

filter_backends = [<class 'rest_framework.filters.OrderingFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>]
filterset_class

alias of pomodorr.frames.filtersets.DataFrameIsFinishedFilter

get_queryset()

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

get_serializer_context()

Extra context provided to the serializer class.

ordering_fields = ['created', 'duration', 'is_finished']
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'pomodorr.tools.permissions.IsDateFrameOwner'>)
serializer_class

alias of pomodorr.frames.serializers.DateFrameSerializer

pomodorr.frames.apps module

class pomodorr.frames.apps.FramesConfig(app_name, app_module)

Bases: django.apps.config.AppConfig

name = 'pomodorr.frames'
verbose = 'Frames'

pomodorr.frames.consumers module

class pomodorr.frames.consumers.DateFrameConsumer(*args, **kwargs)

Bases: channels.generic.websocket.WebsocketConsumer

connect()

In the first step this method authorizes the user trying to connect to the socket. Then if there is any ongoing date frame for the task which the connection points to, it will be terminated and the connection that corresponds to the ongoing date frame is about to be discarded. This means that there can be only one connection responsible for calculating the date frames per the task. Then the connection is being accepted.

disconnect(code)

Called when a WebSocket connection is closed.

frame_discard_other_connections(event)

Called in order to discard the connection and remove it from the channel group.

frame_finish(event)

Called in order to finish a date frame. If there are any colliding date frames, they will be finished immediately. In order to call the handler, the following data is expected by the main receive handler:

  • type: str pointing to frame_start handler,

  • date_frame_id: int corresponding to the date frame that was currently being processed

Valid frame_type values:

  • 0 corresponds to pomodoro

  • 1 corresponds to break

  • 2 corresponds to pause

frame_notify_frame_terminated(event)

Called in order to notify the connected user that the currently processed date frame has been terminated. This happens if someone had started another date frame for the related task from another device or browser and in case when there is a date frame being processed and in the meantime the related task has been marked as completed, which will trigger the signal handler.

frame_start(event)

Called in order to start a date frame. If there are any colliding date frames, they will be finished immediately. In order to call the handler, the following data is expected by the main receive handler:

  • type: str pointing to frame_start handler,

  • frame_type: int corresponding to the date frame types:

Valid frame_type values:

  • 0 corresponds to pomodoro

  • 1 corresponds to break

  • 2 corresponds to pause

frame_terminate(event)

Called in order to fetch the ongoing date frame for the task that the connection corresponds to and if there is one, it will be terminated. This handler is called before establishing each connection.

has_object_permission() → bool
Checks if the task that the connection corresponds to belongs to the socket user.
Returns

bool

notify_frame_terminated()

Called in order to send the info about the event of terminating the date frame.

receive(text_data=None, bytes_data=None)

Receives the text_data, parses it and delegates the further flow to the relevant handler. Possible handlers:

  • frame_start

  • frame_finish

  • frame_terminate

Example json parameters:

  • ‘type’: ‘frame_start’,

  • ‘frame_type’: 0

pomodorr.frames.exceptions module

exception pomodorr.frames.exceptions.DateFrameException(message, code=None, params=None)

Bases: django.core.exceptions.ValidationError

already_completed = 'already_completed'
current_pomodoro_exists = 'current_pomodoro_exists'
does_not_exist = 'does_not_exist'
invalid_break_length = 'invalid_break_length'
invalid_date_frame_type = 'invalid_date_frame_type'
invalid_pomodoro_length = 'invalid_pomodoro_length'
messages = {'already_completed': 'The date frame is already completed.', 'current_pomodoro_exists': 'You cannot start pomodoro for this task because there is a pomodoro in progress.', 'does_not_exist': 'Date Frame with given id does not exist.', 'invalid_break_length': 'The submitted break length is longer than the length specified in settings.', 'invalid_date_frame_type': 'The submitted date type frame is invalid.', 'invalid_pomodoro_length': 'The submitted pomodoro length is longer than the length specified in settings.', 'overlapping_date_frame': 'There is already an overlapping date frame.', 'start_greater_than_end': 'Start date cannot be greater than end date.', 'task_already_completed': 'You cannot submit date frame for a completed task.'}
overlapping_date_frame = 'overlapping_date_frame'
start_greater_than_end = 'start_greater_than_end'
task_already_completed = 'task_already_completed'

pomodorr.frames.filtersets module

class pomodorr.frames.filtersets.DataFrameIsFinishedFilter(data=None, queryset=None, *, request=None, prefix=None)

Bases: django_filters.rest_framework.filterset.FilterSet

class Meta

Bases: object

fields = {'created': ['exact', 'gt', 'gte', 'lt', 'lte'], 'frame_type': ['exact'], 'is_finished': ['exact'], 'task__id': ['exact']}
model

alias of pomodorr.frames.models.DateFrame

base_filters = {'created': <django_filters.filters.IsoDateTimeFilter object>, 'created__gt': <django_filters.filters.IsoDateTimeFilter object>, 'created__gte': <django_filters.filters.IsoDateTimeFilter object>, 'created__lt': <django_filters.filters.IsoDateTimeFilter object>, 'created__lte': <django_filters.filters.IsoDateTimeFilter object>, 'frame_type': <django_filters.filters.ChoiceFilter object>, 'is_finished': <django_filters.rest_framework.filters.BooleanFilter object>, 'task__id': <django_filters.filters.UUIDFilter object>}
declared_filters = {'is_finished': <django_filters.rest_framework.filters.BooleanFilter object>}

pomodorr.frames.managers module

class pomodorr.frames.managers.BreakManager

Bases: pomodorr.frames.managers.DateFrameManager

get_queryset()

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.

class pomodorr.frames.managers.DateFrameManager

Bases: django.db.models.manager.Manager

get_queryset()

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.

class pomodorr.frames.managers.PauseManager

Bases: pomodorr.frames.managers.DateFrameManager

get_queryset()

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.

class pomodorr.frames.managers.PomodoroManager

Bases: pomodorr.frames.managers.DateFrameManager

get_queryset()

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.

pomodorr.frames.models module

class pomodorr.frames.models.Break(created, modified, id, start, end, duration, frame_type, task)

Bases: pomodorr.frames.models.DateFrame

exception DoesNotExist

Bases: pomodorr.frames.models.DateFrame.DoesNotExist

exception MultipleObjectsReturned

Bases: pomodorr.frames.models.DateFrame.MultipleObjectsReturned

objects = <pomodorr.frames.managers.BreakManager object>
class pomodorr.frames.models.DateFrame(created, modified, id, start, end, duration, frame_type, task)

Bases: model_utils.models.TimeStampedModel

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

TYPE_CHOICES = [(0, 'pomodoro'), (1, 'break'), (2, 'pause')]
break_type = 1
check_date_frame_duration_fits_error_margin()
check_start_greater_than_end()
check_task_is_already_completed()
clean()

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

duration

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

end

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property estimated_date_frame_end
frame_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_frame_type_display(*, field=<django.db.models.fields.SmallIntegerField: frame_type>)
get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)
get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)
get_next_by_start(*, field=<django.db.models.fields.DateTimeField: start>, is_next=True, **kwargs)
get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)
get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)
get_previous_by_start(*, field=<django.db.models.fields.DateTimeField: start>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property normalized_date_frame_length
property normalized_duration
objects = <pomodorr.frames.managers.DateFrameManager object>
pause_type = 2
pomodoro_type = 0
save(force_insert=False, force_update=False, using=None, update_fields=None)

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

start

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

task

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.parent is a ForwardManyToOneDescriptor instance.

task_id
class pomodorr.frames.models.Pause(created, modified, id, start, end, duration, frame_type, task)

Bases: pomodorr.frames.models.DateFrame

exception DoesNotExist

Bases: pomodorr.frames.models.DateFrame.DoesNotExist

exception MultipleObjectsReturned

Bases: pomodorr.frames.models.DateFrame.MultipleObjectsReturned

objects = <pomodorr.frames.managers.PauseManager object>
class pomodorr.frames.models.Pomodoro(created, modified, id, start, end, duration, frame_type, task)

Bases: pomodorr.frames.models.DateFrame

exception DoesNotExist

Bases: pomodorr.frames.models.DateFrame.DoesNotExist

exception MultipleObjectsReturned

Bases: pomodorr.frames.models.DateFrame.MultipleObjectsReturned

objects = <pomodorr.frames.managers.PomodoroManager object>

pomodorr.frames.routing module

pomodorr.frames.serializers module

class pomodorr.frames.serializers.DateFrameSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)

Bases: rest_framework.serializers.ModelSerializer

class Meta

Bases: object

fields = ('id', 'created', 'modified', 'start', 'end', 'duration', 'frame_type')
model

alias of pomodorr.frames.models.DateFrame

to_representation(instance)

Object instance -> Dict of primitive datatypes.

pomodorr.frames.statuses module

pomodorr.frames.tasks module

pomodorr.frames.utils module

class pomodorr.frames.utils.BreakDurationCalculator(date_frame_object, end: datetime.datetime)

Bases: pomodorr.frames.utils.DurationCalculator

class pomodorr.frames.utils.DurationCalculator(date_frame_object, end: datetime.datetime)

Bases: object

get_duration() → datetime.timedelta
class pomodorr.frames.utils.DurationCalculatorLoader(date_frame_object, end: datetime.datetime)

Bases: object

calculate() → datetime.timedelta
class pomodorr.frames.utils.PauseDurationCalculator(date_frame_object, end: datetime.datetime)

Bases: pomodorr.frames.utils.DurationCalculator

class pomodorr.frames.utils.PomodoroDurationCalculator(date_frame_object, end: datetime.datetime)

Bases: pomodorr.frames.utils.DurationCalculator

get_breaks_duration() → datetime.timedelta
get_duration() → datetime.timedelta
get_pauses_duration() → datetime.timedelta

Module contents