Installation & Usage
See also the main dalec repository for more information.
Python & django setup
Install the package or set it in your requirement:
pip install dalec_gitlab
In django settings INSTALLED_APPS, add:
INSTALLED_APPS = [
...
"dalec",
"dalec_prime",
"dalec_gitlab",
...
]
Run django-admin makemigrations and django-admin migrate if this is the first dalec plugin installed.
Add also in your settings the gitlab server URL and token:
DALEC_GITLAB_BASE_URL = "https://gitlab.com/"
DALEC_GITLAB_API_TOKEN = "azeazeaezdfqsmlkrjzr"
Usage
General usage: in a template
{% load dalec %}
{% dalec "gitlab" content_type [channel=None] [channel_object=None] [channel_objects=None] [template=None] [ordered_by=None] %}
where content_type can be: issue, event or milestone.
Extending the default templates
Default templates are rather simplistic (see examples). But you can easily create your own template, like every other dalec:
list (don’t forget to extend
dalec/default/list.html):dalec/gitlab/issue-list.htmldalec/gitlab/event-list.htmldalec/gitlab/milestone-list.html
item (don’t forget to extend
dalec/default/item.html):dalec/gitlab/issue-item.htmldalec/gitlab/event-item.htmldalec/gitlab/milestone-item.html
It should be straightforward to create your own (see Content data for available data). Here for instance the default one for issue:
Issue list : simply redifine the block dalec_list_items
{% extends "dalec/default/list.html" %}
{% load i18n %}
{% block dalec_list_items %}
<table>
<thead>
<tr>
<th>{% trans "Title" %}</th>
<th>{% trans "Project" %}</th>
<th>{% trans "Assignee" %}</th>
<th>{% trans "Created at" %}</th>
</tr>
</thead>
<tbody>
{% for object in object_list %}
{% include item_template %}
{% endfor %}
</tbody>
</table>
{% endblock dalec_list_items %}
Issue item : simply load {% load dalec %} (if needed, for instance for the |to_datetime filter) and redifine the block item_content
{% extends "dalec/default/item.html" %}
{% load dalec %}
{% block item_content %}
<tr>
<td class="gitlab issue title">
<a href="{{ object.content_data.web_url }}">
<code>{{ object.content_data.references.relative }}</code>
</a>
</td>
<td class="gitlab issue project">{{ object.content_data.project.name }}</td>
<td class="gitlab issue assignee">{{ object.content_data.assignee.name }}</td>
<td class="gitlab issue created_at">{{ object.creation_dt|date:"DATE_FORMAT" }}</td>
</tr>
{% endblock %}