equal
deleted
inserted
replaced
17 """GHOPTask (Model) query functions. |
17 """GHOPTask (Model) query functions. |
18 """ |
18 """ |
19 |
19 |
20 __authors__ = [ |
20 __authors__ = [ |
21 '"Madhusudan.C.S" <madhusudancs@gmail.com>', |
21 '"Madhusudan.C.S" <madhusudancs@gmail.com>', |
|
22 '"Daniel Hans" <daniel.m.hans@gmail.com>', |
22 '"Lennard de Rijk" <ljvderijk@gmail.com>', |
23 '"Lennard de Rijk" <ljvderijk@gmail.com>', |
23 ] |
24 ] |
24 |
25 |
25 |
26 |
26 import datetime |
27 import datetime |
29 |
30 |
30 from django.utils import simplejson |
31 from django.utils import simplejson |
31 from django.utils.translation import ugettext |
32 from django.utils.translation import ugettext |
32 |
33 |
33 from soc.logic.models import base |
34 from soc.logic.models import base |
|
35 from soc.logic import tags |
|
36 |
|
37 from soc.modules.ghop.logic.models import comment as ghop_comment_logic |
34 |
38 |
35 import soc.models.linkable |
39 import soc.models.linkable |
36 |
40 |
37 import soc.modules.ghop.logic.models.organization |
41 import soc.modules.ghop.logic.models.organization |
38 import soc.modules.ghop.models.task |
42 import soc.modules.ghop.models.task |
43 'NeedsReview': 'transitFromNeedsReview', |
47 'NeedsReview': 'transitFromNeedsReview', |
44 'ActionNeeded': 'transitFromActionNeeded', |
48 'ActionNeeded': 'transitFromActionNeeded', |
45 'NeedsWork': 'transitFromNeedsWork', |
49 'NeedsWork': 'transitFromNeedsWork', |
46 } |
50 } |
47 |
51 |
|
52 TAG_NAMES = ['arbit_tag', 'difficulty', 'task_type'] |
48 |
53 |
49 class Logic(base.Logic): |
54 class Logic(base.Logic): |
50 """Logic methods for the GHOPTask model. |
55 """Logic methods for the GHOPTask model. |
51 """ |
56 """ |
52 |
57 |
67 def __init__(self, model=soc.modules.ghop.models.task.GHOPTask, |
72 def __init__(self, model=soc.modules.ghop.models.task.GHOPTask, |
68 base_model=soc.models.linkable.Linkable, |
73 base_model=soc.models.linkable.Linkable, |
69 scope_logic=soc.modules.ghop.logic.models.organization): |
74 scope_logic=soc.modules.ghop.logic.models.organization): |
70 """Defines the name, key_name and model for this entity. |
75 """Defines the name, key_name and model for this entity. |
71 """ |
76 """ |
|
77 |
|
78 self.tags_service = tags.TagsService(TAG_NAMES) |
72 |
79 |
73 super(Logic, self).__init__(model, base_model=base_model, |
80 super(Logic, self).__init__(model, base_model=base_model, |
74 scope_logic=scope_logic) |
81 scope_logic=scope_logic) |
75 |
82 |
76 def updateEntityProperties(self, entity, entity_properties, |
83 def updateEntityProperties(self, entity, entity_properties, |
429 'content': None, |
436 'content': None, |
430 } |
437 } |
431 |
438 |
432 return update_dict |
439 return update_dict |
433 |
440 |
|
441 def delete(self, entity): |
|
442 """Delete existing entity from datastore. |
|
443 """ |
|
444 |
|
445 def task_delete_txn(entity): |
|
446 """Performs all necessary operations in a single transaction when a task |
|
447 is deleted. |
|
448 """ |
|
449 |
|
450 to_delete = [] |
|
451 to_delete += ghop_comment_logic.logic.getForFields(ancestors=[entity]) |
|
452 to_delete += [entity] |
|
453 |
|
454 db.delete(to_delete) |
|
455 |
|
456 self.tags_service.removeAllTagsForEntity(entity) |
|
457 db.run_in_transaction(task_delete_txn, entity) |
|
458 |
434 |
459 |
435 logic = Logic() |
460 logic = Logic() |