kudos.models

Define 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/.

TokenQuerySet

TokenQuerySet(self, model=None, query=None, using=None, hints=None)

Handle the manager queryset for Tokens.

visible

TokenQuerySet.visible(self)

Filter results down to visible tokens only.

keyword

TokenQuerySet.keyword(self, keyword)

Filter results to all Token objects containing the keywords.

Args: keyword (str): The keyword to search title, issue description, and issue keywords by.

Returns: kudos.models.TokenQuerySet: The QuerySet of tokens filtered by keyword.

Token

Token(self, *args, **kwargs)

Model representing a Kudos ERC721 token on the blockchain.

The model attempts to match the actual blockchain data as much as possible, without being duplicative.

Attributes: artist (str): The artist that created the kudos image. background_color (str): 6 digit hex code background color. See Open Sea docs for details. cloned_from_id (int): Orignal Kudos that this one was cloned from. contract (FK): Foreing key to the Contract model. description (str): Description of the kudos. external_url (str): External URL pointer to image asset. See Open Sea docs for details. image (str): Image file name. name (str): Kudos name. num_clones_allowed (int): How many clones are allowed to be made. num_clones_available (int): How many clones the Kudos has left. num_clones_in_wild (int): How many clones there are in the wild. owner_address (str): ETH address of the owner. Pulled from the ownerOf contract function. platform (str): Where the Kudos originated from. price_finney (int): Price to clone the Kudos in finney. rarity (str): Rarity metric, defined in kudos.utils.py tags (str): Comma delimited tags. TODO: change to array token_id (int): the token_id on the blockchain. txid (str): The ethereum transaction id that generated this kudos.

artist

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

as_img

Convert the provided buffer to another format.

Args: obj (File): The File/ContentFile object.

Exceptions: Exception: Cowardly catch blanket exceptions here, log it, and return None.

Returns: BytesIO: The BytesIO stream containing the converted File data. None: If there is an exception, the method returns None.

background_color

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

bulk_transfers

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

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

capitalized_name

Capitalize name

Returns: str: Capitalized name.

cloned_from_id

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

contract

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.

contract_id

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

description

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

event_ethdenver2019_customizing_kudos

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.

external_url

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

_method

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

_method

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

_method

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

_method

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

hidden

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

humanized_name

Turn snake_case into Snake Case.

Returns: str: The humanized name.

id

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

image

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

kudos_token_cloned_from

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

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

kudos_transfer

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.

name

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

num_clones_allowed

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

num_clones_available

Calculate the number of clones available for a kudos.

Returns: int: Number of clones available.

num_clones_in_wild

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

owner_address

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

owners_handles

. differs from owners_profiles in that not everyone who has received a kudos has a profile Returns: array: array of handles

owners_profiles

.

Returns: array: QuerySet of Profiles

platform

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

popularity

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

popularity_month

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

popularity_quarter

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

popularity_week

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

price_finney

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

price_in_eth

Convert price from finney to eth.

Returns: float or int: price in eth.

rarity

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

send_enabled_for_non_gitcoin_admins

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

shortened_address

Shorten ethereum address to only the first and last 4 digits.

Returns: str: shortened address.

tags

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

token_id

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

transfers_enabled

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

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

txid

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

send_enabled_for

Token.send_enabled_for(self, user)

Arguments: - user: a django user object

Returns: bool: Wehther a send should be enabled for this user

KudosTransfer

KudosTransfer(self, *args, **kwargs)

Model that represents a request to clone a Kudos.

Typically this gets created when using the "kudos send" functionality. The model is inherited from the SendCryptoAsset model, which is also used by Tips.

Attributes: from_address (str): Eth address of the person that is sending the kudos. kudos_token (kudos.Token): Foreign key to the kudos_token that was cloned. This is filled in after the kudos has been cloned. kudos_token_cloned_from (kudos.Token): Foreign key to the kudos_token that will be cloned and sent. recipient_profile (dashboard.Profile): Foreign key to the profile of the person that is being sent the kudos. sender_profile (dashboard.Profile): Foreign key to the profile of the person that is sending the kudos.

activities

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

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

bulk_transfer_redemptions

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

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

_method

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

_method

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

_method

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

_method

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

_method

KudosTransfer._method(self, *, field=<django.db.models.fields.CharField: receive_tx_status>)

_method

KudosTransfer._method(self, *, field=<django.db.models.fields.CharField: tx_status>)

id

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

kudos_token

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.

kudos_token_cloned_from

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.

kudos_token_cloned_from_id

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

kudos_token_id

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

receive_url

URL used for indirect send. Deprecated in favor of receive_url_for_recipient

Returns: str: URL for recipient.

receive_url_for_recipient

URL used for indirect send. Deprecated in favor of receive_url_for_recipient

Returns: str: URL for recipient.

recipient_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.

recipient_profile_id

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

sender_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.

sender_profile_id

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

trust_url

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

Contract

Contract(self, *args, **kwargs)

Contract(id, created_on, modified_on, address, is_latest, network)

address

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

_method

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

_method

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

_method

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

_method

Contract._method(self, *, field=<django.db.models.fields.DateTimeField: modified_on>, 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.

is_latest

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

kudos_contract

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

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

network

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

Wallet

Wallet(self, *args, **kwargs)

DEPRECATED. Kudos Address where the tokens are stored.

Currently not used. Instead we are using preferred_payout_address for now.

Attributes: address (TYPE): Description profile (TYPE): Description

address

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

_method

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

_method

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

_method

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

_method

Wallet._method(self, *, field=<django.db.models.fields.DateTimeField: modified_on>, 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.

preferred_kudos_wallet

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.

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.

BulkTransferCoupon

BulkTransferCoupon(self, *args, **kwargs)

Model representing a bulk send of Kudos

bulk_transfer_redemptions

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

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

comments_to_put_in_kudos_transfer

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

current_uses

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

_method

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

_method

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

_method

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

_method

BulkTransferCoupon._method(self, *, field=<django.db.models.fields.DateTimeField: modified_on>, 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.

num_uses_remaining

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

num_uses_total

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

secret

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

sender_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.

sender_profile_id

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

token

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.

token_id

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

BulkTransferRedemption

BulkTransferRedemption(self, *args, **kwargs)

Model representing a bulk send of Kudos

coupon

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.

coupon_id

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

_method

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

_method

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

_method

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

_method

BulkTransferRedemption._method(self, *, field=<django.db.models.fields.DateTimeField: modified_on>, 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.

ip_address

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

kudostransfer

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.

kudostransfer_id

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

redeemed_by

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.

redeemed_by_id

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

TransferEnabledFor

TransferEnabledFor(self, *args, **kwargs)

Model that represents the ability to send a Kudos, i f token.send_enabled_for_non_gitcoin_admins is true.

_method

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

_method

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

_method

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

_method

TransferEnabledFor._method(self, *, field=<django.db.models.fields.DateTimeField: modified_on>, 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.

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.

token

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.

token_id

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