avatar.models

Define the Avatar models.

Copyright (C) 2018 Gitcoin Core

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.

BaseAvatar

BaseAvatar(self, *args, **kwargs)

Store the options necessary to render a Gitcoin avatar.

active

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

autogenerated

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

avatar_url

Return the appropriate avatar URL.

customavatar

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 a ReverseOneToOneDescriptor instance.

_method

BaseAvatar._method(self, *, field=<django.db.models.fields.DateTimeField: created_on>, is_next=True, **kwargs)

_method

BaseAvatar._method(self, *, field=<django.db.models.fields.DateTimeField: modified_on>, is_next=True, **kwargs)

_method

BaseAvatar._method(self, *, field=<django.db.models.fields.DateTimeField: created_on>, is_next=False, **kwargs)

_method

BaseAvatar._method(self, *, field=<django.db.models.fields.DateTimeField: modified_on>, is_next=False, **kwargs)

hash

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

ICON_SIZE

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.

If the argument is a tuple, the return value is the same object.

id

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

png

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

profile

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.

profile_id

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

socialavatar

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 a ReverseOneToOneDescriptor instance.

svg

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', 'r') as f:
...     instance.file = File(f)

get_avatar_url

BaseAvatar.get_avatar_url(self)

Get the Avatar URL.

convert_field

BaseAvatar.convert_field(self, source, input_fmt, output_fmt)

Handle converting from the source field to the target based on format.

determine_response

BaseAvatar.determine_response(self, use_svg=True)

Determine the content type and file to serve.

Args: use_svg (bool): Whether or not to use SVG format.

CustomAvatar

CustomAvatar(self, *args, **kwargs)

CustomAvatar(id, created_on, modified_on, active, profile, svg, png, hash, autogenerated, baseavatar_ptr, recommended_by_staff, config)

baseavatar_ptr

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.place is a ForwardOneToOneDescriptor instance.

baseavatar_ptr_id

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

config

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

recommended_by_staff

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

create_from_config

CustomAvatar.create_from_config(self)

Create an avatar SVG from the configuration.

TODO: * Deprecate in favor of request param based view using templates.

SocialAvatar

SocialAvatar(self, *args, **kwargs)

SocialAvatar(id, created_on, modified_on, active, profile, svg, png, hash, autogenerated, baseavatar_ptr)

baseavatar_ptr

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.place is a ForwardOneToOneDescriptor instance.

baseavatar_ptr_id

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