Metadata-Version: 2.4
Name: django-opalstack
Version: 0.1.0
Summary: Django interface to Opalstack python API
Project-URL: Repository, https://github.com/andywar65/django-opalstack
Author-email: andywar65 <andy.war1965@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Andrea Guerra
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Framework :: Django
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Requires-Dist: django>=4.2
Requires-Dist: opalstack
Requires-Dist: requests
Provides-Extra: dev
Requires-Dist: coverage; extra == 'dev'
Requires-Dist: environs[django]; extra == 'dev'
Description-Content-Type: text/x-rst

django-opalstack
================

Django interface to Opalstack python API

What is (((Opalstack?
---------------------

`(((Opalstack.com <https://opalstack.com>`__ is a developer friendly
hosting company. It has a powerful
`API <https://my.opalstack.com/api/v1/doc/>`__ that enables full control
over one's hosting environment. A `python
wrapper <https://github.com/opalstack/opalstack-python>`__ is provided
for the API.

Requirements
------------

This app is tested on Django 5.1 and Python 3.12. It requires the
aforementioned python API and the
`requests <https://requests.readthedocs.io/en/latest/>`__ library.
`HTMX <https://htmx.org>`__ is injected for smooth interactions
(JavaScript must be enabled in your browser).

Installation from PyPI
----------------------

Activate your virtual environment and install with:

::

   python -m pip install django-opalstack

In your Django project add:

.. code:: python

   INSTALLED_APPS = [
       # ...
       "django_opalstack",
   ]

.. code:: python

   # my_project/urls.py
   urlpatterns = [
       # ...
       path("opal/", include("django_opalstack.urls", namespace="django_opalstack")),
   ]

Finally run the following management commands:

::

   python manage.py migrate
   python manage.py collectstatic

Templates
~~~~~~~~~

You also need a ``base.html`` template with following template blocks (a
sample ``base.html`` is provided among package templates).

::

   {% block content %}
   {% endblock content %}
   ...
   {% block extra-js %}
   {% end block extra-js %}

Package comes with several templates in the
``django_opalstack/templates/`` directory. All templates have very few
styles (all inline). If you want to add your own styles, copy the
templates in a new ``my_project/templates/django_opalstack/`` directory
and override them. You will have to set:

.. code:: python

   TEMPLATES = [
       {
           "BACKEND": "django.template.backends.django.DjangoTemplates",
           "DIRS": [BASE_DIR / "my_project/templates"],
           # ...
       },
   ]

Usage
-----

You will need an `(((Opalstack.com <https://opalstack.com>`__ account
(there is a 14-day free trial). Once logged in, obtain a API token from
https://my.opalstack.com/tokens/. Copy the token ``KEY``, then run the
local server and browse to
http://128.1.1.0:8000/admin/django_opalstack/token/add/ and create a new
``Token`` pasting the previously copied ``KEY``. Go to
http://128.1.1.0:8000/opal/token/ and select the newly added token. At
the moment the app is read only, you will have to create ``OS users``,
``Applications`` and ``Sites`` directly on Opalstack.

Tests
-----

Tests with unittest, 99% coverage. Tested for Django 5.1 and Python 3.12
versions.

Changelog
---------

-  0.1.0: First working version (read only)
