equal
deleted
inserted
replaced
41 |
41 |
42 class TaskTag(Tag): |
42 class TaskTag(Tag): |
43 """Model for storing all Task tags. |
43 """Model for storing all Task tags. |
44 """ |
44 """ |
45 |
45 |
46 #: Each task_type tag is scoped under the program. |
46 #: Each task_type tag is scoped under the program. |
47 scope = db.ReferenceProperty(reference_class=soc.models.linkable.Linkable, |
|
48 required=True, |
|
49 collection_name='task_type_tags') |
|
50 |
47 |
51 order = db.IntegerProperty(required=True, default=0) |
48 order = db.IntegerProperty(required=True, default=0) |
52 |
49 |
53 @classmethod |
50 @classmethod |
54 def __key_name(cls, scope_path, tag_name): |
51 def __key_name(cls, scope_path, tag_name): |
145 |
142 |
146 @classmethod |
143 @classmethod |
147 def get_or_create(cls, scope, tag_name, order=0): |
144 def get_or_create(cls, scope, tag_name, order=0): |
148 """Get the Tag object that has the tag value given by tag_value. |
145 """Get the Tag object that has the tag value given by tag_value. |
149 """ |
146 """ |
|
147 |
|
148 if not scope: |
|
149 return None |
|
150 |
150 tag_key_name = cls.__key_name(scope.key().name(), tag_name) |
151 tag_key_name = cls.__key_name(scope.key().name(), tag_name) |
151 existing_tag = cls.get_by_key_name(tag_key_name) |
152 existing_tag = cls.get_by_key_name(tag_key_name) |
152 if existing_tag is None: |
153 if existing_tag is None: |
153 # the tag does not yet exist, so create it. |
154 # the tag does not yet exist, so create it. |
154 if not order: |
155 if not order: |