Exemplo n.º 1
0
class DeveloperInvitation(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    email = models.EmailField(unique=True, validators=[validate_email])
    type = models.IntegerField(choices=USER_TYPE_CHOICES,
                               default=USER_TYPE_DEVELOPER)
    invitation_key = models.UUIDField(default=uuid.uuid4,
                                      editable=False,
                                      unique=True)
    invitation_sent_at = models.DateTimeField(blank=True,
                                              null=True,
                                              editable=False)
    used = models.BooleanField(default=False)
    used_at = models.DateTimeField(blank=True, null=True, editable=False)
    resent = models.BooleanField(default=False)
    resent_at = models.DateTimeField(blank=True, null=True, editable=False)
    created_by = models.ForeignKey(settings.AUTH_USER_MODEL,
                                   on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        verbose_name = 'user invitation'

    def __unicode__(self):
        return self.display_name

    @property
    def display_name(self):
        return '%s %s' % (self.first_name, self.last_name)
class PublicationScore(models.Model):
    publication = models.ForeignKey(Publication,
                                    related_name="scores",
                                    on_delete=models.CASCADE)
    types = [
        ('adiccion', 'ADICCIÓN'),
        ('ambientacion', 'AMBIENTACIÓN'),
        ('combate', 'COMBATE'),
        ('dificultad', 'DIFICULTAD'),
        ('equipo', 'EQUIPO'),
        ('estrategia', 'ESTRATEGIA'),
        ('terror', 'TERROR'),
        ('puzzles', 'PUZZLES'),
        ('monstruos', 'MONSTRUOS'),
        ('narrativa', 'NARRATIVA'),
    ]

    name = models.CharField(max_length=100, choices=types)
    types = [(1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5')]

    value = models.IntegerField(choices=types)
    description = models.CharField(max_length=999, default=None, null=True)

    def __str__(self):
        return self.publication.slug + " - " + self.name
Exemplo n.º 3
0
class UserProfile(models.Model):
    user = models.OneToOneField(settings.AUTH_USER_MODEL,
                                on_delete=models.CASCADE)
    bio = models.TextField(max_length=500, blank=True, null=True)
    country = CountryField(blank=True, null=True)
    city = tagulous.models.SingleTagField(to=City, blank=True, null=True)
    street = models.CharField(max_length=100, blank=True, null=True)
    plot_number = models.CharField(max_length=100, blank=True, null=True)
    postal_code = models.IntegerField(blank=True, null=True)
    postal_address = models.CharField(max_length=100, blank=True, null=True)
    phone_number = models.CharField(max_length=15, blank=True, null=True)
    company = models.CharField(max_length=200, blank=True, null=True)
    skills = tagulous.models.TagField(to=Skill, blank=True)
    website = models.URLField(blank=True, null=True)

    def __unicode__(self):
        return self.user.get_short_name()

    @property
    def city_name(self):
        return str(self.city)

    @property
    def country_name(self):
        return self.country.name

    @allow_staff_or_superuser
    def has_object_read_permission(self, request):
        return True

    @allow_staff_or_superuser
    def has_object_write_permission(self, request):
        return request.user == self.user
Exemplo n.º 4
0
class Participation(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             on_delete=models.DO_NOTHING)
    task = models.ForeignKey(Task, on_delete=models.CASCADE)
    accepted = models.BooleanField(default=False)
    responded = models.BooleanField(default=False)
    assignee = models.BooleanField(default=False)
    role = models.CharField(max_length=100, default='Developer')
    share = models.IntegerField(blank=True, null=True)
    satisfaction = models.SmallIntegerField(blank=True, null=True)
    created_by = models.ForeignKey(settings.AUTH_USER_MODEL,
                                   related_name='participants_added')
    created_at = models.DateTimeField(auto_now_add=True)
    activated_at = models.DateTimeField(blank=True, null=True)
    ratings = GenericRelation(Rating, related_query_name='participants')

    def __unicode__(self):
        return '%s - %s' % (self.user.get_short_name()
                            or self.user.username, self.task.title)

    class Meta:
        unique_together = ('user', 'task')
        verbose_name_plural = 'participation'

    @allow_staff_or_superuser
    def has_object_read_permission(self, request):
        return self.task.has_object_read_permission(request)

    @allow_staff_or_superuser
    def has_object_write_permission(self, request):
        return request.user == self.user or request.user == self.task.user
Exemplo n.º 5
0
class Profile(AbstractUser):

    address = models.CharField(max_length=255, blank=True, null=True)
    address2 = models.CharField(max_length=255, blank=True, null=True)
    city = models.CharField(max_length=255, blank=True, null=True)
    state = models.CharField(max_length=255, blank=True, null=True)
    country = models.CharField(max_length=100, blank=True, null=True)
    country_code = models.CharField(max_length=100, blank=True, null=True)
    zipcode = models.IntegerField(blank=True, null=True)
    location = models.CharField(max_length=100, blank=True, null=True)
    capacity = models.IntegerField(blank=True, null=True)
    notes = models.TextField(blank=True, null=True)
    photo = models.ImageField(blank=True, null=True, upload_to=path_and_rename)
    skills = tagulous.models.TagField(to=Skills, blank=True)
    signup_code = models.CharField(max_length=25, blank=True, null=True)
    title = models.CharField(max_length=100, blank=True, null=True)
    roles = models.ManyToManyField(Role, blank=True)
    stripe = models.CharField(max_length=255, blank=True, null=True)
    stripe_connect = models.CharField(max_length=255, blank=True, null=True)
    verification = models.CharField(max_length=255, default='unverified')
    payouts_enabled = models.BooleanField(default=False)
    biography = models.TextField(blank=True, null=True)
    long_description = models.TextField(blank=True, null=True)
    objects = CustomUserManager()
    email_notifications = models.BooleanField(default=True)
    email_confirmed = models.BooleanField(default=False)
    featured = models.BooleanField(default=False)
    tos = models.BooleanField(default=False)
    work_examples = GenericRelation('generics.Attachment')
    score = models.DecimalField(blank=True,
                                null=True,
                                max_digits=5,
                                decimal_places=2)
    referral_code = models.CharField(max_length=50, blank=True, null=True)
    full_time = models.BooleanField(default=True)
    contract_to_hire = models.BooleanField(default=True)
    freelance = models.BooleanField(default=True)

    @property
    def name(self):
        return '{0} {1}'.format(self.first_name, self.last_name)

    @property
    def get_photo(self):
        if self.photo:
            return '{0}{1}'.format(settings.MEDIA_URL, self.photo)
        else:
            try:
                return self.social_auth.get(
                    provider='linkedin-oauth2'
                ).extra_data['picture_urls']['values'][0]
            except:
                return ''

    @property
    def linkedin(self):
        try:
            return self.social_auth.get(provider='linkedin-oauth2')
        except UserSocialAuth.DoesNotExist:
            return None

    @property
    def company(self):
        """
        TODO Needs to support multiple primary companies
        """
        try:
            return Employee.objects.get(profile=self, primary=True).company
        except Employee.DoesNotExist:
            return None

    @property
    def contact_details(self):
        details, created = ContactDetails.objects.get_or_create(profile=self)
        if (created):
            details.email = self.email
            details.email_confirmed = self.email_confirmed
            details.save()
        return details

    def get_skills(self):
        return self.skills.all()

    @property
    def skilltests(self):
        return SkillTest.objects.filter(profile=self)

    @property
    def taken_tests(self):
        return [t.expertratings_test for t in self.skilltests]

    def get_default_payment(self):
        if self.stripe:
            stripe.api_key = settings.STRIPE_KEY
            stripe_customer = stripe.Customer.retrieve(self.stripe)
            for card in stripe_customer['sources']['data']:
                if card['id'] == stripe_customer['default_source']:
                    # TODO Manually serialize card, circular import error if using api serializer
                    return card
        return None

    @property
    def subscribed(self):
        active_projects = Project.objects.filter(project_manager=self,
                                                 status='active')
        if len(active_projects) > 0:
            return True
        return False

    def invite(self, sender):
        invite, created = Invite.objects.get_or_create(recipient=self,
                                                       sender=sender)
        if created:
            return True
        return False
Exemplo n.º 6
0
class Role(models.Model):
    name = models.CharField(max_length=100)
    display_name = models.CharField(max_length=100)
    category = models.CharField(max_length=100, blank=True, null=True)
    years = models.IntegerField(null=True)
class Publication(models.Model):
    def get_absolute_url(self):
        return reverse('publication_detail', args=(self.slug, ))

    # TODO: change for correct article types
    types = [
        ('noticia', 'noticia'),
        ('articulo', 'artículo'),
        ('análisis', 'análisis'),
    ]

    publication_type = models.CharField(max_length=100, choices=types)
    slug = models.SlugField()
    author = models.ForeignKey('user.user',
                               related_name="author",
                               on_delete=models.CASCADE)

    title = models.CharField(max_length=100,
                             default=None,
                             null=True,
                             blank=True)
    subtitle = models.CharField(max_length=100,
                                default=None,
                                null=True,
                                blank=True)
    game_release_name = models.CharField(max_length=100,
                                         default=None,
                                         null=None,
                                         blank=True)
    game_release_date = models.DateTimeField(null=None, blank=True)
    publication_date = models.DateTimeField(null=None, blank=True)

    title_tag = tagulous.models.TagField(to="general.customtag",
                                         related_name="title_tag",
                                         default=None,
                                         blank=True)
    genre_tags = tagulous.models.TagField(to="general.customtag",
                                          related_name="genre_tags",
                                          default=None,
                                          blank=True)
    developer_tags = tagulous.models.TagField(to="general.customtag",
                                              related_name="developer_tags",
                                              default=None,
                                              blank=True)
    publisher_tags = tagulous.models.TagField(to="general.customtag",
                                              related_name="publisher_tags",
                                              default=None,
                                              blank=True)
    review_platform_tags = tagulous.models.TagField(
        to="general.customtag",
        related_name="review_platform_tags",
        default=None,
        blank=True)
    available_platform_tags = tagulous.models.TagField(
        to="general.customtag",
        related_name="available_platform_tags",
        default=None,
        blank=True)

    tags = tagulous.models.TagField(to="general.customtag",
                                    related_name="tags",
                                    default=None,
                                    blank=True)

    content = FroalaField()

    masonry_snippet = models.CharField(max_length=140, default=None, null=True)
    masonry_size = models.IntegerField(default=1)

    def __str__(self):
        return self.title
Exemplo n.º 8
0
class Project(models.Model):
    company = models.ForeignKey(Company, blank=True, null=True)
    project_manager = models.ForeignKey('accounts.Profile')
    title = models.CharField(max_length=255, unique=True)
    slug = models.SlugField(max_length=255)
    type = models.CharField(max_length=100,
                            choices=PROJECT_TYPES,
                            blank=True,
                            null=True)
    category = models.CharField(max_length=100, blank=True, null=True)
    start_date = models.DateField(blank=True, null=True)
    end_date = models.DateField(blank=True, null=True)
    expire_date = models.DateField(blank=True, null=True)
    skills = tagulous.models.TagField(to='accounts.Skills',
                                      blank=True,
                                      null=True)
    deleted = models.BooleanField(default=False)
    estimated_hours = models.IntegerField(blank=True, null=True)
    estimated_cash = models.IntegerField(blank=True, null=True)
    estimated_equity_percentage = models.DecimalField(blank=True,
                                                      null=True,
                                                      max_digits=4,
                                                      decimal_places=2)
    estimated_equity_shares = models.DecimalField(blank=True,
                                                  null=True,
                                                  max_digits=9,
                                                  decimal_places=2)
    date_created = models.DateTimeField(auto_now_add=True)
    city = models.CharField(max_length=255, blank=True, null=True)
    state = models.CharField(max_length=255, blank=True, null=True)
    country = models.CharField(max_length=100, blank=True, null=True)
    country_code = models.CharField(max_length=100, blank=True, null=True)
    location = models.CharField(max_length=150, blank=True, null=True)
    status = models.CharField(max_length=100, blank=True, null=True)
    remote = models.BooleanField(default=False)
    featured = models.BooleanField(default=False)
    mix = models.BooleanField(default=False)
    background = models.TextField(blank=True, null=True)
    progress = models.TextField(blank=True, null=True)
    scope = models.TextField(blank=True, null=True)
    specs = models.TextField(blank=True, null=True)
    private_info = models.TextField(blank=True, null=True)
    published = models.BooleanField(default=False)
    approved = models.BooleanField(default=False)
    role = models.CharField(max_length=100, blank=True, null=True)
    years = models.IntegerField(blank=True, null=True)
    employment_type = models.CharField(max_length=100, default='freelance')
    autorenew = models.BooleanField(default=False)
    sku = models.CharField(max_length=50, blank=True, null=True)
    views = models.IntegerField(default=0)

    objects = ProjectManager()

    def __str__(self):
        return self.title

    def __unicode__(self):
        return self.title

    class Meta:
        ordering = ['-date_created']

    def save(self, *args, **kwargs):
        self.slug = slugify(self.title)
        super(Project, self).save(*args, **kwargs)

    def preauth(self, promo=None):
        product = Product.objects.get(sku=self.sku)
        try:
            order = Order.objects.get(content_type__pk=self.content_type.id,
                                      object_id=self.id,
                                      status='preauth')
        except Order.DoesNotExist:
            if promo:
                promo = Promo.objects.get(code=promo.lower())
            order = Order(content_object=self,
                          product=product,
                          user=self.project_manager,
                          status='preauth',
                          promo=promo)
            order.save()
            order.charge()
        return order

    def activate(self):
        today = datetime.now().date()
        if not self.sku:
            self.sku = 'free'
        product = Product.objects.get(sku=self.sku)
        self.expire_date = today + timedelta(days=product.interval)
        self.status = 'active'
        self.save()
        return self

    def subscribe(self, promo=None):
        try:
            order = Order.objects.get(content_type__pk=self.content_type.id,
                                      object_id=self.id,
                                      status='preauth')
        except Order.DoesNotExist:
            order = self.preauth(promo=promo)
        if order.product.sku != self.sku:
            product = Product.objects.get(sku=self.sku)
            order.product = product
            order.save()
        order.capture()
        if self.project_manager.referral_code:
            response = vl_conversion(self.project_manager)
            context = {
                'name': self.project_manager.name,
                'title': self.title,
                'email': self.project_manager.email,
                'location': self.project_manager.location,
                'referral_code': self.project_manager.referral_code,
                'url': settings.VL_CAMPAIGN_URL
            }
            send_to_emails('referral-conversion', settings.ADMINS, context)
        self.activate()
        return self

    def deactivate(self):
        today = datetime.now().date()
        if self.expire_date and self.expire_date <= today:
            if self.sku != 'free':
                order = Order.objects.get(
                    content_type__pk=self.content_type.id,
                    object_id=self.id,
                    status='active')
                order.status = 'expired'
                order.save()
            self.status = 'expired'
            self.published = False
            self.save()
            if not self.deleted:
                template = 'project-expired-free' if self.sku == 'free' else 'project-expired'
                url = '{0}/project/upgrade/{1}/'.format(
                    settings.BASE_URL, self.slug
                ) if self.sku == 'free' else '{0}/project/renew/{1}/'.format(
                    settings.BASE_URL, self.slug)
                send_mail(
                    template, [self.project_manager], {
                        'fname': self.project_manager.first_name,
                        'title': self.title,
                        'url': url
                    })
        return self

    @property
    def content_type(self):
        return ContentType.objects.get_for_model(self)

    @property
    def location(self):
        return self.city if self.city else self.project_manager.city

    @property
    def skills_str(self):
        return self.skills.get_tag_string()

    @property
    def nda_list(self):
        ndas = NDA.objects.filter(proposal__project=self)
        nda_list = [nda.receiver.id for nda in ndas]
        nda_list.append(self.project_manager.id)
        return nda_list