Helpers
create_citation_text(query_doi, creation_timestamp, resource_name, package_title, package_doi=None, publisher=None, html=False)
¶
Creates the citation text for the given query doi and the given additional related arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_doi
|
the query's DOI, this should just be the prefix/suffix, e.g. 10.xxxx/xxxxxx, not the full URL |
required | |
creation_timestamp
|
a datetime object representing the exact moment the DOI was created |
required | |
resource_name
|
the name of the resource the DOI references |
required | |
package_title
|
the title of the package the resource the DOI references is in |
required | |
package_doi
|
the DOI of the package, if there is one (defaults to None) |
None
|
|
publisher
|
the publisher to use in the citation (defaults to None in which case the ckanext.query_dois.publisher config value is used |
None
|
|
html
|
whether to include a tags around URLs in the returned string. Defaults to False which does not add a tags and therefore the returned string is just pure text |
False
|
Returns:
| Type | Description |
|---|---|
|
a citation string for the given query DOI and associated data |
Source code in ckanext/query_dois/helpers.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
create_multisearch_citation_text(query_doi, html=False)
¶
Creates the citation text for a multisearch based DOI and returns it, either as a raw string or as a piece of html, if requested.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_doi
|
a query doi object |
required | |
html
|
whether to return a basic string or a piece of html |
False
|
Returns:
| Type | Description |
|---|---|
|
the citation text |
Source code in ckanext/query_dois/helpers.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
get_doi_count(package_id)
¶
Return the total count of DOIs created against the resources within the given package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package_id
|
str
|
the ID of the package |
required |
Returns:
| Type | Description |
|---|---|
int
|
a number |
Source code in ckanext/query_dois/helpers.py
68 69 70 71 72 73 74 75 76 77 | |
get_landing_page_url(query_doi)
¶
Given a QueryDOI object, return the landing URL for it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_doi
|
a QueryDOI object |
required |
Returns:
| Type | Description |
|---|---|
|
the landing page URL |
Source code in ckanext/query_dois/helpers.py
109 110 111 112 113 114 115 116 117 118 119 | |
get_most_recent_dois(package_id, number)
¶
Retrieve the most recent DOIs that have been minted on queries against the resources in the given package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package_id
|
the package's ID |
required | |
number
|
the number of DOIs to return |
required |
Returns:
| Type | Description |
|---|---|
|
a list of QueryDOI objects |
Source code in ckanext/query_dois/helpers.py
53 54 55 56 57 58 59 60 61 62 63 64 65 | |
get_time_ago_description(query_doi)
¶
Given a QueryDOI object, return a short description of how long ago it was minted. The resolutions are described above in the time_resolutions tuple.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_doi
|
the QueryDOI object |
required |
Returns:
| Type | Description |
|---|---|
|
a unicode string describing how long ago the DOI was minted |
Source code in ckanext/query_dois/helpers.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
pretty_print_query(query)
¶
Does what you'd expect really.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
a query dict |
required |
Returns:
| Type | Description |
|---|---|
|
a string of pretty json |
Source code in ckanext/query_dois/helpers.py
223 224 225 226 227 228 229 230 | |
render_filter_value(field, filter_value)
¶
Renders the given filter value for the given field. This should be called for each filter value rather than by passing a list or filter values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
the field name |
required | |
filter_value
|
the filter value for the field |
required |
Returns:
| Type | Description |
|---|---|
|
the value to display |
Source code in ckanext/query_dois/helpers.py
19 20 21 22 23 24 25 26 27 28 29 30 31 | |