Skip to content

Commit

Permalink
Update documentation and minify and join vendor's static files
Browse files Browse the repository at this point in the history
  • Loading branch information
luisza committed Jul 20, 2023
1 parent a3eb0d3 commit 9c0967e
Show file tree
Hide file tree
Showing 31 changed files with 7,582 additions and 288 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,6 @@ djgentelella/static/vendors/
#ignore vscode settins
.vscode/
demo/media
djgentelella/static/djgentelella.vendors.header.min.js
djgentelella/static/djgentelella.vendors.min.css
djgentelella/static/djgentelella.vendors.min.js
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ clean-build:
rm -fr dist/
rm -fr *.egg-info
rm -fr djgentelella/static/vendors/*
rm -fr djgentelella/static/djgentelella.vendors*

clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
Expand All @@ -35,8 +36,8 @@ test:
docs:
$(MAKE) -C docs clean
$(MAKE) -C docs html
sphinx-build -b linkcheck ./docs/source _build/
sphinx-build -b html ./docs/source _build/
sphinx-build -b linkcheck ./docs/source docs/build/
sphinx-build -b html ./docs/source docs/build/


release: sdist
Expand All @@ -46,6 +47,7 @@ release: sdist

sdist: clean
cd demo && python manage.py makemigrations && python manage.py loaddevstatic && python manage.py createbasejs
python -m pylp
cd djgentelella && django-admin compilemessages -l es
python3 -m build
ls -l dist
Expand Down
7 changes: 4 additions & 3 deletions demo/demo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
JQUERY_URL = None
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

# DEFAULT_JS_IMPORTS = {
# 'use_bootstraptree': True
# }
DEFAULT_JS_IMPORTS = {
'use_readonlywidgets': True,
'use_flags': True
}
37 changes: 2 additions & 35 deletions demo/demoapp/object_management/viewset.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import viewsets
from rest_framework.decorators import action
from rest_framework.filters import SearchFilter, OrderingFilter
from rest_framework.pagination import LimitOffsetPagination
from rest_framework.response import Response

from djgentelella.objectmanagement import BaseObjectManagement
from ..datatables import serializer
from ..datatables.serializer import PersonFilterSet
from ..models import Person


class PersonObjectMangement(viewsets.ModelViewSet):
class PersonObjectMangement(BaseObjectManagement):
serializer_class = {
'list': serializer.PersonDataTableSerializer,
'create': serializer.PersonCreateSerializer,
Expand All @@ -28,34 +26,3 @@ class PersonObjectMangement(viewsets.ModelViewSet):
ordering_fields = ['name', 'num_children', 'born_date', 'last_time']
ordering = ('-num_children',) # default order
operation_type = ''

def get_serializer_class(self):
if isinstance(self.serializer_class, dict):
if self.action in self.serializer_class:
return self.serializer_class[self.action]
return super().get_serializer_class()

def list(self, request, *args, **kwargs):
queryset = self.filter_queryset(self.get_queryset())
data = self.paginate_queryset(queryset)
response = {'data': data, 'recordsTotal': Person.objects.count(),
'recordsFiltered': queryset.count(),
'draw': self.request.GET.get('draw', 1)}
return Response(self.get_serializer(response).data)

def retrieve(self, request, *args, **kwargs):
return super().retrieve(request, *args, **kwargs)

@action(detail=True, methods=['get'])
def get_values_for_update(self, request, *args, **kwargs):
instance = self.get_object()
serializer = self.get_serializer(instance)
return Response(serializer.data)

@action(detail=False, methods=['get'])
def detail_template(self, request, *args, **kwargs):
data = {
"title": "Title {{it.name}}",
"template": "Name: {{it.name}}"
}
return Response(data)
66 changes: 31 additions & 35 deletions demo/demoapp/templates/chartjs.html
Original file line number Diff line number Diff line change
@@ -1,52 +1,48 @@
{% extends 'gentelella/base.html' %}
{% load gtsettings %}

{% block pre_head %}
{% define_true "use_chartjs" %}
{% endblock %}

{% block content %}

<div class="row">

<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=vertical_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=horizontal_url %}
</div>
<div class="col-md-4" >
{% include 'gentelella/widgets/chartjs.html' with graph_url=stacked_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=vertical_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=horizontal_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=stacked_url %}
</div>
</div>

<div class="row">
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=line_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=stepped_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=arealine_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=line_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=stepped_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=arealine_url %}
</div>
</div>

<div class="row">
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=pie_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=pie_url %}
</div>

<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=doughnut_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=linebar_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=doughnut_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=linebar_url %}
</div>
</div>
<div class="row">
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=scatter_url %}
</div>
<div class="col-md-4">
{% include 'gentelella/widgets/chartjs.html' with graph_url=scatter_url %}
</div>
</div>
{% endblock %}
{% endblock %}
24 changes: 10 additions & 14 deletions demo/demoapp/templates/gentelella/datatables/datatables.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
{% extends 'gentelella/base.html' %}
{% load gtsettings timejs %}

{% block pre_head %}
{% define_true "use_datatables" %}
{% endblock %}


{% block content %}
<div class="card">
<div class="card-body">
<div class="card-title titles">
<h2>Datable Example</h2>
</div>
<div class="card-body">
<div class="card-title titles">
<h2>Datable Example</h2>
</div>

<div class="col-12">
<table id="datatableelement" class="table "> </table>
<div class="col-12">
<table id="datatableelement" class="table "></table>

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

Expand All @@ -33,6 +28,7 @@ <h2>Datable Example</h2>
{data: "last_time", name: "last_time", title: "Last time", type: "date", visible: true, "dateformat": "{% get_datetime_format %}"},
]
}, addfilter=true);

</script>

{% endblock js%}
{% endblock js%}
10 changes: 7 additions & 3 deletions demo/demoapp/templates/object_management.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{% load gtsettings %}

{% block pre_head %}
{% define_true "use_datatables" %}
{% define_urlname_action 'object_management' %}
{% endblock %}

Expand Down Expand Up @@ -42,8 +41,7 @@ <h3 class="heading-1"><span> {% trans 'List of Objects' %} </span></h3>
{% block js %}
{{block.super}}
<script>
document.datetime_format="{% get_datetime_format %}";
document.date_format="{% get_date_format %}";

var object_urls ={
list_url: "{% url 'api-personobjectmanagement-list' %}",
destroy_url: "{% url 'api-personobjectmanagement-detail' 0 %}",
Expand Down Expand Up @@ -103,6 +101,12 @@ <h3 class="heading-1"><span> {% trans 'List of Objects' %} </span></h3>
let ocrud=ObjectCRUD("setmeunique", objconfig)
ocrud.init();







</script>


Expand Down
21 changes: 16 additions & 5 deletions djgentelella/management/commands/loaddevstatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
print("Requests is required try pip install requests")
exit(1)

FLAGS = ['ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'ao', 'aq', 'ar', 'as', 'at', 'au',
FLAGS = ['ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'ao', 'aq', 'ar', 'as', 'at',
'au', 'cp', 'dg', 'ea', 'es-ct', 'es-ga', 'ic', 'ta',
'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bl',
'bm', 'bn', 'bo', 'bq', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc',
'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv',
Expand All @@ -31,8 +32,8 @@
'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'ss', 'st', 'sv', 'sx',
'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to',
'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'um', 'un', 'us', 'uy', 'uz', 'va',
'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'xk', 'ye', 'yt', 'za', 'zm',
'zw']
'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'xk', 'xx', 'ye', 'yt', 'za',
'zm', 'zw']


def download(urls):
Expand Down Expand Up @@ -142,10 +143,12 @@ def handle(self, *args, **options):
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/fonts/fontawesome-webfont.woff2',
],
'font-awesome': [

'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css',
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css.map'
],
'friconix': [
"https://friconix.com/cdn/friconix.js"
],
'bootstrap-daterangepicker': [
# 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/3.1/daterangepicker.min.js',
# 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/3.1/daterangepicker.min.css',
Expand Down Expand Up @@ -281,6 +284,8 @@ def handle(self, *args, **options):
"https://cdn.knightlab.com/libs/timeline3/latest/css/icons/tl-icons.eot",
"https://cdn.knightlab.com/libs/timeline3/latest/css/icons/tl-icons.ttf",
"https://cdn.knightlab.com/libs/timeline3/latest/css/icons/tl-icons.svg",
"https://cdn.knightlab.com/libs/timeline3/latest/css/icons/tl-icons.woff",
"https://cdn.knightlab.com/libs/timeline3/latest/css/icons/tl-icons.woff2",
],
'timeline/js': [
"https://cdn.knightlab.com/libs/timeline3/latest/js/timeline.js"],
Expand All @@ -289,7 +294,13 @@ def handle(self, *args, **options):
"https://cdn.knightlab.com/libs/storymapjs/latest/css/storymap.css",
],
'css/icons/': [
'https://cdn.knightlab.com/libs/storymapjs/latest/css/icons/vco-icons.ttf'
'https://cdn.knightlab.com/libs/storymapjs/latest/css/icons/vco-icons.ttf',
'https://cdn.knightlab.com/libs/storymapjs/latest/css/icons/vco-icons.eot',
'https://cdn.knightlab.com/libs/storymapjs/latest/css/icons/vco-icons.woff',
'https://cdn.knightlab.com/libs/storymapjs/latest/css/icons/vco-icons.woff2',
'https://cdn.knightlab.com/libs/storymapjs/latest/css/icons/vco-icons.svg',
'https://cdn.knightlab.com/libs/storymapjs/latest/css/icons/layers.png',
'https://cdn.knightlab.com/libs/storymapjs/latest/css/icons/layers-2x.png',
],
'chartjs': [
'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js',
Expand Down
21 changes: 21 additions & 0 deletions djgentelella/migrations/00012_defaultusecompessstatic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.4 on 2021-06-26 20:31

from django.db import migrations


def forwards_func(apps, schema_editor):
Settings = apps.get_model("djgentelella", "GentelellaSettings")
Settings.objects.create(
key='use_compress_static',
value='true'
)


class Migration(migrations.Migration):
dependencies = [
('djgentelella', '0003_alter_chunkedupload_status'),
]

operations = [
migrations.RunPython(forwards_func)
]
Loading

0 comments on commit 9c0967e

Please sign in to comment.