Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/bs5 #314

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docker/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ RUN apt-get update && \
nano \
chromium \
graphviz \
libpq-dev \
python3.9
libpq-dev
# python3.9

RUN pip install pip --upgrade
RUN pip install virtualenv
Expand Down
1 change: 1 addition & 0 deletions examples/mezzanine_example/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# Mapping.
fobi_theme_home_template_mapping = {
"bootstrap3": "home/bootstrap3.html",
"bootstrap5": "home/bootstrap5.html",
"foundation5": "home/foundation5.html",
"simple": "home/simple.html",
}
Expand Down
8 changes: 6 additions & 2 deletions examples/simple/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def gettext(s):
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

DEBUG = False
DEBUG_TOOLBAR = False
DEBUG = True
DEBUG_TOOLBAR = True
DEV = False

ADMINS = (
Expand Down Expand Up @@ -311,6 +311,10 @@ def gettext(s):
# ***********************************************************************
"fobi.contrib.themes.simple", # Simple theme
# ***********************************************************************
# ************************* Bootstrap 5 theme ***************************
# ***********************************************************************
"fobi.contrib.themes.bootstrap5", # Bootstrap 5 theme
# ***********************************************************************
# ***********************************************************************
# ************************* Fobi form importers *************************
# ***********************************************************************
Expand Down
18 changes: 18 additions & 0 deletions examples/simple/settings/bootstrap5_theme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from .base import *

INSTALLED_APPS = list(INSTALLED_APPS)

try:
INSTALLED_APPS.remove(
"admin_tools"
) if "admin_tools" in INSTALLED_APPS else None
INSTALLED_APPS.remove(
"admin_tools.menu"
) if "admin_tools.menu" in INSTALLED_APPS else None
INSTALLED_APPS.remove(
"admin_tools.dashboard"
) if "admin_tools.dashboard" in INSTALLED_APPS else None
except Exception as err:
pass

FOBI_DEFAULT_THEME = "bootstrap5"
16 changes: 14 additions & 2 deletions examples/simple/settings/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from .bootstrap3_theme import *

from .bootstrap5_theme import *


def project_dir(base):
return os.path.abspath(
Expand All @@ -16,7 +18,7 @@ def gettext(s):

PROJECT_DIR = project_dir
DEBUG = True
DEBUG_TOOLBAR = False
DEBUG_TOOLBAR = True
DEBUG_TEMPLATE = True
# TEMPLATE_DEBUG = True
DEV = True
Expand Down Expand Up @@ -57,7 +59,17 @@ def gettext(s):
"page": "page.migrations",
}

INTERNAL_IPS = ("127.0.0.1",)
INTERNAL_IPS = ["127.0.0.1",]
if DEBUG:
# A better way to get the IP address?
# import subprocess
# cmd = ['hostname', '-I']
# result = subprocess.run(cmd, capture_output=True, text=True)
# return result.stdout.strip()
import socket # only if you haven't already imported this
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + ["127.0.0.1", "10.0.2.2", "10.89.0.3"]

ALLOWED_HOSTS = ["*"]

EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
Expand Down
67 changes: 67 additions & 0 deletions examples/simple/templates/home/bootstrap5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{% extends "home/base.html" %}

{% load i18n static %}

{% block page-title %}{% trans 'Home' %}{% endblock %}
{% block site-title %}{% trans "django-fobi example site" %}{% endblock site-title %}

{% block navbar-menu %}
{% endblock navbar-menu %}

{% block main-content-wrapper %}
<div class="bg-light border rounded p-1 ps-3 pe-3 mb-3">
<div class="container">
<h1>django-fobi</h1>
{% blocktrans %}
<p>
Welcome to `django-fobi` (later on named just `Fobi`) - a customisable, modular, developer-friendly form
builder application for Django. With `Fobi` you can build Django forms using a user-friendly GUI,
save or mail posted form data. Developer-friendly API allows you to build your own form elements
and form handlers (mechanisms for handling the submitted form data).
</p>
{% endblocktrans %}
<p><a href="http://pythonhosted.org/django-fobi/#screenshots" class="btn btn-primary btn-lg" role="button">{% trans "Learn more" %}</a></p>
</div>
</div>

<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="col-md-4">
<h2>{% trans "Dashboard" %}</h2>
{% url 'fobi.dashboard' as fobi_dashboard_url %}
{% blocktrans with fobi_dashboard_url as dashboard_url %}
<p>The `Fobi` dashboard, where you can see all the forms you have created, edit them (add/remove elements,
form handlers), create new forms as well as remove existing ones.</p>
<p><a class="btn btn-outline-primary" href="{{ dashboard_url }}" role="button">Go to dashboard &raquo;</a></p>
{% endblocktrans %}
</div>
<div class="col-md-4">
<h2>{% trans "Create a form" %}</h2>
{% url 'fobi.create_form_entry' as fobi_create_form_entry_url %}
{% blocktrans with fobi_create_form_entry_url as create_form_entry_url %}
<p>Create your first form using awesome user-friendly GUI. Choose what to do with the posted data.</p>
<p><a class="btn btn-outline-primary" href="{{ create_form_entry_url }}" role="button">Create form &raquo;</a></p>
{% endblocktrans %}
</div>
<div class="col-md-4">
<h2>{% trans "See the admin part" %}</h2>
{% url 'admin:index' as fobi_admin_url %}
{% blocktrans with fobi_admin_url as admin_url %}
<p>See the Django-admin for saved data, as well as choose who to grant with permissions of using
one or another `Fobi` plugin (form element or form handler).</p>
<p><a class="btn btn-outline-primary" href="{{ admin_url }}" role="button">Go to admin &raquo;</a></p>
{% endblocktrans %}
</div>
</div>

<hr>

<footer>
<p>{{ fobi_theme.footer_text|safe }}</p>
</footer>
</div> <!-- /container -->
{% endblock main-content-wrapper %}

{% block sidebar-wrapper %}
{% endblock sidebar-wrapper %}
1 change: 1 addition & 0 deletions examples/simple/urls/class_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Mapping.
fobi_theme_home_template_mapping = {
"bootstrap3": "home/bootstrap3.html",
"bootstrap5": "home/bootstrap5.html",
"foundation5": "home/foundation5.html",
"simple": "home/simple.html",
}
Expand Down
1 change: 1 addition & 0 deletions examples/simple/urls/function_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Mapping.
fobi_theme_home_template_mapping = {
"bootstrap3": "home/bootstrap3.html",
"bootstrap5": "home/bootstrap5.html",
"foundation5": "home/foundation5.html",
"simple": "home/simple.html",
}
Expand Down
1 change: 1 addition & 0 deletions examples/tutorial/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# Mapping.
fobi_theme_home_template_mapping = {
"bootstrap3": "home/bootstrap3.html",
"bootstrap5": "home/bootstrap5.html",
"foundation5": "home/foundation5.html",
}

Expand Down
22 changes: 22 additions & 0 deletions src/fobi/contrib/themes/bootstrap5/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
fobi.contrib.themes.bootstrap5
------------------------------
A ``django-fobi`` Bootstrap 5 theme.

Installation
~~~~~~~~~~~~
(1) Add ``fobi.contrib.themes.bootstrap5`` to the
``INSTALLED_APPS`` in your ``settings.py``.

.. code-block:: python

INSTALLED_APPS = (
# ...
'fobi.contrib.themes.bootstrap5',
# ...
)

(2) Specify ``bootstrap5`` as a default theme in your ``settings.py``:

.. code-block:: python

FOBI_DEFAULT_THEME = 'bootstrap5'
10 changes: 10 additions & 0 deletions src/fobi/contrib/themes/bootstrap5/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
__title__ = "fobi.contrib.themes.bootstrap5"
__license__ = "GPL 2.0/LGPL 2.1"
__all__ = (
"default_app_config",
"UID",
)

default_app_config = "fobi.contrib.themes.bootstrap5.apps.Config"

UID = "bootstrap5"
12 changes: 12 additions & 0 deletions src/fobi/contrib/themes/bootstrap5/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.apps import AppConfig

__title__ = "fobi.contrib.themes.bootstrap3.apps"
__license__ = "GPL 2.0/LGPL 2.1"
__all__ = ("Config",)


class Config(AppConfig):
"""Config."""

name = "fobi.contrib.themes.bootstrap5"
label = "fobi_contrib_themes_bootstrap5"
Loading