Themes REST interface

RESTful API for the Theme

Theme is a look and feel that can be applied to Portal. All theme’s resources are limited to only those users that have the ‘themes’ or superuser permissions. Response Formats: JSON

Resource GET /API/v1/theme/%id/

Response Formats:
JSON
Resource URL:
/API/v1/theme/%id/
Schema URL:
/API/v1/theme/schema/
Permission Required:
theme

Parameters for Theme Item

Name Description Example
id (Integer) GUID for Theme object 12
title (String) Name for the theme ‘dark theme’
template_string (String - optional) Actual template that can be called when rendering the page ‘ ‘
css (URL - optional) CSS file location “/sitemedia/css /dark-theme.css”
javascript (URL - optional) Javascript location “/sitemedia/js/ dark-theme.js”
status (Choice) Status of the theme if it shouldn’t be made live yet. 1 - EDITING 2 - PENDING 3 - APPROVED 4 - HIDDEN
logoimage (File - optional) Filepath a image that will be served for the theme
/opt/cantemo/p

ortal/portal_med ia/img/logo/ mylogo.png

is_default (Bool) This is the default theme for the site false

Example response:

{
    "css": "/sitemedia/css/portal-core.css",
    "id": "3",
    "is_default": false,
    "javascript": "",
    "logoimage": "/sitemedia/img/Cantemo-logo.png",
    "resource_uri": "/API/v1/theme/3/",
    "status": 2,
    "template_string": "{% themeextends "base.html" %}{% block title %}
                        {% endblock %} {% block theme %}
                        {% block navigation %}
                        {% themeinclude 'includes/navigation.html' %}
                        {% endblock %} <div id="main">{% block body %}
                        {% block heading %} {% endblock heading %}
                        <div id="content"> {% block content %}
                        {% endblock content %} </div>{% endblock body %}
                        </div>{% block footer %} 
                        {% themeinclude 'includes/footer.html' %}
                        {% endblock %}{% endblock %}",
    "title": "core"
}

Resource GET /API/v1/theme/

Returns a list of theme items for the user the current authenticated user.

Response Formats:
JSON
Resource URL:
/API/v1/theme/
Schema URL:
/API/v1/theme/schema/
Permission Required:
theme

Parameters for meta

Name Description Example
limit (Integer) Usual offset limit for pagination 20
next (URI) Next null
offset (Integer) First item on the page 20
previous (URI) Next null
total (Integer) Total amount of items in the Theme for this user 20
  • Parameters for objects *

Objects is a list of Theme Items.

Example response:

{
    "css": "/sitemedia/css/portal-core.css",
    "id": "3",
    "is_default": false,
    "javascript": "",
    "logoimage": "/sitemedia/img/Cantemo-logo.png",
    "resource_uri": "/API/v1/theme/3/",
    "status": 2,
    "template_string": "{% themeextends "base.html" %}{% block title %}
                        {% endblock %}
                        {% block theme %} {% block navigation %}
                        {% themeinclude 'includes/navigation.html' %}
                        {% endblock %}
                        <div id="main">{% block body %}
                        {% block heading %}
                        {% endblock heading %} <div id="content">
                        {% block content %}
                        {% endblock content %} </div>{% endblock body %}
                        </div>{% block footer %}
                        {% themeinclude 'includes/footer.html' %}
                        {% endblock %}{% endblock %}",
    "title": "core"
}

Resource POST /API/v1/theme/

When wanting to add a theme for the current user.

Example payload:

{
    "css": "/sitemedia/css/portal-core.css",
    "is_default": false,
    "javascript": "",
    "logoimage": "/sitemedia/img/Cantemo-logo.png",
    "status": 2,
    "template_string": "{% themeextends "base.html" %}{% block title %}
                        {% endblock %}
                        {% block theme %} {% block navigation %}
                        {% themeinclude 'includes/navigation.html' %}
                        {% endblock %}<div id="main">{% block body %}
                        {% block heading %}{% endblock heading %} 
                        <div id="content">
                        {% block content %} {% endblock content %}
                        </div>{% endblock body %}
                        </div>{% block footer %}
                        {% themeinclude 'includes/footer.html' %}
                        {% endblock %}{% endblock %}",
    "title": "core"
}

Example response (Status Code 200):

{
    "css": "/sitemedia/css/portal-core.css",
    "id": "3",
    "is_default": false,
    "javascript": "",
    "logoimage": "/sitemedia/img/Cantemo-logo.png",
    "resource_uri": "/API/v1/theme/3/",
    "status": 2,
    "template_string": "{% themeextends "base.html" %}
                        {% block title %} {% endblock %}{% block theme %}
                        {% block navigation %}
                        {% themeinclude 'includes/navigation.html' %}
                        {% endblock %}<div id="main">{% block body %}
                        {% block heading %}{% endblock heading %}
                        <div id="content">        {% block content %}
                        {% endblock content %}    </div>
                        {% endblock body %}</div>{% block footer %}
                        {% themeinclude 'includes/footer.html' %}
                        {% endblock %}{% endblock %}",
    "title": "core"
}
class portal.themes.api.ThemeResource(api_name=None)
authorized_read_list(object_list, bundle)

Limit this to users with the theme or superuser privilege…

post_list(request, **kwargs)

Custom method to return what has been created from the POST response