app/soc/modules/ghop/logic/models/task.py
author Daniel Hans <Daniel.M.Hans@gmail.com>
Mon, 02 Nov 2009 23:38:43 +0100
changeset 3074 ebda36efbd61
parent 3059 14421976288a
child 3080 30a33926ab91
permissions -rw-r--r--
HtmlSanitizer becomes Python 2.6 compatible. The Cleaner class must not have any arguments when calling __init__ function for the object class, because in this case Python 2.6 raises TypeError (while previous versions just ignored them).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2401
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     2
#
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     4
#
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     8
#
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    10
#
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    16
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    17
"""GHOPTask (Model) query functions.
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    18
"""
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    19
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    20
__authors__ = [
2823
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    21
    '"Madhusudan.C.S" <madhusudancs@gmail.com>',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    22
    '"Lennard de Rijk" <ljvderijk@gmail.com>',
2401
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    23
  ]
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    24
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    25
2823
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    26
import datetime
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    27
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    28
from google.appengine.ext import db
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    29
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    30
from django.utils import simplejson
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    31
from django.utils.translation import ugettext
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    32
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    33
from soc.logic.models import base
2401
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    34
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    35
import soc.models.linkable
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    36
2407
e23fce20ad3a Changed GHOP module imports to be consistent with rest of Melange code.
Madhusudan C.S. <madhusudancs@gmail.com>
parents: 2401
diff changeset
    37
import soc.modules.ghop.logic.models.organization
e23fce20ad3a Changed GHOP module imports to be consistent with rest of Melange code.
Madhusudan C.S. <madhusudancs@gmail.com>
parents: 2401
diff changeset
    38
import soc.modules.ghop.models.task
2401
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    39
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    40
2823
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    41
STATE_TRANSITIONS = {
2831
a7ed56911653 STATE_TRANSITIONS dictionary values are changed to strings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2823
diff changeset
    42
    'Claimed': 'transitFromClaimed',
a7ed56911653 STATE_TRANSITIONS dictionary values are changed to strings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2823
diff changeset
    43
    'NeedsReview': 'transitFromNeedsReview',
a7ed56911653 STATE_TRANSITIONS dictionary values are changed to strings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2823
diff changeset
    44
    'ActionNeeded': 'transitFromActionNeeded',
a7ed56911653 STATE_TRANSITIONS dictionary values are changed to strings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2823
diff changeset
    45
    'NeedsWork': 'transitFromNeedsWork',
2823
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    46
    }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    47
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    48
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    49
class Logic(base.Logic):
2401
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    50
  """Logic methods for the GHOPTask model.
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    51
  """
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    52
2823
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    53
  DEF_ACTION_NEEDED_MSG = ugettext(
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    54
      '(The Melange Automated System has detected that the intial '
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    55
      'deadline has been passed and it has set the task status to '
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    56
      'ActionNeeded.)')
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    57
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    58
  DEF_NO_MORE_WORK_MSG = ugettext(
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    59
      '(The Melange Automated System has detected that the deadline '
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    60
      'has been passed and no more work can be submitted.)')
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    61
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    62
  DEF_REOPENED_MSG = ugettext(
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    63
      '(The Melange Automated System has detected that the final '
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    64
      'deadline has been passed and it has Reopened the task.)')
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    65
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    66
2407
e23fce20ad3a Changed GHOP module imports to be consistent with rest of Melange code.
Madhusudan C.S. <madhusudancs@gmail.com>
parents: 2401
diff changeset
    67
  def __init__(self, model=soc.modules.ghop.models.task.GHOPTask,
2401
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    68
               base_model=soc.models.linkable.Linkable, 
2407
e23fce20ad3a Changed GHOP module imports to be consistent with rest of Melange code.
Madhusudan C.S. <madhusudancs@gmail.com>
parents: 2401
diff changeset
    69
               scope_logic=soc.modules.ghop.logic.models.organization):
2401
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    70
    """Defines the name, key_name and model for this entity.
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    71
    """
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    72
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    73
    super(Logic, self).__init__(model, base_model=base_model,
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    74
                                scope_logic=scope_logic)
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    75
2823
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    76
  def updateEntityProperties(self, entity, entity_properties,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    77
                             silent=False, store=True):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    78
    """See base.Logic.updateEntityProperties().
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    79
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    80
    Also ensures that the history property of the task is updated in the same
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    81
    datastore operation.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    82
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    83
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    84
    from soc.logic.models import base as base_logic
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    85
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    86
    # TODO: History needs a proper test drive and perhaps a refactoring
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    87
    history = {}
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    88
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    89
    # we construct initial snapshot of the task when it is published
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    90
    # for the first time.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    91
    if entity_properties and 'status' in entity_properties:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    92
      if entity.status == 'Unpublished' or entity.status == 'Unapproved':
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    93
        if entity_properties['status'] == 'Open':
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    94
          history = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    95
              'title': entity.title,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    96
              'description': entity.description,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    97
              'difficulty': entity.difficulty[0].tag,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    98
              'task_type': [type.tag for type in entity.task_type],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    99
              'time_to_complete': entity.time_to_complete,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   100
              'mentors': [m_key.name() for m_key in entity.mentors],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   101
              'user': '',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   102
              'student': '',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   103
              'status': entity.status,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   104
              'deadline': '',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   105
              'created_by': entity.created_by.key().name(),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   106
              'created_on': str(entity.created_on),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   107
              'modified_on': str(entity.modified_on),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   108
              }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   109
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   110
          if entity.modified_by:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   111
            history['modified_by'] = entity.modified_by.key().name()
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   112
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   113
          # initialize history
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   114
          task_history = {}
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   115
      # extract the existing json history from the entity to update it
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   116
    else:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   117
      task_history = simplejson.loads(entity.history)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   118
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   119
      # we construct history for only changed entity properties
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   120
      if entity_properties:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   121
        for property in entity_properties:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   122
          changed_val = getattr(entity, property)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   123
          if changed_val != entity_properties[property]:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   124
            if property == 'deadline':
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   125
              history[property] = str(changed_val)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   126
            else:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   127
              history[property] = changed_val
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   128
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   129
    if history:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   130
      # create a dictionary for the new history update with timestamp as key
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   131
      tstamp = str(datetime.datetime.now())
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   132
      new_history = {tstamp: history}
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   133
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   134
      # update existing history
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   135
      task_history.update(new_history)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   136
      task_history_str = simplejson.dumps(task_history)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   137
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   138
      # update the task's history property
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   139
      history_property = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   140
          'history': task_history_str
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   141
          }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   142
      entity_properties.update(history_property)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   143
2979
ba4aeaaad0a1 Fixed GHOP Task Logic's updateEntityProperties.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2831
diff changeset
   144
    # call the base logic method to store the updated Task entity
ba4aeaaad0a1 Fixed GHOP Task Logic's updateEntityProperties.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2831
diff changeset
   145
    return super(Logic, self).updateEntityProperties(
ba4aeaaad0a1 Fixed GHOP Task Logic's updateEntityProperties.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2831
diff changeset
   146
        entity, entity_properties, silent=silent, store=store)
2823
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   147
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   148
  def updateEntityPropertiesWithCWS(self, entity, entity_properties,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   149
                                    comment_properties=None, 
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   150
                                    ws_properties=None, silent=False):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   151
    """Updates the GHOPTask entity properties and creates a comment
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   152
    entity.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   153
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   154
    Args:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   155
      entity: a model entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   156
      entity_properties: keyword arguments that correspond to entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   157
          properties and their values
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   158
      comment_properties: keyword arguments that correspond to the
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   159
          GHOPTask's to be created comment entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   160
      silent: iff True does not call post store methods.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   161
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   162
3059
14421976288a The work_submission model's update now reflected in views and logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2979
diff changeset
   163
    from soc.modules.ghop.logic.models.comment import logic as \
14421976288a The work_submission model's update now reflected in views and logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2979
diff changeset
   164
        ghop_comment_logic
14421976288a The work_submission model's update now reflected in views and logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2979
diff changeset
   165
    from soc.modules.ghop.logic.models.work_submission import logic as \
2823
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   166
        ghop_work_submission_logic
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   167
    from soc.modules.ghop.models import comment as ghop_comment_model
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   168
    from soc.modules.ghop.models import work_submission as \
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   169
        ghop_work_submission_model
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   170
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   171
    if entity_properties:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   172
      entity = self.updateEntityProperties(entity, entity_properties, 
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   173
                                           silent=silent, store=False)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   174
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   175
    comment_entity = ghop_comment_model.GHOPComment(**comment_properties)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   176
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   177
    ws_entity = None
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   178
    if ws_properties:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   179
      ws_entity = ghop_work_submission_model.GHOPWorkSubmission(
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   180
          **ws_properties)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   181
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   182
    def comment_create():
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   183
      """Method to be run in transaction that stores Task, Comment and
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   184
      WorkSubmission.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   185
      """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   186
      entity.put()
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   187
      if ws_entity:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   188
        ws_entity.put()
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   189
        comment_entity.content = comment_entity.content % (
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   190
            ws_entity.key().id_or_name())
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   191
        comment_entity.put()
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   192
        return entity, comment_entity, ws_entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   193
      else:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   194
        comment_entity.put()
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   195
        return entity, comment_entity, None
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   196
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   197
    entity, comment_entity, ws_entity = db.run_in_transaction(
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   198
        comment_create)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   199
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   200
    if not silent:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   201
      # call the _onCreate methods for the Comment and WorkSubmission
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   202
      if comment_entity:
3059
14421976288a The work_submission model's update now reflected in views and logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2979
diff changeset
   203
        ghop_comment_logic._onCreate(comment_entity)
2823
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   204
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   205
      if ws_entity:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   206
        ghop_work_submission_logic._onCreate(ws_entity)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   207
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   208
    return entity, comment_entity, ws_entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   209
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   210
  def updateOrCreateFromFields(self, properties, silent=False):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   211
    """See base.Logic.updateOrCreateFromFields().
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   212
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   213
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   214
    # TODO: History needs to be tested and perhaps refactored
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   215
    if properties['status'] == 'Open':
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   216
      history = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   217
          'title': properties['title'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   218
          'description': properties['description'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   219
          'difficulty': properties['difficulty']['tags'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   220
          'task_type': properties['type_tags'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   221
          'time_to_complete': properties['time_to_complete'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   222
          'mentors': [m_key.name() for m_key in properties['mentors']],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   223
          'user': '',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   224
          'student': '',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   225
          'status': properties['status'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   226
          'deadline': '',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   227
          'created_on': str(properties['created_on']),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   228
          'modified_on': str(properties['modified_on']),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   229
          }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   230
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   231
      if 'created_by' in properties and properties['created_by']:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   232
        history['created_by'] = properties['created_by'].key().name()
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   233
        history['modified_by'] = properties['modified_by'].key().name()
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   234
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   235
      # Constructs new history from the _constructNewHistory method, assigns
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   236
      # it as a value to the dictionary key with current timestamp and dumps
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   237
      # a JSON string.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   238
      task_history_str = simplejson.dumps({
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   239
          str(datetime.datetime.now()): history,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   240
          })
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   241
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   242
      # update the task's history property
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   243
      history_property = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   244
          'history': task_history_str
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   245
          }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   246
      properties.update(history_property)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   247
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   248
    entity = super(Logic, self).updateOrCreateFromFields(properties, silent)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   249
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   250
    if entity:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   251
      if properties.get('task_type'):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   252
        setattr(entity, 'task_type', properties['task_type'])
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   253
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   254
      if properties.get('difficulty'):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   255
        setattr(entity, 'difficulty', properties['difficulty'])
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   256
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   257
    return entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   258
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   259
  def getFromKeyFieldsWithCWSOr404(self, fields):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   260
    """Returns the Task, all Comments and all WorkSubmissions for the Task
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   261
    specified by the fields argument.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   262
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   263
    For args see base.getFromKeyFieldsOr404().
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   264
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   265
3059
14421976288a The work_submission model's update now reflected in views and logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2979
diff changeset
   266
    from soc.modules.ghop.logic.models.comment import logic as \
14421976288a The work_submission model's update now reflected in views and logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2979
diff changeset
   267
        ghop_comment_logic
14421976288a The work_submission model's update now reflected in views and logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2979
diff changeset
   268
    from soc.modules.ghop.logic.models.work_submission import logic as \
2823
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   269
        ghop_work_submission_logic
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   270
 
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   271
    entity = self.getFromKeyFieldsOr404(fields)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   272
3059
14421976288a The work_submission model's update now reflected in views and logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2979
diff changeset
   273
    comment_entities = ghop_comment_logic.getForFields(
2823
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   274
        ancestors=[entity], order=['created_on'])
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   275
3059
14421976288a The work_submission model's update now reflected in views and logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2979
diff changeset
   276
    ws_entities = ghop_work_submission_logic.getForFields(
2823
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   277
        ancestors=[entity], order=['submitted_on'])
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   278
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   279
    return entity, comment_entities, ws_entities
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   280
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   281
  def updateTaskStatus(self, entity):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   282
    """Method used to transit a task from a state to another state
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   283
    depending on the context. Whenever the deadline has passed.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   284
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   285
    Args:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   286
      entity: The GHOPTask entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   287
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   288
    Returns:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   289
      Task entity and a Comment entity if the occurring transit created one.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   290
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   291
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   292
    from soc.modules.ghop.tasks import task_update
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   293
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   294
    if entity.deadline and datetime.datetime.now() > entity.deadline:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   295
      # calls a specific method to make a transition depending on the
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   296
      # task's current state
2831
a7ed56911653 STATE_TRANSITIONS dictionary values are changed to strings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2823
diff changeset
   297
      transit_func = getattr(self, STATE_TRANSITIONS[entity.status])
2823
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   298
      update_dict = transit_func(entity)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   299
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   300
      comment_properties = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   301
          'parent': entity,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   302
          'scope_path': entity.key().name(),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   303
          'created_by': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   304
          'content': update_dict['content'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   305
          'changes': update_dict['changes'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   306
          }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   307
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   308
      entity, comment_entity, _ = self.updateEntityPropertiesWithCWS(
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   309
          entity, update_dict['properties'], comment_properties)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   310
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   311
      if entity.deadline:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   312
        # only if there is a deadline set we should schedule another task
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   313
        task_update.spawnUpdateTask(entity)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   314
    else:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   315
      comment_entity=None
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   316
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   317
    return entity, comment_entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   318
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   319
  def transitFromClaimed(self, entity):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   320
    """Makes a state transition of a GHOP Task from Claimed state
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   321
    to a relevant state.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   322
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   323
    Args:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   324
      entity: The GHOPTask entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   325
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   326
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   327
    # deadline is extended by 24 hours.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   328
    deadline = entity.deadline + datetime.timedelta(
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   329
        hours=24)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   330
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   331
    properties = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   332
        'status': 'ActionNeeded',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   333
        'deadline': deadline,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   334
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   335
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   336
    changes = [ugettext('User-MelangeAutomatic'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   337
               ugettext('Action-Warned for action'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   338
               ugettext('Status-%s' % (properties['status']))]
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   339
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   340
    content = self.DEF_ACTION_NEEDED_MSG
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   341
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   342
    update_dict = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   343
        'properties': properties,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   344
        'changes': changes,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   345
        'content': content,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   346
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   347
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   348
    return update_dict
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   349
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   350
  def transitFromNeedsReview(self, entity):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   351
    """Makes a state transition of a GHOP Task from NeedsReview state
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   352
    to a relevant state.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   353
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   354
    Args:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   355
      entity: The GHOPTask entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   356
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   357
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   358
    properties = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   359
        'deadline': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   360
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   361
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   362
    changes = [ugettext('User-MelangeAutomatic'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   363
               ugettext('Action-Deadline passed'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   364
               ugettext('Status-%s' % (entity.status))]
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   365
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   366
    content = self.DEF_NO_MORE_WORK_MSG
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   367
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   368
    update_dict = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   369
        'properties': properties,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   370
        'changes': changes,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   371
        'content': content,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   372
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   373
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   374
    return update_dict
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   375
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   376
  def transitFromActionNeeded(self, entity):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   377
    """Makes a state transition of a GHOP Task from ActionNeeded state
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   378
    to a relevant state.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   379
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   380
    Args:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   381
      entity: The GHOPTask entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   382
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   383
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   384
    properties = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   385
        'user': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   386
        'student': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   387
        'status': 'Reopened',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   388
        'deadline': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   389
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   390
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   391
    changes = [ugettext('User-MelangeAutomatic'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   392
               ugettext('Action-Forcibly reopened'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   393
               ugettext('Status-Reopened')]
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   394
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   395
    content = self.DEF_REOPENED_MSG
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   396
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   397
    update_dict = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   398
        'properties': properties,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   399
        'changes': changes,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   400
        'content': content,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   401
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   402
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   403
    return update_dict
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   404
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   405
  def transitFromNeedsWork(self, entity):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   406
    """Makes a state transition of a GHOP Task from NeedsWork state
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   407
    to a relevant state.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   408
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   409
    Args:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   410
      entity: The GHOPTask entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   411
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   412
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   413
    properties = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   414
        'user': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   415
        'student': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   416
        'status': 'Reopened',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   417
        'deadline': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   418
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   419
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   420
    changes = [ugettext('User-MelangeAutomatic'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   421
               ugettext('Action-Forcibly reopened'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   422
               ugettext('Status-Reopened')]
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   423
    
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   424
    update_dict = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   425
        'properties': properties,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   426
        'changes': changes,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   427
        'content': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   428
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   429
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   430
    return update_dict
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   431
2401
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
   432
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
   433
logic = Logic()