Example #1
0
class DeveloperApplication(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    email = models.EmailField(unique=True, validators=[validate_email])
    phone_number = models.CharField(max_length=15)
    country = CountryField()
    city = models.CharField(max_length=50)
    stack = models.TextField()
    experience = models.TextField()
    discovery_story = models.TextField()
    status = models.PositiveSmallIntegerField(
        choices=APPLICATION_STATUS_CHOICES,
        help_text=','.join(['%s - %s' % (item[0], item[1]) for item in APPLICATION_STATUS_CHOICES]),
        default=REQUEST_STATUS_INITIAL
    )
    created_at = models.DateTimeField(auto_now_add=True)
    confirmation_key = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
    confirmation_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)

    def __str__(self):
        return self.display_name

    @property
    def display_name(self):
        return '%s %s' % (self.first_name, self.last_name)

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

    country_name.fget.short_description = 'country'
Example #2
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)
Example #3
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
Example #4
0
class AppIntegration(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             on_delete=models.CASCADE)
    provider = models.CharField(
        max_length=30,
        choices=APP_INTEGRATION_PROVIDER_CHOICES,
        help_text=','.join([
            '%s - %s' % (item[0], item[1])
            for item in APP_INTEGRATION_PROVIDER_CHOICES
        ]))
    token = models.TextField(
        verbose_name='token',
        help_text='"oauth_token" (OAuth1) or access token (OAuth2)')
    token_secret = models.TextField(
        blank=True,
        verbose_name='token secret',
        help_text='"oauth_token_secret" (OAuth1) or refresh token (OAuth2)')
    extra = models.TextField(blank=True,
                             null=True)  # JSON formatted extra details
    expires_at = models.DateTimeField(blank=True,
                                      null=True,
                                      verbose_name='expires at')
    updated_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        unique_together = ('user', 'provider')
        verbose_name = 'app integration'
        verbose_name_plural = 'app integrations'

    def __unicode__(self):
        return '%s - %s' % (self.user.get_short_name(),
                            self.get_provider_display())
Example #5
0
class BTCWallet(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             on_delete=models.CASCADE)
    provider = models.CharField(max_length=30,
                                choices=BTC_WALLET_PROVIDER_CHOICES,
                                help_text=','.join([
                                    '%s - %s' % (item[0], item[1])
                                    for item in BTC_WALLET_PROVIDER_CHOICES
                                ]))
    token = models.TextField(
        verbose_name='token',
        help_text='"oauth_token" (OAuth1) or access token (OAuth2)')
    token_secret = models.TextField(
        blank=True,
        verbose_name='token secret',
        help_text='"oauth_token_secret" (OAuth1) or refresh token (OAuth2)')
    expires_at = models.DateTimeField(blank=True,
                                      null=True,
                                      verbose_name='expires at')
    updated_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        unique_together = ('user', 'provider')
        verbose_name = 'bitcoin wallet'

    def __unicode__(self):
        return '%s - %s' % (self.user.get_short_name(),
                            self.get_provider_display())
Example #6
0
class Document(models.Model):
    project = models.ForeignKey(Project)
    type = models.CharField(choices=PROJECT_DOCUMENT_CHOICES,
                            max_length=30,
                            default=DOC_OTHER)
    url = models.URLField(blank=True, null=True)
    file = models.FileField(verbose_name='Upload',
                            upload_to='documents/%Y/%m/%d',
                            blank=True,
                            null=True)
    title = models.CharField(max_length=100, blank=True, null=True)
    description = models.TextField(blank=True, null=True)
    created_by = models.ForeignKey(settings.AUTH_USER_MODEL)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    legacy_id = models.PositiveIntegerField(blank=True, null=True)
    migrated_at = models.DateTimeField(blank=True, null=True)

    def __str__(self):
        return '{} | {}'.format(self.type, self.project)

    class Meta:
        ordering = ['-created_at']

    @staticmethod
    @allow_staff_or_superuser
    def has_read_permission(request):
        return True

    @allow_staff_or_superuser
    def has_object_read_permission(self, request):
        return self.project.is_participant(request.user)

    @staticmethod
    @allow_staff_or_superuser
    def has_write_permission(request):
        return request.user.is_project_manager or request.user.is_project_owner

    @allow_staff_or_superuser
    def has_object_write_permission(self, request):
        return request.user == self.created_by

    @property
    def download_url(self):
        if self.file:
            return '{}{}'.format(
                not re.match(r'://', self.file.url) and TUNGA_URL or '',
                self.file.url)
        elif self.url:
            return self.url
        return None
Example #7
0
class Application(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             on_delete=models.CASCADE)
    task = models.ForeignKey(Task, on_delete=models.CASCADE)
    accepted = models.BooleanField(default=False)
    responded = models.BooleanField(default=False)
    pitch = models.CharField(max_length=1000, blank=True, null=True)
    hours_needed = models.PositiveIntegerField(blank=True, null=True)
    hours_available = models.PositiveIntegerField(blank=True, null=True)
    remarks = models.TextField(
        blank=True,
        null=True)  # These will also be delivered as messages to the client
    deliver_at = models.DateTimeField(blank=True, null=True)
    created_at = models.DateTimeField(auto_now_add=True)
    channels = GenericRelation(Channel, related_query_name='task_applications')

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

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

    @staticmethod
    @allow_staff_or_superuser
    def has_read_permission(request):
        return True

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

    @staticmethod
    @allow_staff_or_superuser
    def has_write_permission(request):
        return request.user.type == USER_TYPE_DEVELOPER

    @staticmethod
    @allow_staff_or_superuser
    def has_update_permission(request):
        return True

    @allow_staff_or_superuser
    def has_object_write_permission(self, request):
        return request.user == self.user

    @allow_staff_or_superuser
    def has_object_update_permission(self, request):
        # Task owner can update applications
        return request.user == self.user or request.user == self.task.user
Example #8
0
class SavedTask(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             on_delete=models.CASCADE)
    task = models.ForeignKey(Task, on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)

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

    @staticmethod
    @allow_staff_or_superuser
    def has_read_permission(request):
        return True

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

    @staticmethod
    @allow_staff_or_superuser
    def has_write_permission(request):
        return request.user.type == USER_TYPE_DEVELOPER

    @allow_staff_or_superuser
    def has_object_write_permission(self, request):
        return request.user == self.user
Example #9
0
class TaskRequest(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             on_delete=models.DO_NOTHING)
    task = models.ForeignKey(Task, on_delete=models.CASCADE)
    type = models.PositiveSmallIntegerField(
        choices=TASK_REQUEST_CHOICES,
        help_text=','.join(
            ['%s - %s' % (item[0], item[1]) for item in TASK_REQUEST_CHOICES]))
    created_at = models.DateTimeField(auto_now_add=True)

    def __unicode__(self):
        return '%s - %s' % (self.get_type_display(), self.task.summary)

    @staticmethod
    @allow_staff_or_superuser
    def has_read_permission(request):
        return True

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

    @staticmethod
    @allow_staff_or_superuser
    def has_write_permission(request):
        return request.user.type == USER_TYPE_DEVELOPER

    @allow_staff_or_superuser
    def has_object_write_permission(self, request):
        return request.user == self.user
Example #10
0
class UserRequest(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING, related_name='user_requests')
    created_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING, related_name='users_requested')
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return '{} requested {}'.format(self.created_by.short_name(), self.user.short_name())
Example #11
0
class Connection(models.Model):
    from_user = models.ForeignKey(
        settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='connections_initiated')
    to_user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='connection_requests')
    accepted = models.BooleanField(default=False)
    responded = models.BooleanField(default=False)
    status = models.CharField(
        max_length=30, choices=CONNECTION_STATUS_CHOICES, default=STATUS_INITIAL,
        help_text=', '.join(['%s - %s' % (item[0], item[1]) for item in CONNECTION_STATUS_CHOICES])
    )
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return '%s -> %s' % (self.from_user.get_short_name, self.to_user.get_short_name)

    class Meta:
        ordering = ['-created_at']

    @allow_staff_or_superuser
    def has_object_read_permission(self, request):
        return request.user == self.from_user or request.user == self.to_user

    @allow_staff_or_superuser
    def has_object_write_permission(self, request):
        return request.user == self.from_user or request.user == self.to_user
Example #12
0
class Connection(models.Model):
    from_user = models.ForeignKey(settings.AUTH_USER_MODEL,
                                  on_delete=models.CASCADE,
                                  related_name='connections_initiated')
    to_user = models.ForeignKey(settings.AUTH_USER_MODEL,
                                on_delete=models.CASCADE,
                                related_name='connection_requests')
    accepted = models.BooleanField(default=False)
    responded = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)

    def __unicode__(self):
        return '%s -> %s' % (self.from_user.get_short_name,
                             self.to_user.get_short_name)

    class Meta:
        ordering = ['-created_at']

    @allow_staff_or_superuser
    def has_object_read_permission(self, request):
        return request.user == self.from_user or request.user == self.to_user

    @allow_staff_or_superuser
    def has_object_write_permission(self, request):
        return request.user == self.from_user or request.user == self.to_user
Example #13
0
class IntegrationEvent(models.Model):
    id = models.CharField(max_length=30, primary_key=True)
    name = models.CharField(max_length=30)
    description = models.CharField(max_length=200, blank=True, null=True)
    created_by = models.ForeignKey(settings.AUTH_USER_MODEL,
                                   blank=True,
                                   null=True,
                                   related_name='integration_events_created',
                                   on_delete=models.DO_NOTHING)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return '%s - %s' % (self.id, self.name)

    class Meta:
        ordering = ['id', 'name']
Example #14
0
class IntegrationMeta(models.Model):
    integration = models.ForeignKey(Integration, on_delete=models.CASCADE)
    meta_key = models.CharField(max_length=30)
    meta_value = models.CharField(max_length=30)
    created_by = models.ForeignKey(settings.AUTH_USER_MODEL,
                                   related_name='integration_meta_created',
                                   blank=True,
                                   null=True,
                                   on_delete=models.DO_NOTHING)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return '%s | %s - %s' % (self.integration, self.meta_key,
                                 self.meta_value)

    class Meta:
        ordering = ['created_at']
Example #15
0
class ProgressEvent(models.Model):
    task = models.ForeignKey(Task, on_delete=models.CASCADE)
    type = models.PositiveSmallIntegerField(
        choices=PROGRESS_EVENT_TYPE_CHOICES,
        default=PROGRESS_EVENT_TYPE_DEFAULT,
        help_text=','.join([
            '%s - %s' % (item[0], item[1])
            for item in PROGRESS_EVENT_TYPE_CHOICES
        ]))
    due_at = models.DateTimeField()
    title = models.CharField(max_length=200, blank=True, null=True)
    description = models.CharField(max_length=1000, blank=True, null=True)
    created_by = models.ForeignKey(settings.AUTH_USER_MODEL,
                                   related_name='progress_events_created',
                                   blank=True,
                                   null=True)
    created_at = models.DateTimeField(auto_now_add=True)
    last_reminder_at = models.DateTimeField(blank=True, null=True)

    def __unicode__(self):
        return '%s | %s - %s' % (self.get_type_display(), self.task.summary,
                                 self.due_at)

    class Meta:
        unique_together = ('task', 'due_at')
        ordering = ['due_at']

    @staticmethod
    @allow_staff_or_superuser
    def has_read_permission(request):
        return True

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

    @staticmethod
    @allow_staff_or_superuser
    def has_write_permission(request):
        return request.user.type == USER_TYPE_PROJECT_OWNER

    @allow_staff_or_superuser
    def has_object_write_permission(self, request):
        return request.user == self.task.user
Example #16
0
class Inquirer(models.Model):
    name = models.CharField(max_length=50, blank=True, null=True)
    email = models.EmailField(blank=True, null=True)
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return '%s (%s)' % (self.name, self.email or self.id)

    class Meta:
        ordering = ['-created_at']
Example #17
0
class ProjectMeta(models.Model):
    project = models.ForeignKey(Project, on_delete=models.CASCADE)
    meta_key = models.CharField(max_length=30)
    meta_value = models.TextField()
    created_by = models.ForeignKey(settings.AUTH_USER_MODEL,
                                   related_name='project_meta_created',
                                   blank=True,
                                   null=True,
                                   on_delete=models.DO_NOTHING)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __str__(self):
        return '{} | {} - {}'.format(self.project, self.meta_key,
                                     self.meta_value)

    class Meta:
        ordering = ['created_at']
        unique_together = ('project', 'meta_key')
Example #18
0
class Project(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             related_name='projects_created',
                             on_delete=models.DO_NOTHING)
    title = models.CharField(max_length=200)
    description = models.TextField(blank=True, null=True)
    deadline = models.DateTimeField(blank=True, null=True)
    closed = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    closed_at = models.DateTimeField(blank=True, null=True)

    def __unicode__(self):
        return self.title

    class Meta:
        ordering = ['-created_at']
        unique_together = ('user', 'title')

    @staticmethod
    @allow_staff_or_superuser
    def has_read_permission(request):
        return request.user.type == USER_TYPE_PROJECT_OWNER

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

    @staticmethod
    @allow_staff_or_superuser
    def has_write_permission(request):
        return request.user.type == USER_TYPE_PROJECT_OWNER

    @allow_staff_or_superuser
    def has_object_write_permission(self, request):
        return request.user == self.user

    @property
    def excerpt(self):
        try:
            return strip_tags(self.description).strip()
        except:
            return None
Example #19
0
class WhitePaperUser(models.Model):
    first_name = models.CharField(max_length=100)
    last_name = models.CharField(max_length=100)
    company = models.CharField(max_length=100)
    email = models.EmailField(max_length=100)
    phone_number = models.CharField(max_length=20)
    country = CountryField()
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return '{} {} - {}'.format(self.first_name, self.email, self.company)
class Submission(models.Model):
    student_profile = models.ForeignKey('users.StudentProfile',
                                        on_delete=models.CASCADE,
                                        related_name='student_submissions')
    uploaded_file = models.FileField(upload_to='student_uploads/')
    uploaded_time = models.DateTimeField(auto_now_add=True)
    post = models.ForeignKey('blog.Post',
                             on_delete=models.CASCADE,
                             related_name='post_submissions')

    class Meta:
        unique_together = ('student_profile', 'post')
Example #21
0
class IntegrationActivity(models.Model):
    integration = models.ForeignKey(Integration,
                                    on_delete=models.CASCADE,
                                    related_name='activities')
    event = models.ForeignKey(IntegrationEvent,
                              related_name='integration_activities')
    action = models.CharField(max_length=30, blank=True, null=True)
    url = models.URLField(blank=True, null=True)
    ref = models.CharField(max_length=30, blank=True, null=True)
    ref_name = models.CharField(max_length=50, blank=True, null=True)
    username = models.CharField(max_length=30, blank=True, null=True)
    fullname = models.CharField(max_length=50, blank=True, null=True)
    avatar_url = models.URLField(blank=True, null=True)
    title = models.CharField(max_length=200, blank=True, null=True)
    body = models.TextField(blank=True, null=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return '%s | ' % (self.integration, )

    class Meta:
        ordering = ['created_at']
Example #22
0
class Connection(models.Model):
    """
    TODO: When implementing the `request_connection` api:
    * Add `from_type = { REQUESTER, REQUESTEE }`
    * Add `status = { requested, accepted, connected }`
    * Don't show `contact_details` unless `status == connected`
    """
    class Meta:
        unique_together = ('from_profile', 'to_profile')

    date_created = models.DateTimeField(auto_now_add=True)
    from_profile = models.ForeignKey('accounts.Profile',
                                     related_name='from_profile')
    to_profile = models.ForeignKey('accounts.Profile',
                                   related_name='to_profile')
Example #23
0
class WhitePaperUser(models.Model):
    white_paper_choices = (
        ('best_african_countries_for_outsourcing', 'best_african_countries_for_outsourcing'),
        ('scaling_your_team_with_remote_developers', 'scaling_your_team_with_remote_developers')
    )
    paper = models.CharField(max_length=255, choices=white_paper_choices)
    first_name = models.CharField(max_length=100)
    last_name = models.CharField(max_length=100)
    company = models.CharField(max_length=100)
    email = models.EmailField(max_length=100)
    phone_number = models.CharField(max_length=20)
    country = CountryField()
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return '{} {} - {}'.format(self.first_name, self.email, self.company)
Example #24
0
class UserNumber(models.Model):
    """
    Helper table for generating user numbers in a sequence
    """
    user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.number

    class Meta:
        abstract = True

    @property
    def number(self):
        return get_serialized_id(self.id, max_digits=4)
class ContactForm(models.Model):
    """
    Contact form
    """
    submission_types = {("tecnico", "tecnico"), ("particular", "particular"),
                        ("empresa", "empresa"), ("inapropiado", "inapropiado"),
                        ("patreon_link", "patreon_link"), ("otros", "otros")}

    content = models.TextField()
    subject = models.TextField()
    username = models.CharField(max_length=100)
    email = models.CharField(max_length=100)
    submission_type = models.CharField(max_length=100,
                                       choices=submission_types)
    timestamp = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return str(self.content)
Example #26
0
class SocialLink(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    platform = models.ForeignKey(SocialPlatform)
    link = models.URLField(blank=True, null=True)
    username = models.CharField(max_length=100, blank=True, null=True)
    created_at = models.DateTimeField(auto_now_add=True)

    def __unicode__(self):
        return '%s -  %s' % (self.user.get_short_name(), self.platform)

    class Meta:
        unique_together = ('user', 'platform')

    @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
Example #27
0
class ProgressReport(models.Model):
    event = models.OneToOneField(ProgressEvent, on_delete=models.CASCADE)
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             on_delete=models.DO_NOTHING)
    status = models.PositiveSmallIntegerField(
        choices=PROGRESS_REPORT_STATUS_CHOICES,
        help_text=','.join([
            '%s - %s' % (item[0], item[1])
            for item in PROGRESS_REPORT_STATUS_CHOICES
        ]))
    percentage = models.PositiveIntegerField(
        validators=[MinValueValidator(0),
                    MaxValueValidator(100)])
    accomplished = models.TextField()
    next_steps = models.TextField(blank=True, null=True)
    remarks = models.TextField(blank=True, null=True)
    created_at = models.DateTimeField(auto_now_add=True)
    uploads = GenericRelation(Upload, related_query_name='progress_reports')

    def __unicode__(self):
        return '{0} - {1}%'.format(self.event, self.percentage)

    @staticmethod
    @allow_staff_or_superuser
    def has_read_permission(request):
        return True

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

    @staticmethod
    @allow_staff_or_superuser
    def has_write_permission(request):
        return request.user.type == USER_TYPE_DEVELOPER

    @allow_staff_or_superuser
    def has_object_write_permission(self, request):
        return request.user == self.user
Example #28
0
class List(models.Model):
    """Content lists which can be created for each user."""
    user = models.ForeignKey(BucketUser, on_delete=models.CASCADE)
    date_created = models.DateTimeField(auto_now_add=True)
    name = models.CharField(max_length=255, verbose_name="Name")
    slug = models.SlugField(max_length=150,
                            unique=True,
                            editable=False,
                            verbose_name="Slug")
    description = models.TextField(blank=True, verbose_name="Description")
    image = models.ImageField(upload_to='list_images',
                              blank=True,
                              null=True,
                              verbose_name="Image")
    image_thumbnail = ImageSpecField(source='image',
                                     processors=[ResizeToFill(100, 150)],
                                     options={'quality': 100})
    content = models.ManyToManyField(Content,
                                     blank=True,
                                     related_name='content',
                                     verbose_name='Content')
    visibility = models.CharField(max_length=150,
                                  choices=visibility,
                                  default='public',
                                  verbose_name="Visibility")
    topics = tagulous.models.TagField(to=Topic, related_name='list_topic')
    list_bookmarked_by = models.ManyToManyField(BucketUser,
                                                related_name='list_bookmark')

    class Meta:
        ordering = ['name']

    def __str__(self):
        return "{0} by {1}".format(self.name, self.user)

    def save(self, *args, **kwargs):
        self.slug = add_slug(self)
        super().save(*args, **kwargs)
Example #29
0
class SocialPlatform(models.Model):
    name = models.CharField(max_length=100, unique=True)
    url_prefix = models.CharField(max_length=200, blank=True, null=True)
    placeholder = models.CharField(max_length=100, blank=True, null=True)
    icon = models.URLField(blank=True, null=True)
    fa_icon = models.CharField(max_length=20, blank=True, null=True)
    glyphicon = models.CharField(max_length=20, blank=True, null=True)
    created_by = models.ForeignKey(
            settings.AUTH_USER_MODEL, related_name='social_platforms_created', on_delete=models.DO_NOTHING)
    created_at = models.DateTimeField(auto_now_add=True)

    def __unicode__(self):
        return self.name

    @staticmethod
    @allow_staff_or_superuser
    def has_read_permission(request):
        return False

    @staticmethod
    @allow_staff_or_superuser
    def has_write_permission(request):
        return False
Example #30
0
class ProgressReport(models.Model):
    event = models.ForeignKey(ProgressEvent, on_delete=models.CASCADE)
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             on_delete=models.DO_NOTHING)

    # Status details
    status = models.CharField(max_length=50,
                              choices=PROGRESS_REPORT_STATUS_CHOICES,
                              help_text=','.join([
                                  '%s - %s' % (item[0], item[1])
                                  for item in PROGRESS_REPORT_STATUS_CHOICES
                              ]),
                              blank=True,
                              null=True)
    percentage = models.PositiveIntegerField(
        validators=[MinValueValidator(0),
                    MaxValueValidator(100)],
        blank=True,
        null=True)
    accomplished = models.TextField(blank=True, null=True)
    todo = models.TextField(blank=True, null=True)
    obstacles = models.TextField(blank=True, null=True)
    obstacles_prevention = models.TextField(blank=True, null=True)
    remarks = models.TextField(blank=True, null=True)
    stuck_reason = models.CharField(
        max_length=50,
        choices=PROGRESS_REPORT_STUCK_REASON_CHOICES,
        help_text=','.join([
            '%s - %s' % (item[0], item[1])
            for item in PROGRESS_REPORT_STUCK_REASON_CHOICES
        ]),
        blank=True,
        null=True)
    stuck_details = models.TextField(blank=True, null=True)

    # Deliverables
    rate_deliverables = models.PositiveIntegerField(
        validators=[MinValueValidator(1),
                    MaxValueValidator(5)],
        blank=True,
        null=True)

    # Deadline Info
    started_at = models.DateTimeField(blank=True, null=True)
    last_deadline_met = models.NullBooleanField(blank=True, null=True)
    deadline_miss_communicated = models.NullBooleanField(blank=True, null=True)
    deadline_report = models.TextField(blank=True, null=True)
    next_deadline = models.DateTimeField(blank=True, null=True)
    next_deadline_meet = models.NullBooleanField(blank=True, null=True)
    next_deadline_fail_reason = models.TextField(blank=True, null=True)

    # PMs only
    team_appraisal = models.TextField(blank=True, null=True)

    # Clients only
    deliverable_satisfaction = models.NullBooleanField(blank=True, null=True)
    rate_communication = models.PositiveIntegerField(
        validators=[MinValueValidator(1),
                    MaxValueValidator(5)],
        blank=True,
        null=True)
    pm_communication = models.NullBooleanField(blank=True, null=True)

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    legacy_id = models.PositiveIntegerField(blank=True, null=True)
    migrated_at = models.DateTimeField(blank=True, null=True)

    def __str__(self):
        return '{0} - {1}%'.format(self.event, self.percentage)

    class Meta:
        ordering = ['-created_at']

    @staticmethod
    @allow_staff_or_superuser
    def has_read_permission(request):
        return True

    @allow_staff_or_superuser
    def has_object_read_permission(self, request):
        return self.event.project.is_participant(request)

    @staticmethod
    @allow_staff_or_superuser
    def has_write_permission(request):
        return request.user.is_developer or request.user.is_project_manager or request.user.is_project_owner

    @allow_staff_or_superuser
    def has_object_write_permission(self, request):
        return request.user == self.user