コード例 #1
0
 def __init__(self, *args, **kwargs):
     parent = kwargs.pop('parent', None)
     user = kwargs.pop('user', AnonymousUser())
     super(NodeForm, self).__init__(*args, **kwargs)
     # Set initial values if node does not exist
     if parent and not self.instance.pk:  # A new node with a parent
         related = parent.related_projects.all()
         self.fields['related_projects'].initial = related
         self.fields['focus_area'].initial = parent.focus_areas.all()
     # Limit todo states to those valid to the user
     self.fields['todo_state'].queryset = TodoState.get_visible(user=user)
コード例 #2
0
ファイル: forms.py プロジェクト: m3wolf/orgwolf
 def __init__(self, *args, **kwargs):
     parent = kwargs.pop('parent', None)
     user = kwargs.pop('user', AnonymousUser())
     super(NodeForm, self).__init__(*args, **kwargs)
     # Set initial values if node does not exist
     if parent and not self.instance.pk: # A new node with a parent
         related = parent.related_projects.all()
         self.fields['related_projects'].initial = related
         self.fields['focus_area'].initial = parent.focus_areas.all()
     # Limit todo states to those valid to the user
     self.fields['todo_state'].queryset = TodoState.get_visible(user=user)
コード例 #3
0
ファイル: views.py プロジェクト: m3wolf/orgwolf
 def get_queryset(self):
     return TodoState.get_visible(user=self.request.user)
コード例 #4
0
def todo_states_json(context):
    states = TodoState.get_visible(user=context['request'].user)
    serializer = TodoStateSerializer(states, many=True)
    return json.dumps(serializer.data)
コード例 #5
0
def todo_states_json(context):
    states = TodoState.get_visible(user=context['request'].user)
    serializer = TodoStateSerializer(states, many=True)
    return mark_safe(json.dumps(serializer.data))
コード例 #6
0
def populate_todo_states(reset=False):
    """
    Create objects for the system default todo-states.
    If the argument reset=True then all current TodoState objects
    will be deleted.
    """
    if reset:
        TodoState.objects.all().delete()
    system_states = [{'abbr': 'NEXT',
                      'display': 'Next Action',
                      'actionable': True,
                      'closed': False,
                      'owner': None,
                      '_color_rgb': 0,
                      '_color_alpha': 0},
                     {'abbr': 'ACTN',
                      'display': 'Future Action',
                      'actionable': False,
                      'closed': False,
                      'owner': None,
                      '_color_rgb': 0,
                      '_color_alpha': 0},
                     {'abbr': 'DONE',
                      'display': 'Completed',
                      'actionable': False,
                      'closed': True,
                      'owner': None,
                      '_color_rgb': 0,
                      '_color_alpha': 0},
                     {'abbr': 'SMDY',
                      'display': 'Someday Maybe',
                      'actionable': False,
                      'closed': False,
                      'owner': None,
                      '_color_rgb': 0,
                      '_color_alpha': 0},
                     {'abbr': 'DFRD',
                      'display': 'Deferred',
                      'actionable': False,
                      'closed': False,
                      'owner': None,
                      '_color_rgb': 0,
                      '_color_alpha': 0},
                     {'abbr': 'WAIT',
                      'display': 'Waiting For',
                      'actionable': False,
                      'closed': True,
                      'owner': None,
                      '_color_rgb': 0,
                      '_color_alpha': 0},
                     {'abbr': 'CNCL',
                      'display': 'Cancelled',
                      'actionable': False,
                      'closed': True,
                      'owner': None,
                      '_color_rgb': 0,
                      '_color_alpha': 0},
                     {'abbr': 'HARD',
                      'display': 'Hard Scheduled',
                      'actionable': False,
                      'closed': False,
                      'owner': None,
                      '_color_rgb': 0,
                      '_color_alpha': 0}]
    for state in system_states:
        todo_state = TodoState(abbreviation = state['abbr'],
                               display_text = state['display'],
                               actionable = state['actionable'],
                               closed = state['closed'],
                               _color_rgb = state['_color_rgb'],
                               _color_alpha = state['_color_alpha'])
        todo_state.save()
コード例 #7
0
 def get_queryset(self):
     return TodoState.get_visible(user=self.request.user)