Пример #1
0
    def deadline_reached(self):
        # BB-3616 "Funding projects should not look at (in)complete tasks for their status."
        from bluebottle.utils.model_dispatcher import get_task_model

        TASK_MODEL = get_task_model()

        if self.is_funding:
            if self.amount_donated >= self.amount_asked:
                self.status = ProjectPhase.objects.get(slug="done-complete")
            elif self.amount_donated <= 20 or not self.campaign_started:
                self.status = ProjectPhase.objects.get(slug="closed")
            else:
                self.status = ProjectPhase.objects.get(slug="done-incomplete")
        else:
            if self.task_set.filter(
                    status__in=[TASK_MODEL.TaskStatuses.in_progress,
                                TASK_MODEL.TaskStatuses.open]).count() > 0:
                self.status = ProjectPhase.objects.get(slug="done-incomplete")
            else:
                self.status = ProjectPhase.objects.get(slug="done-complete")
        self.campaign_ended = now()
        self.save()

        data = {
            "Project": self.title,
            "Author": self.owner.username
        }

        bb_track("Project Deadline Reached", data)
Пример #2
0
from django.contrib.auth import get_user_model
from django.contrib import admin
from django.core.urlresolvers import reverse
from django.forms import ModelForm
from django.forms.models import ModelChoiceField

from bluebottle.utils.model_dispatcher import get_user_model, get_task_model, get_taskmember_model, \
    get_taskfile_model, get_task_skill_model

BB_USER_MODEL = get_user_model()
BB_TASK_MODEL = get_task_model()
BB_TASKMEMBER_MODEL = get_taskmember_model()
BB_TASKFILE_MODEL = get_taskfile_model()
BB_SKILL_MODEL = get_task_skill_model()


class TaskMemberAdminInline(admin.StackedInline):
    model = BB_TASKMEMBER_MODEL

    raw_id_fields = ('member', )
    readonly_fields = ('created', )
    fields =  readonly_fields + ('member', 'status', 'motivation', 'time_spent')
    extra = 0


class TaskFileAdminInline(admin.StackedInline):
    model = BB_TASKFILE_MODEL

    raw_id_fields = ('author', )
    readonly_fields = ('created', )
    fields =  readonly_fields + ('author', 'file')
Пример #3
0
    def get_open_tasks(self):
        from bluebottle.utils.model_dispatcher import get_task_model

        TASK_MODEL = get_task_model()
        return self.task_set.filter(status=TASK_MODEL.TaskStatuses.open).all()
Пример #4
0
    def task_count(self):
        """ Returns the number of tasks a user is the author of  and / or is a task member in """
        task_count = get_task_model().objects.filter(author=self).count()
        taskmember_count = get_taskmember_model().objects.filter(member=self, status__in=['applied', 'accepted', 'realized']).count()

        return task_count + taskmember_count