pomodorr.users package¶
Subpackages¶
Submodules¶
pomodorr.users.admin module¶
-
class
pomodorr.users.admin.
IsBlockedFilter
(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_blocked'¶
-
queryset
(request, queryset)¶ Return the filtered queryset.
-
title
= 'is_blocked status'¶
-
-
class
pomodorr.users.admin.
UserAdmin
(model, admin_site)¶ Bases:
django.contrib.auth.admin.UserAdmin
-
actions
= ['unblock_selected']¶
-
add_fieldsets
= ((None, {'classes': ('wide',), 'fields': ('email', 'username', 'password1', 'password2', 'is_staff', 'is_superuser', 'is_active')}), ('Important dates', {'fields': ('blocked_until',)}))¶
-
add_form
¶
-
fieldsets
= ((None, {'fields': ('username', 'password')}), ('Personal info', {'fields': ('first_name', 'last_name', 'email')}), ('Permissions', {'fields': ('is_active', 'is_staff', 'is_superuser', 'groups', 'user_permissions')}), ('Important dates', {'fields': ('last_login', 'date_joined', 'blocked_until')}))¶
-
form
¶
-
is_blocked
(instance)¶
-
list_display
= ('email', 'username', 'is_staff', 'is_superuser', 'is_active', 'is_blocked')¶
-
list_filter
= ('is_staff', 'is_superuser', 'is_active', <class 'pomodorr.users.admin.IsBlockedFilter'>)¶
-
property
media
¶
-
ordering
= ('email',)¶
-
search_fields
= ('email', 'username')¶
-
unblock_selected
(request, queryset)¶
-
pomodorr.users.apps module¶
pomodorr.users.forms module¶
-
class
pomodorr.users.forms.
AdminSiteUserCreationForm
(*args, **kwargs)¶ Bases:
django.contrib.auth.forms.UserCreationForm
-
class
Meta
¶ Bases:
object
-
field_classes
= {'username': <class 'django.contrib.auth.forms.UsernameField'>}¶
-
fields
= ('username', 'email', 'blocked_until')¶
-
model
¶ alias of
pomodorr.users.models.User
-
-
base_fields
= {'blocked_until': <django.forms.fields.DateTimeField object>, 'email': <django.forms.fields.EmailField object>, 'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>, 'username': <django.contrib.auth.forms.UsernameField object>}¶
-
clean_blocked_until
()¶
-
clean_email
()¶
-
clean_username
()¶
-
declared_fields
= {'email': <django.forms.fields.EmailField object>, 'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>}¶
-
property
media
¶
-
class
-
class
pomodorr.users.forms.
AdminSiteUserUpdateForm
(*args, **kwargs)¶ Bases:
django.contrib.auth.forms.UserChangeForm
-
class
Meta
¶ Bases:
object
-
field_classes
= {'username': <class 'django.contrib.auth.forms.UsernameField'>}¶
-
fields
= ('username', 'email', 'blocked_until')¶
-
model
¶ alias of
pomodorr.users.models.User
-
-
base_fields
= {'blocked_until': <django.forms.fields.DateTimeField object>, 'email': <django.forms.fields.EmailField object>, 'password': <django.contrib.auth.forms.ReadOnlyPasswordHashField object>, 'username': <django.contrib.auth.forms.UsernameField object>}¶
-
clean_blocked_until
()¶
-
declared_fields
= {'password': <django.contrib.auth.forms.ReadOnlyPasswordHashField object>}¶
-
property
media
¶
-
save
(commit=True)¶ Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.
-
class
pomodorr.users.models module¶
-
class
pomodorr.users.models.
User
(password, last_login, is_superuser, username, first_name, last_name, is_staff, is_active, date_joined, id, email, blocked_until, avatar)¶ Bases:
django.contrib.auth.models.AbstractUser
-
ALLOWED_AVATAR_EXTENSIONS
= ['jpg', 'jpeg', 'png']¶
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
REQUIRED_FIELDS
= ['username']¶
-
USERNAME_FIELD
= 'email'¶
-
auth_token
¶ 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.restaurant
is aReverseOneToOneDescriptor
instance.
-
avatar
¶ 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)
-
blocked_until
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
get_avatar_url
()¶
-
get_next_by_date_joined
(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)¶
-
get_previous_by_date_joined
(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)¶
-
groups
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
logentry_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.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
objects
= <pomodorr.users.models.UserManager object>¶
-
priorities
¶ 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.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
projects
¶ 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.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
settings
¶ 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.restaurant
is aReverseOneToOneDescriptor
instance.
-
user_permissions
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
-
class
pomodorr.users.models.
UserManager
¶ Bases:
django.contrib.auth.base_user.BaseUserManager
-
active_standard_users
()¶
-
blocked_standard_users
()¶
-
create_superuser
(email, username=None, password=None, **extra_fields)¶
-
create_user
(email, username=None, password=None, is_active=False, **extra_fields)¶
-
get_queryset
()¶ Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
-
non_active_standard_users
()¶
-
ready_to_unblock_users
()¶
-
-
pomodorr.users.models.
user_upload_path
(instance, filename)¶
pomodorr.users.selectors module¶
-
pomodorr.users.selectors.
get_active_standard_users
()¶
-
pomodorr.users.selectors.
get_all_users
()¶
-
pomodorr.users.selectors.
get_blocked_standard_users
()¶
-
pomodorr.users.selectors.
get_non_active_standard_users
()¶
-
pomodorr.users.selectors.
get_ready_to_unblock_users
()¶
pomodorr.users.serializers module¶
-
class
pomodorr.users.serializers.
UserDetailSerializer
(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)¶ Bases:
rest_framework.serializers.ModelSerializer
-
class
Meta
¶ Bases:
object
-
extra_kwargs
= {'avatar': {'source': 'get_avatar_url'}}¶
-
fields
= ('id', 'email', 'username', 'avatar', 'settings')¶
-
model
¶ alias of
pomodorr.users.models.User
-
-
create
(validated_data)¶ We have a bit of extra checking around this in order to provide descriptive messages when something goes wrong, but this method is essentially just:
return ExampleModel.objects.create(**validated_data)
If there are many to many fields present on the instance then they cannot be set until the model is instantiated, in which case the implementation is like so:
example_relationship = validated_data.pop(‘example_relationship’) instance = ExampleModel.objects.create(**validated_data) instance.example_relationship = example_relationship return instance
The default implementation also does not handle nested relationships. If you want to support writable nested relationships you’ll need to write an explicit .create() method.
-
update
(instance, validated_data)¶
-
class