app/soc/modules/ghop/logic/models/task.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Fri, 28 Aug 2009 12:34:16 +0200
changeset 2823 21c222535654
parent 2407 e23fce20ad3a
child 2831 a7ed56911653
permissions -rw-r--r--
Added several methods to the Task Logic module. These include the automatic tranistion methods. The methods for running updates , that for instance place comments, in a datastore transition to keep the Task synced with the comments. And a rudimentary way of updating the Tasks' history. Reviewed by: Lennard de Rijk
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 = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    42
    'Claimed': transitFromClaimed,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    43
    'NeedsReview': transitFromNeedsReview,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    44
    'ActionNeeded': transitFromActionNeeded,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
    45
    'NeedsWork': transitFromNeedsWork,
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
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   144
      # call the base logic method to store the updated Task entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   145
      return super(Logic, self).updateEntityProperties(
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   146
          entity, entity_properties, siltent=silent, store=store)
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
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   163
    from soc.modules.ghop.logic.models import comment as ghop_comment_logic
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   164
    from soc.modules.ghop.logic.models import work_submission as \
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   165
        ghop_work_submission_logic
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   166
    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
   167
    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
   168
        ghop_work_submission_model
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   169
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   170
    if entity_properties:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   171
      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
   172
                                           silent=silent, store=False)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   173
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   174
    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
   175
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   176
    ws_entity = None
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   177
    if ws_properties:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   178
      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
   179
          **ws_properties)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   180
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   181
    def comment_create():
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   182
      """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
   183
      WorkSubmission.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   184
      """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   185
      entity.put()
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   186
      if ws_entity:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   187
        ws_entity.put()
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   188
        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
   189
            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
   190
        comment_entity.put()
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   191
        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
   192
      else:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   193
        comment_entity.put()
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   194
        return entity, comment_entity, None
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   195
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   196
    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
   197
        comment_create)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   198
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   199
    if not silent:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   200
      # 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
   201
      if comment_entity:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   202
        ghop_comment_logic.logic._onCreate(comment_entity)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   203
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   204
      if ws_entity:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   205
        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
   206
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   207
    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
   208
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   209
  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
   210
    """See base.Logic.updateOrCreateFromFields().
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   211
    """
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
    # 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
   214
    if properties['status'] == 'Open':
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   215
      history = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   216
          'title': properties['title'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   217
          'description': properties['description'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   218
          'difficulty': properties['difficulty']['tags'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   219
          'task_type': properties['type_tags'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   220
          '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
   221
          '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
   222
          'user': '',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   223
          'student': '',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   224
          'status': properties['status'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   225
          'deadline': '',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   226
          '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
   227
          '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
   228
          }
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
      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
   231
        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
   232
        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
   233
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   234
      # 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
   235
      # 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
   236
      # a JSON string.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   237
      task_history_str = simplejson.dumps({
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   238
          str(datetime.datetime.now()): history,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   239
          })
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
      # 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
   242
      history_property = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   243
          'history': task_history_str
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   244
          }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   245
      properties.update(history_property)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   246
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   247
    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
   248
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   249
    if entity:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   250
      if properties.get('task_type'):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   251
        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
   252
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   253
      if properties.get('difficulty'):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   254
        setattr(entity, 'difficulty', properties['difficulty'])
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   255
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   256
    return entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   257
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   258
  def getFromKeyFieldsWithCWSOr404(self, fields):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   259
    """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
   260
    specified by the fields argument.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   261
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   262
    For args see base.getFromKeyFieldsOr404().
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   263
    """
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
    from soc.modules.ghop.logic.models import comment as ghop_comment_logic
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   266
    from soc.modules.ghop.logic.models import work_submission as \
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   267
        ghop_work_submission_logic
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   268
 
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   269
    entity = self.getFromKeyFieldsOr404(fields)
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
    comment_entities = ghop_comment_logic.logic.getForFields(
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   272
        ancestors=[entity], order=['created_on'])
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   273
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   274
    ws_entities = ghop_work_submission_logic.logic.getForFields(
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   275
        ancestors=[entity], order=['submitted_on'])
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   276
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   277
    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
   278
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   279
  def updateTaskStatus(self, entity):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   280
    """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
   281
    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
   282
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   283
    Args:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   284
      entity: The GHOPTask entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   285
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   286
    Returns:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   287
      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
   288
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   289
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   290
    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
   291
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   292
    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
   293
      # 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
   294
      # task's current state
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   295
      transit_func = STATE_TRANSITIONS[entity.status]
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   296
      update_dict = transit_func(entity)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   297
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   298
      comment_properties = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   299
          'parent': entity,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   300
          'scope_path': entity.key().name(),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   301
          'created_by': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   302
          'content': update_dict['content'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   303
          'changes': update_dict['changes'],
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   304
          }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   305
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   306
      entity, comment_entity, _ = self.updateEntityPropertiesWithCWS(
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   307
          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
   308
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   309
      if entity.deadline:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   310
        # 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
   311
        task_update.spawnUpdateTask(entity)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   312
    else:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   313
      comment_entity=None
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   314
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   315
    return entity, comment_entity
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
  def transitFromClaimed(self, entity):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   318
    """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
   319
    to a relevant state.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   320
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   321
    Args:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   322
      entity: The GHOPTask entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   323
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   324
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   325
    # 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
   326
    deadline = entity.deadline + datetime.timedelta(
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   327
        hours=24)
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   328
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   329
    properties = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   330
        'status': 'ActionNeeded',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   331
        'deadline': deadline,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   332
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   333
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   334
    changes = [ugettext('User-MelangeAutomatic'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   335
               ugettext('Action-Warned for action'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   336
               ugettext('Status-%s' % (properties['status']))]
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   337
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   338
    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
   339
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   340
    update_dict = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   341
        'properties': properties,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   342
        'changes': changes,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   343
        'content': content,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   344
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   345
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   346
    return update_dict
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
  def transitFromNeedsReview(self, entity):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   349
    """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
   350
    to a relevant state.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   351
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   352
    Args:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   353
      entity: The GHOPTask entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   354
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   355
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   356
    properties = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   357
        'deadline': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   358
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   359
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   360
    changes = [ugettext('User-MelangeAutomatic'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   361
               ugettext('Action-Deadline passed'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   362
               ugettext('Status-%s' % (entity.status))]
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   363
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   364
    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
   365
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   366
    update_dict = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   367
        'properties': properties,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   368
        'changes': changes,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   369
        'content': content,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   370
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   371
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   372
    return update_dict
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
  def transitFromActionNeeded(self, entity):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   375
    """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
   376
    to a relevant state.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   377
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   378
    Args:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   379
      entity: The GHOPTask entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   380
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   381
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   382
    properties = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   383
        'user': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   384
        'student': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   385
        'status': 'Reopened',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   386
        'deadline': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   387
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   388
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   389
    changes = [ugettext('User-MelangeAutomatic'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   390
               ugettext('Action-Forcibly reopened'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   391
               ugettext('Status-Reopened')]
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   392
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   393
    content = self.DEF_REOPENED_MSG
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
    update_dict = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   396
        'properties': properties,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   397
        'changes': changes,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   398
        'content': content,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   399
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   400
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   401
    return update_dict
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
  def transitFromNeedsWork(self, entity):
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   404
    """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
   405
    to a relevant state.
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   406
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   407
    Args:
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   408
      entity: The GHOPTask entity
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   409
    """
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   410
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   411
    properties = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   412
        'user': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   413
        'student': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   414
        'status': 'Reopened',
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   415
        'deadline': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   416
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   417
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   418
    changes = [ugettext('User-MelangeAutomatic'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   419
               ugettext('Action-Forcibly reopened'),
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   420
               ugettext('Status-Reopened')]
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   421
    
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   422
    update_dict = {
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   423
        'properties': properties,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   424
        'changes': changes,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   425
        'content': None,
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   426
        }
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   427
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   428
    return update_dict
21c222535654 Added several methods to the Task Logic module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2407
diff changeset
   429
2401
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
   430
bf70c5a0ef66 Added logic for every GHOP specific model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
   431
logic = Logic()