Skip to content

Instantly share code, notes, and snippets.

@gsathya
Created March 24, 2012 13:46
Show Gist options
  • Save gsathya/2183060 to your computer and use it in GitHub Desktop.
Save gsathya/2183060 to your computer and use it in GitHub Desktop.
From 6a11e821214616994e6eff5da7451eeccd58496b Mon Sep 17 00:00:00 2001
From: Sathyanarayanan Gunasekaran <[email protected]>
Date: Sat, 24 Mar 2012 11:20:04 +0530
Subject: [PATCH] Add keywords to tasks
Support associating keywords (text strings) with tasks
---
modules/eden/cms.py | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/modules/eden/cms.py b/modules/eden/cms.py
index 2ff64b2..430456e 100644
--- a/modules/eden/cms.py
+++ b/modules/eden/cms.py
@@ -45,6 +45,8 @@ class S3ContentModel(S3Model):
names = ["cms_series",
"cms_post",
"cms_comment",
+ "cms_keywords",
+ "cms_resource_keywords"
]
def model(self):
@@ -238,6 +240,46 @@ class S3ContentModel(S3Model):
# ---------------------------------------------------------------------
# Pass variables back to global scope (response.s3.*)
#
+
+
+ # ---------------------------------------------------------------------
+ # Tags
+
+ tablename = "cms_tags"
+ table = define_table(tablename,
+ Field("tag", "text",
+ notnull=True,)
+ *meta_fields())
+
+ # Resource Configuration
+ configure(tablename,
+ list_fields=["id",
+ "tag",
+ ])
+
+ # ---------------------------------------------------------------------
+ # Tag Resource - Used to tag a tag to a resource
+
+ tablename = "cms_resource_tag"
+ table = self.define_table(tablename,
+ Field("tag_id", "reference cms_tag",
+ requires = IS_ONE_OF(db,"cms_tag.id")),
+ Field("resource",
+ represent = lambda opt: \
+ resource_opts.get(s3.crud_strings[opt._tablename].name_nice, opt),
+ label=T("Resource")),
+ Field("record_uuid",
+ type=s3uuid,
+ length=128),
+ *s3.meta_fields())
+
+ self.configure(tablename,
+ list_fields=[ "id",
+ "tag_id",
+ "record_uuid",
+ "resource",
+ ])
+
return Storage()
# -------------------------------------------------------------------------
--
1.7.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment