Working cut of the tags app
Updated 8 months, 1 week ago
| John Peters | Reviewers | ||
| Basie-Dev | |||
| None | Basie SVN | ||
Simple yet functional cut of tagging. You can view all tags in Basie, and view all objects that have a given tag. An inclusion tag can be added to views in other apps to let you view all tags associated with an object, and also lets you add or remove tags from an object. Currently, this patch does NOT but SHOULD support: - performing HTML sanitation on tag names - filtering the list of objects associated with a tag so you only see the ones you're authorized to see If all goes smoothly, I prefer addressing the following in a separate patch: - renaming a tag - displaying a weighted tag cloud
Tests are present for the business logic layer (service layer) and for the controllers (views.py).
Posted 8 months, 3 weeks ago (November 8th, 2009, 12:54 a.m.)
A few specific questions about how Basie does things; want to keep a consistent feel in the tags app.
-
/trunk/apps/tags/templates/tags/object_tags.html (Diff revision 1) -
For each tag displayed, there should be a link for removing that tag from this object. The actual delete should be on a confirmation page with a POST (don't want Google deleting our tags). What's the convention for 'confirm delete' pages in Basie (almost nothing ever gets deleted). Should it be a separate page, or some popup?
-
/trunk/apps/tags/templates/tags/tag_detail.html (Diff revision 1) -
There can easily be a form with one field here for renaming the tag. But does Basie want to keep view and edit pages distinct (looking at tickets seems to say yes). Seems rather silly to have an edit page with just one field.
-
/trunk/apps/tags/urls.py (Diff revision 1) -
Double check URLs to see if they fit Basie's conventions.
Review request changed
Updated 8 months, 3 weeks ago (November 10th, 2009, 3:02 p.m.)
-
- added Diff r2
Fix to the patch - the __init__.py files were not being created, as they had no content (weird, as they still had entries in the patch). Added an empty line to the files. Responding to the conversation on the mailing list: Greg: "does "rename" affect one tag on one object or does renaming the tag affect all uses of that tag? If the former, just let people overtype inline. If the latter, a page that displays all tags with usage counts seems useful...?" The detail view for each tag will display that tag's name, as well as all the objects that use that tag (so yes, the user will be able to see the usage for each tag). The rename operation will affect all usages for that tag. The main tag page currently displays a list of all tags. I could easily display a usage count for each tag on that page, or continue working on a tag cloud. Tag deletion: Milestones uses a popup confirmation dialog, so I'll go that route. django-tagging doesn't have anything like enabled/disabled tags, so all deletions would be permanent. I'd have to extend django-tagging's models if we wanted an 'enabled' field for tags and the tag-object join table - using some type of auditing would be cleaner if we really want this feature.
Review request changed
Updated 8 months, 2 weeks ago (November 13th, 2009, 2:13 a.m.)
-
- added Diff r3
Changes: - created bll.py for the business logic layer (service layer) - is this overkill? - tags can be completely removed. - objects can be untagged. - some permissions have been added. A few more questions: - It will be very difficult to make my unit tests use YAML fixtures. The TaggedItem join table (used to map tags to objects) refers to objects via their primary key AND the primary key of their ContentType. It's easy to create TaggedItem rows programmatically, but hard to do in YAML short of guessing the ContentType primary key. I could hardcode a value in now that would work, but whenever a new model is added to Basie, this would break the tests. Is it fine if I create TaggedItem rows in the setUp() function of my tests, or is there some YAML magic/YAML alternative that I don't know about? - I haven't added permission checking to all my views yet. The problem is that the tagging inclusion tag will be placed in many other templates in Basie. If users lack the TAGS_READ privilege, we don't want to stop them from reading a wiki page (or hide the 'Add Tag' form if they lack the TAGS_ADD privilege, etc.). What's the preferred location for hiding the offending information? Should I check user permissions in my views.py and use different templates depending on how privileged the user is? (And create multiple templates with redundant HTML, violating DRY?) Or should I pass the user object to my templates and have them only display the HTML that the user is allowed to see (and violate MVC)? Either works for me.
Posted 8 months, 2 weeks ago (November 14th, 2009, 1:58 p.m.)
There's some parsing error on templates when the tag name uses <> and/or single quotes.
In template /Users/tony/basie/trunk/apps/tags/templates/tags/object_tags.html, error at line 5
Caught an exception while rendering: Reverse for 'basie.tag-detail' with arguments '(u'dev_project', <Tag: <script>alert('foo');</script>>)' and keyword arguments '{}' not found.
Line 5 being: {% for tag in tags %}
-----------
Tagging with "one two" tags item with two separate tags.
Tagging with "one two, three" thrown AttributeError, Multiple tags were given: "one two".
-----------
Should there be any special clean-up facilities for removing a tag from an object, and having the tag link to absolutely nothing after?
------------
-
/trunk/apps/tags/bll.py (Diff revision 3) -
pep8 "expected 2 blank lines, found 1"
-
/trunk/apps/tags/templates/tags/tag_detail.html (Diff revision 3) -
could this be some sort of a human-readable name, instead of it rendering as "ChatConversation object"
-
/trunk/apps/tags/views.py (Diff revision 3) -
How complicated would it be to cloud~ify the tags?
-
/trunk/apps/tags/views.py (Diff revision 3) -
I don't completely understand the way the permissions work; but judging by some other discussion comments, it seems that lack of a particular READ permission should make items invisible. Wouldn't this by-pass any such READ permissions for associated (tagged) objects?
-
/trunk/apps/tags/views.py (Diff revision 3) -
405 Method Not Allowed http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error
-
/trunk/apps/tags/views.py (Diff revision 3) -
if form.is_valid() && user.has_permission check that the user actually has TAG_WRITE permission... and/or OBJECT_WRITE permission?
-
/trunk/basie/settings.py (Diff revision 3) -
should be this 'django_tagging' to match buildout.cfg's eggs?
Review request changed
Updated 8 months, 2 weeks ago (November 15th, 2009, 12:32 a.m.)
-
- added Diff r4
Thanks a lot for the review, Tony! - permissions (for tagging, at least - see my comments in Tony's review) have been added. - tests for the bll.py and views.py have been added. - responded to most of Tony's review. Sanitizing input for tag names and needing dual permissions for tagging objects (write permission on both tagging and that object) are the show-stoppers for this patch. I'd rather get stuff into SVN before gunning for nice-to-haves like tag clouds (is the feature freeze this Wednesday or Friday?) (The review summary will be updated.)
Review request changed
Updated 8 months, 2 weeks ago (November 15th, 2009, 12:36 a.m.)
-
Test files will be added to the patch once I isolate the ones that just affect these changes.
Tests are present for the business logic layer (service layer) and for the controllers (views.py).
-
Simple yet functional cut of tagging. It doesn't include everything I'm working on locally, but I'm posting the working subset so I can have more eyeballs. You can view all tags in Basie, and view all objects that have a given tag. An inclusion tag can be added to views in other apps to let you view all tags associated with an object, and also adds tags to an object. Currently, this patch does NOT support: - renaming a tag - removing a tag from an object - displaying a weighted tag cloud - filtering the list of objects associated with a tag so you only see the ones you're authorized to see
Simple yet functional cut of tagging. You can view all tags in Basie, and view all objects that have a given tag. An inclusion tag can be added to views in other apps to let you view all tags associated with an object, and also lets you add or remove tags from an object. Currently, this patch does NOT but SHOULD support: - performing HTML sanitation on tag names - filtering the list of objects associated with a tag so you only see the ones you're authorized to see If all goes smoothly, I prefer addressing the following in a separate patch: - renaming a tag - displaying a weighted tag cloud
Posted 8 months, 2 weeks ago (November 17th, 2009, 2:29 p.m.)
So with the above mentioned show-stoppers, are there more changes coming to this patch? Or should we just review again as-is, and commit with #TODO comments?
Review request changed
Updated 8 months, 1 week ago (November 18th, 2009, 2:05 a.m.)
-
- added Diff r5
Here's a minor change - tagging/untagging an object now requires change permission for that object, as well as add/remove permissions for tagging. I'd prefer addressing the other concerns in separate, smaller review requests. Special characters in tag names is the only thing that breaks this patch, but to fix it The Right Way would require changing AddTagForm. These changes would be easiest to do if adding a tag was also an AJAX operation, and I think that should be part of another ticket.
