コード例 #1
0
    def authenticate_credentials(self, payload):
        """
        Returns an active user that matches the payload's user id and email.
        """
        User = utils.get_user_model()

        user_id = jwt_get_user_id_from_payload(payload)

        if user_id is not None:
            try:
                user = User.objects.get(pk=user_id, is_active=True)
            except User.DoesNotExist:
                msg = _('Invalid signature.')
                raise exceptions.AuthenticationFailed(msg)
        else:
            msg = _('Invalid payload.')
            raise exceptions.AuthenticationFailed(msg)

        return user
コード例 #2
0
    def authenticate_credentials(self, payload):
        """
        Returns an active user that matches the payload's user id and email.
        """
        User = utils.get_user_model()

        user_id = jwt_get_user_id_from_payload(payload)

        if user_id is not None:
            try:
                user = User.objects.get(pk=user_id, is_active=True)
            except User.DoesNotExist:
                msg = _('Invalid signature.')
                raise exceptions.AuthenticationFailed(msg)
        else:
            msg = _('Invalid payload.')
            raise exceptions.AuthenticationFailed(msg)

        return user
コード例 #3
0
ファイル: models.py プロジェクト: StuartMacKay/checklists
from django.core.validators import MinValueValidator
from django.db.models import Model, BooleanField, IntegerField, \
    CharField, TextField, DateField, TimeField, DateTimeField, \
    ForeignKey, OneToOneField, ManyToManyField, PROTECT, SET_NULL, \
    PositiveIntegerField
from django.template.defaultfilters import slugify
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.contrib.contenttypes.models import ContentType

from transmeta import TransMeta

from utils import get_user_model


User = get_user_model()


class ChecklistsModel(Model):
    """Base class for the Checklists model."""

    class Meta:
        abstract = True

    def save(self, force_insert=False, force_update=False, **kwargs):
        """Validate a model object on save."""
        if not (force_insert or force_update):
            self.full_clean()

        super(ChecklistsModel, self)\
            .save(force_insert, force_update, **kwargs)
コード例 #4
0
ファイル: talent.py プロジェクト: youngnac/gori
from .curriculum import CurriculumSerializer
from .location import LocationSerializer
from .qna import QuestionSerializer
from .review import ReviewSerializer, AverageRatesSerializer

__all__ = (
    'TalentListSerializer',
    'TalentShortInfoSerializer',
    'TalentCreateSerializer',
    'TalentDetailSerializer',
    'TalentShortDetailSerializer',
    'MyTalentsWrapperSerializer',
    'TalentUpdateSerializer',
)

User = get_user_model()


class TalentShortInfoSerializer(serializers.ModelSerializer):
    category = serializers.SerializerMethodField(read_only=True)
    type = serializers.SerializerMethodField(read_only=True)
    review_count = serializers.SerializerMethodField(read_only=True)
    regions = serializers.SerializerMethodField(read_only=True)
    average_rate = serializers.SerializerMethodField(read_only=True)
    wishlist_count = serializers.SerializerMethodField(read_only=True)

    class Meta:
        model = Talent
        fields = (
            'pk',
            'title',
コード例 #5
0
	def __unicode__(self):
		return self.email

class Profile(ModelWithHexkey):
	"""Object for user-editable information about People"""
	user = models.ForeignKey(Person, editable=False, unique=True)  # To follow this the other way, use '<person>.get_profile()'
	phone = models.CharField(max_length=50, null=True, blank=True)
	fax = models.CharField(max_length=50, null=True, blank=True)
	additional_email_addresses = models.ManyToManyField(EmailAddress, blank=True)
	address1 = models.CharField(max_length=200, null=True, blank=True)
	address2 = models.CharField(max_length=200, null=True, blank=True)
	post_code = models.CharField(max_length=10, null=True, blank=True)
	personal_info = models.TextField(null=True, blank=True)
	research_info = models.TextField(null=True, blank=True)
	gender = models.CharField(max_length=1, choices=GENDER_CHOICES, null=True, blank=True)
	
	def get_absolute_url(self):
		return self.user.get_absolute_url()
	
	def __unicode__(self):
		return '[Profile] %s' % self.user.get_full_name()
	



post_save.connect(create_profile_for_user, sender=get_user_model())
pre_delete.connect(delete_profile_for_user, sender=get_user_model())