Helpers
TwitterJSHelpers
¶
A class defining various methods to pass into the templates as helpers.
Source code in ckanext/twitter/lib/helpers.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
get_tweet(package_id)
¶
Generates the tweet text for the given package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package_id |
The package ID. |
required |
Returns:
| Type | Description |
|---|---|
|
str |
Source code in ckanext/twitter/lib/helpers.py
50 51 52 53 54 55 56 57 | |
tweet_ready(package_id)
¶
Checks the session to see if the package has been marked as ready for tweeting via the update hook. Removes the 'twitter_is_suitable' key from the session if present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package_id |
The package ID. |
required |
Returns:
| Type | Description |
|---|---|
|
boolean |
Source code in ckanext/twitter/lib/helpers.py
38 39 40 41 42 43 44 45 46 47 48 | |
twitter_pkg_suitable(context, pkg_id, pkg_dict=None)
¶
Various tests to determine if a package is suitable for tweeting about, e.g. it's active & has resources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context |
The current context. |
required | |
pkg_id |
The package ID. |
required | |
pkg_dict |
Optionally provided instead of pkg_id to avoid requesting from the API. Not recommended - provided as a test helper. |
None
|
Returns:
| Type | Description |
|---|---|
|
boolean |
Source code in ckanext/twitter/lib/helpers.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |