Пример #1
0
    def check_number_of_members_needed(self, task):
        members = get_taskmember_model().objects.filter(task=task, status='accepted')
        total_externals = 0
        for member in members:
            total_externals += member.externals

        members_accepted = members.count() + total_externals

        if task.status == 'open' and task.people_needed <= members_accepted:
            task.set_in_progress()
        return members_accepted
Пример #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
from django.utils import timezone
from django.core import mail
from django.db import IntegrityError
from django.test.utils import override_settings

from bluebottle.test.utils import BluebottleTestCase
from bluebottle.test.factory_models.accounts import BlueBottleUserFactory
from bluebottle.test.factory_models.tasks import TaskFactory, TaskMemberFactory
from bluebottle.utils.model_dispatcher import get_taskmember_model
from bluebottle.test.factory_models.orders import OrderFactory
from bluebottle.test.factory_models.donations import DonationFactory
from bluebottle.test.factory_models.projects import ProjectPhaseFactory, ProjectFactory
from bluebottle.test.factory_models.fundraisers import FundraiserFactory

TASKS_MEMBER_MODEL = get_taskmember_model()


class BlueBottleUserManagerTestCase(BluebottleTestCase):

    """
    Test case for the model manager of the abstract user model.
    """

    def test_create_user(self):
        """
        Tests the manager ``create_user`` method.
        """
        user = BlueBottleUserFactory.create(
            email='*****@*****.**')
Пример #4
0
 def sourcing(self):
     taskmembers = get_taskmember_model().objects.filter(
         task__project=self,
         status__in=['applied', 'accepted', 'realized']
     ).distinct('member')
     return taskmembers.count()
Пример #5
0
 def get_tasks_qs(self):
     return get_taskmember_model().objects.filter(member=self, status__in=['applied', 'accepted', 'realized'])
Пример #6
0
 def tasks_performed(self):
     """ Returns the number of tasks that the user participated in."""
     return get_taskmember_model().objects.filter(member=self, status='realized').count()
Пример #7
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
Пример #8
0
 def check_number_of_members_needed(self, task):
     members_accepted = get_taskmember_model().objects.filter(task=task, status='accepted').count()
     if task.status == 'open' and task.people_needed <= members_accepted:
         task.set_in_progress()