Skip to content

Commit

Permalink
Merge branch 'master' into disable_create_button
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos authored Oct 2, 2024
2 parents d8f2f3e + a9e2e7c commit 64570e5
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 41 deletions.
13 changes: 10 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
CHANGELOG
=========

8.9.2+dev (XXXX-XX-XX)
8.10.0 (2024-10-02)
-----------------------

**Bug fixes**
**Breaking changes**

* Compatibility with new django-crispy-forms (2.0.0+)
* New explicit dependency to ``crispy-bootstrap4``.
* You should adapt configuration by adding `crispy_bootstrap4` in your INSTALLED_APPS and check your templates inheritance.

**Improvements**

- Use HTML tag for create/update button
- Due to new crispy forms, there is new login form
- Use HTML `button` tag for create/update forms
- Prevent multiple submissions of create/update form


Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:
convertit:
image: makinacorpus/convertit:latest
Expand Down
1 change: 1 addition & 0 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Add these entries to your ``INSTALLED_APPS``::
'compressor',
'easy_thumbnails',
'crispy_forms',
'crispy_bootstrap4',
'rest_framework',
'embed_video',
'modeltranslation'
Expand Down
2 changes: 1 addition & 1 deletion mapentity/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.9.2+dev
8.10.0
4 changes: 2 additions & 2 deletions mapentity/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.conf import settings as settings_ # import the settings file

from mapentity import __version__
from .registry import registry
from .settings import app_settings

Expand All @@ -12,7 +12,7 @@ def settings(request):
return dict(
TITLE=app_settings['TITLE'],
DEBUG=settings_.DEBUG,
VERSION=getattr(settings_, 'VERSION', 'unknown'),
VERSION=getattr(settings_, 'VERSION', __version__),
JS_SETTINGS_VIEW=app_settings['JS_SETTINGS_VIEW'],
TRANSLATED_LANGUAGES=app_settings['TRANSLATED_LANGUAGES'],
MODELTRANSLATION_LANGUAGES=settings_.MODELTRANSLATION_LANGUAGES,
Expand Down
6 changes: 4 additions & 2 deletions mapentity/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ def __init__(self, div_id, label):

class MapEntityForm(TranslatedModelForm):
fieldslayout = None
geomfields = []
geomfields = None
leftpanel_scrollable = True
hidden_fields = []

def __init__(self, *args, **kwargs):
if self.geomfields is None:
self.geomfields = ['geom']
self.user = kwargs.pop('user', None)
self.can_delete = kwargs.pop('can_delete', True)

Expand Down Expand Up @@ -222,7 +224,7 @@ def _init_layout(self):
formactions = FormActions(
*actions,
css_class="form-actions",
template='mapentity/crispy_forms/bootstrap4/layout/formactions.html'
template='mapentity/crispy_bootstrap4/bootstrap4/layout/formactions.html'
)

# Main form layout
Expand Down
2 changes: 1 addition & 1 deletion mapentity/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}

app_settings = dict({
'TITLE': "",
'TITLE': "Mapentity",
'HISTORY_ITEMS_MAX': 5,
'CONVERSION_SERVER': 'http://convertit/',
'CAPTURE_SERVER': 'http://screamshotter/',
Expand Down
2 changes: 1 addition & 1 deletion mapentity/templates/mapentity/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
data-app-verbosename="{{ app_verbose_name }}"
data-modelname="{{ modelname }}"
data-objectsname="{{ objectsname }}"
data-pk="{{ object.pk }}">
data-pk="{{ object.pk }}" class="{% block body_classes %}{% endblock %}">

{% block content %}
{% block navbar %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div{% if formactions.attrs %} {{ formactions.flat_attrs|safe }}{% endif %} class="form-group">
<div{% if formactions.attrs %} {{ formactions.flat_attrs|safe }}{% endif %} class="{{ formactions.css_class|safe }}">
{{ fields_output|safe }}
</div>
103 changes: 78 additions & 25 deletions mapentity/templates/registration/login.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,87 @@
{% extends "mapentity/base_site.html" %}
{% load i18n crispy_forms_tags mapentity_tags %}

{% load crispy_forms_filters %}
{% load i18n mapentity_tags %}

{% block extrahead %}
<style>
.card {
flex-direction: row;
align-items: center;
}

.card-title {
font-weight: bold;
}

.card img {
width: 30%;
border-top-right-radius: 0;
border-bottom-left-radius: calc(0.25rem - 1px);
}

@media only screen and (max-width: 768px) {
a {
display: none;
}

.card-body {
padding: 0.5em 1.2em;
}

.card-body .card-text {
margin: 0;
}

.card img {
width: 50%;
}
}

@media only screen and (max-width: 1200px) {
.card img {
width: 40%;
}
}
</style>
{% endblock %}

{% block body_classes %}bg-light{% endblock %}

{% block content %}
<div class="container">
{% if messages %}
{% for message in messages %}
<div class="alert {{ message.tags }} alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% endfor %}
{% endif %}
<div class="row justify-content-center">
<div class="col-12 col-sm-8 col-md-6 col-lg-4">
<img src="{% media_static_fallback 'upload/logo-login.png' 'images/logo-login.png' %}" />
<form action="" method="post" class="login-form">
{% csrf_token %}
{{ form|crispy }}
<div class="text-right">
<button type="submit" class="btn btn-primary">{% trans "Login" %}</button>
<div class="container-fluid">
<br>
{% if messages %}
{% for message in messages %}
<div class="alert {{ message.tags }} alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
</form>

<p>Version {{ VERSION }}</p>
{% endfor %}
{% endif %}
<div class="row">
<div class="col-12 col-md-6 offset-md-3">
<div class="card">
<img class="img-rounded p-2"
src="{% media_static_fallback 'upload/logo-login.png' 'images/logo-login.png' %}" alt="logo"/>
<div class="card-body">
<form action="" method="post" class="form-horizontal">
{% csrf_token %}
{{ form|crispy }}
<div class="text-right">
<button type="submit" class="btn btn-success"><i class="bi bi-box-arrow-in-right"></i> {% trans "Login" %}</button>
</div>
</form>
<p class="card-text">
<span class="font-weight-bold">{{ TITLE }}</span> <span class="font-italic">{{ VERSION }}</span>
</p>
</div>
</div>
</div>
</div>

</div>
</div>
{% endblock content %}

{% block extrabody %}
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
'tzdata',
'django-appypod',
'django-compressor',
'django-crispy-forms<2.0',
'django-crispy-forms>=2.0',
'crispy-bootstrap4',
'django-embed-video',
'django-filter',
'django-leaflet>=0.19,<0.20', # leaflet 0.7.x
Expand Down
10 changes: 9 additions & 1 deletion test_app/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from mapentity.forms import MapEntityForm
from test_app.models import Road, DummyModel
from test_app.models import Road, DummyModel, MushroomSpot


class DummyModelForm(MapEntityForm):
Expand All @@ -12,3 +12,11 @@ class RoadForm(MapEntityForm):
class Meta:
model = Road
fields = ("name", "geom")


class MushroomSpotForm(MapEntityForm):
geomfields = []

class Meta:
model = MushroomSpot
fields = "__all__"
14 changes: 12 additions & 2 deletions test_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from mapentity import views as mapentity_views
from .filters import DummyModelFilter
from .forms import DummyModelForm, RoadForm
from .models import DummyModel, Road
from .forms import DummyModelForm, RoadForm, MushroomSpotForm
from .models import DummyModel, Road, MushroomSpot
from .serializers import DummySerializer, RoadSerializer, DummyGeojsonSerializer


Expand Down Expand Up @@ -72,3 +72,13 @@ class RoadViewSet(mapentity_views.MapEntityViewSet):
queryset = Road.objects.all()
serializer_class = RoadSerializer
permission_classes = [DjangoModelPermissionsOrAnonReadOnly]


class MushroomSpotCreate(mapentity_views.MapEntityCreate):
model = MushroomSpot
form_class = MushroomSpotForm


class MushroomSpotUpdate(mapentity_views.MapEntityUpdate):
model = MushroomSpot
form_class = MushroomSpotForm
1 change: 1 addition & 0 deletions test_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
'easy_thumbnails',
'django_filters',
'crispy_forms',
'crispy_bootstrap4',
'rest_framework',
'embed_video',
'tinymce',
Expand Down

0 comments on commit 64570e5

Please sign in to comment.