A modification of the twitter app mixins from Mezzanine with additional functionality such as support for images.
- New mixin that supports an additional checkbox for indicating if an image should be tweeted along with the text
- New mixin for ModelAdmins to support tweeting as an admin action, versus 'tweet on save'
- Add mezzanine_twitterplus to your virtualenv or clone the repository:
pip install git+git://github.com/dfraser/mezzanine-twitterplus.git
- Add "twitterplus" to INSTALLED_APPS:
INSTALLED_APPS = (
"...",
"twitterplus",
)
TweetImageAdminMixin is a mixin, based on Mezzanine's TweetableAdminMixin, that adds support for tweeting an image along with the tweet's text -- only upon saving of the object.
It can be configured to either support 'tweet with optional image' or 'tweet, always with image'.
- Modify FORMFIELD_HTML as necessary
- Add the mixin as follows to classes that support tweeting (drop in replacement for TweetableAdminMixin)
class ObjectAdmin(TweetImageAdminMixin, ...)
- Add or modify the parent class init() to insert init parameters for TweetImageAdminMixin to override default settings (display both checkboxes, image field name is 'image', text to tweet is str(obj))
def __init__(self, *args, *kwargs):
kwargs['text_or_image'] = False
kwargs['tweet_image_field'] = 'tweeted_image'
kwargs['tweet_field'] = 'tweet'
super(Class, self).__init__(*args, **kwargs)
TweetAction is a mixin for ModelAdmins that adds support for tweeting thru the action menu. This is an alternative to TweetableAdminMixin / TweetImageAdminMixin that facilitates tweeting something repeatedly.
The assumption is that a mass tweeting involves tweeting existing data, e.g. the tweet attribute of an object and any existing image. If a choice as to what is tweeted should be made at tweet time, then a custom form + the action should be implemented
- Add the mixin as follows to classes that support tweeting (drop in replacement for TweetableAdminMixin)
class ObjectAdmin(TweetAction, models.ModelAdmin)
- Add or modify the parent class init() to insert init parameters for TweetAction to override default settings (image field name is None (no image present to be tweeted), text to tweet is str(obj))
def __init__(self, *args, *kwargs):
kwargs['tweet_image_field'] = 'tweeted_image'
kwargs['tweet_field'] = 'tweet'
super(Class, self).__init__(*args, **kwargs)
- Upgrade to use new Twitter API
- Verify 3.3 compatability