コード例 #1
0
ファイル: forms.py プロジェクト: sourabhsmf/remo
    def clean(self):
        """Clean Form."""
        cdata = super(RotmNomineeForm, self).clean()
        user = self.instance.user

        if not user_is_rep(user):
            raise ValidationError('You cannot nominate a non Rep user.')
        return cdata
コード例 #2
0
ファイル: forms.py プロジェクト: Josespaul/remo
    def clean(self):
        """Clean Form."""
        cdata = super(RotmNomineeForm, self).clean()
        user = self.instance.user

        if not user_is_rep(user):
            raise ValidationError('You cannot nominate a non Rep user.')
        return cdata
コード例 #3
0
    def get_action_items(self):
        # Avoid circular dependency
        from remo.base.templatetags.helpers import user_is_rep
        from remo.dashboard.models import Item
        ActionItem = get_model('dashboard', 'ActionItem')

        if not self.assigned_to or not user_is_rep(self.assigned_to):
            return []

        action_items = []
        actions = [
            (_get_action_name(ADD_RECEIPTS_ACTION,
                              self), 'waiting_receipts', ActionItem.NORMAL),
            (_get_action_name(ADD_REPORT_ACTION,
                              self), 'waiting_report', ActionItem.NORMAL),
            (_get_action_name(ADD_PHOTOS_ACTION,
                              self), 'waiting_photos', ActionItem.NORMAL),
            (_get_action_name(ADD_REPORTS_PHOTOS_ACTION, self),
             'waiting_report_photos', ActionItem.NORMAL),
            (_get_action_name(REVIEW_BUDGET_REQUEST_ACTION, self),
             'council_member_assigned', ActionItem.BLOCKER)
        ]

        for action_name, attr, priority in actions:
            if getattr(self, attr, None):
                action_item = Item(action_name, self.assigned_to, priority,
                                   None)
                action_items.append(action_item)

        mentor_action = _get_action_name(WAITING_MENTOR_VALIDATION_ACTION,
                                         self)
        if self.assigned_to and user_is_rep(self.assigned_to):
            mentor = self.assigned_to
            if self.pending_mentor_validation:
                action_item = Item(mentor_action, mentor, ActionItem.BLOCKER,
                                   None)
                action_items.append(action_item)

        action_name = _get_action_name(NEEDINFO_ACTION, self)
        for user in self.budget_needinfo.all():
            action_item = Item(action_name, user, ActionItem.CRITICAL, None)
            action_items.append(action_item)

        return action_items
コード例 #4
0
ファイル: models.py プロジェクト: MichaelKohler/remo
    def get_action_items(self):
        # Avoid circular dependency
        from remo.base.templatetags.helpers import user_is_rep
        from remo.dashboard.models import Item
        ActionItem = get_model('dashboard', 'ActionItem')

        if not self.assigned_to or not user_is_rep(self.assigned_to):
            return []

        action_items = []
        actions = [
            (_get_action_name(ADD_RECEIPTS_ACTION, self),
             'waiting_receipts', ActionItem.NORMAL),
            (_get_action_name(ADD_REPORT_ACTION, self),
             'waiting_report', ActionItem.NORMAL),
            (_get_action_name(ADD_PHOTOS_ACTION, self),
             'waiting_photos', ActionItem.NORMAL),
            (_get_action_name(ADD_REPORTS_PHOTOS_ACTION, self),
             'waiting_report_photos', ActionItem.NORMAL),
            (_get_action_name(REVIEW_BUDGET_REQUEST_ACTION, self),
             'council_member_assigned', ActionItem.BLOCKER)
        ]

        for action_name, attr, priority in actions:
            if getattr(self, attr, None):
                action_item = Item(action_name, self.assigned_to, priority, None)
                action_items.append(action_item)

        mentor_action = _get_action_name(WAITING_MENTOR_VALIDATION_ACTION, self)
        if self.assigned_to and user_is_rep(self.assigned_to):
            mentor = self.assigned_to
            if self.pending_mentor_validation:
                action_item = Item(mentor_action, mentor, ActionItem.BLOCKER, None)
                action_items.append(action_item)

        action_name = _get_action_name(NEEDINFO_ACTION, self)
        for user in self.budget_needinfo.all():
            action_item = Item(action_name, user, ActionItem.CRITICAL, None)
            action_items.append(action_item)

        return action_items
コード例 #5
0
    def save(self, *args, **kwargs):
        # Avoid circular dependency
        from remo.base.templatetags.helpers import user_is_rep
        ActionItem = get_model('dashboard', 'ActionItem')

        # Update action items
        action_model = ContentType.objects.get_for_model(self)
        if self.pk:
            # Get saved action item
            action_items = ActionItem.objects.filter(content_type=action_model,
                                                     object_id=self.pk,
                                                     resolved=False)
            # If there is no user or user is not rep or the bug is resolved,
            # resolve the action item too!
            if (not self.assigned_to or not user_is_rep(self.assigned_to)
                    or self.status == 'RESOLVED'):
                action_items.update(resolved=True)
            else:
                possible_actions = [
                    ADD_RECEIPTS_ACTION, ADD_REPORT_ACTION, ADD_PHOTOS_ACTION,
                    ADD_REPORTS_PHOTOS_ACTION, REVIEW_BUDGET_REQUEST_ACTION,
                    WAITING_MENTOR_VALIDATION_ACTION
                ]
                action_names = ([
                    u'{0} {1}'.format(action, self.summary)
                    for action in possible_actions
                ])
                # Resolve any non-valid action items.
                invalid_actions = []
                for action_name, attr in zip(action_names, BUG_ATTRS):
                    if not getattr(self, attr):
                        invalid_actions.append(action_name)
                invalid_action_items = action_items.filter(
                    name__in=invalid_actions)
                for invalid_item in invalid_action_items:
                    ActionItem.resolve(self, invalid_item.user,
                                       invalid_item.name)

                # If the bug changed owner, re-assign it
                current_bug = Bug.objects.get(id=self.pk)
                if current_bug.assigned_to != self.assigned_to:
                    action_items.filter(name__in=action_names).update(
                        user=self.assigned_to)

        super(Bug, self).save()
コード例 #6
0
ファイル: models.py プロジェクト: MichaelKohler/remo
    def save(self, *args, **kwargs):
        # Avoid circular dependency
        from remo.base.templatetags.helpers import user_is_rep
        ActionItem = get_model('dashboard', 'ActionItem')

        # Update action items
        action_model = ContentType.objects.get_for_model(self)
        if self.pk:
            # Get saved action item
            action_items = ActionItem.objects.filter(content_type=action_model,
                                                     object_id=self.pk,
                                                     resolved=False)
            # If there is no user or user is not rep or the bug is resolved,
            # resolve the action item too!
            if (not self.assigned_to or not user_is_rep(self.assigned_to) or
                    self.status == 'RESOLVED'):
                action_items.update(resolved=True)
            else:
                possible_actions = [ADD_RECEIPTS_ACTION, ADD_REPORT_ACTION,
                                    ADD_PHOTOS_ACTION,
                                    ADD_REPORTS_PHOTOS_ACTION,
                                    REVIEW_BUDGET_REQUEST_ACTION,
                                    WAITING_MENTOR_VALIDATION_ACTION]
                action_names = ([u'{0} {1}'.format(action, self.summary)
                                 for action in possible_actions])
                # Resolve any non-valid action items.
                invalid_actions = []
                for action_name, attr in zip(action_names, BUG_ATTRS):
                    if not getattr(self, attr):
                        invalid_actions.append(action_name)
                invalid_action_items = action_items.filter(name__in=invalid_actions)
                for invalid_item in invalid_action_items:
                    ActionItem.resolve(self, invalid_item.user, invalid_item.name)

                # If the bug changed owner, re-assign it
                current_bug = Bug.objects.get(id=self.pk)
                if current_bug.assigned_to != self.assigned_to:
                    action_items.filter(name__in=action_names).update(user=self.assigned_to)

        super(Bug, self).save()