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

Update V2 with bootstrap 4.5.x, bug corrected on horizontal filters, upgrade django version and more #772

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d7ec7a2
close #768 : On my side with these modifications, the demo can run wi…
Nov 11, 2020
2011b2c
Upgrade node dependencies and gulp script
Nov 11, 2020
9326e51
Upgrade bootstrap alpha6
Nov 11, 2020
1717af9
Set 12px for regular font-size
Nov 11, 2020
6131a4a
Revert "Set 12px for regular font-size"
Nov 11, 2020
6d6c74d
prepare for migration to django 2 and bootstrap future upgrade
Nov 12, 2020
058276a
Bootstrap v4.0.0 (#1)
pulse-mind Nov 14, 2020
6da87ad
migrate to bootstrap v4.1
Nov 14, 2020
167dfa0
migrate to bootstrap v4.1
Nov 14, 2020
a9f017d
Merge remote-tracking branch 'origin/v2' into v2
Nov 14, 2020
f68eda8
migrate to bootstrap v4.1
Nov 14, 2020
8286ae5
migrate to bootstrap v4.1.3
Nov 14, 2020
223d65b
migrate to bootstrap v4.2.1
Nov 14, 2020
dec32eb
migrate to bootstrap v4.3.1
Nov 14, 2020
2a06d3e
migrate to bootstrap v4.4.1
Nov 14, 2020
4e62e22
migrate to bootstrap v4.5.0
Nov 14, 2020
c192b74
migrate to bootstrap v4.5.0 (#2)
pulse-mind Nov 14, 2020
d622c33
migrate to bootstrap v4.5.3
Nov 15, 2020
70db6a5
migrate to django 2.2.x
Nov 15, 2020
91b50c5
Reduce size 14px to 13px and h2 - h5
Nov 16, 2020
e6d6c7a
Addlink button (#3)
pulse-mind Nov 17, 2020
113547b
Update djangosuit version
Nov 17, 2020
98fdae8
Migrate to Django3.0.x (#4)
pulse-mind Nov 18, 2020
d35bf27
Update django suit version
Nov 18, 2020
fe4dbb8
Merge remote-tracking branch 'origin/v2' into v2
Nov 18, 2020
3406a42
Migration to Django 3.1.x (#5)
pulse-mind Nov 19, 2020
d92b2c0
Django31 (#6)
pulse-mind Nov 19, 2020
7dbe970
Migrate to Django3.1 (#7)
pulse-mind Nov 24, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ docs/_build/
/bower_components/
/node_modules/
/env/
/package-lock.json
15 changes: 7 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
language: python
python:
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
- 3.7
- 3.8
- pypy3
env:
- DJANGO=1.11
- DJANGO=2.0
- DJANGO=2.2.17
- DJANGO=3.0.11
install:
- pip install -e .
- pip install -q Django==$DJANGO
Expand All @@ -16,6 +15,6 @@ script:
matrix:
exclude:
- python: 2.7
env: DJANGO=2.0
env: DJANGO=2.2.17
- python: pypy
env: DJANGO=2.0
env: DJANGO=2.2.17
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"tests"
],
"devDependencies": {
"bootstrap": "v4.0.0-alpha.5"
"bootstrap": "v4.5.3"
}
}
Binary file modified demo/db.sqlite3
Binary file not shown.
35 changes: 26 additions & 9 deletions demo/demo/admin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from django.conf import settings
from django.conf.urls import url
from django.contrib import admin
from django.forms import ModelForm, Select, TextInput, NumberInput
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib import messages
from django.shortcuts import redirect
from django.urls import re_path
from django_select2.forms import ModelSelect2Widget
from suit import apps

Expand Down Expand Up @@ -46,9 +43,9 @@ class Meta:
attrs={'placeholder': 'Country area'}),
'population': EnclosedInput(
prepend='fa-users',
append='<button class="btn btn-secondary" type="button" '
'onclick="window.open(\'https://www.google.com/\')">Search</button>',
append_class='btn', attrs={'placeholder': 'Human population'}),
append='Search',
onclick_append="window.open(\'https://www.google.com/\')",
append_class='addon', attrs={'placeholder': 'Human population' }),
'description': AutosizedTextarea,
'architecture': AutosizedTextarea,
}
Expand All @@ -66,7 +63,7 @@ class PopulationFilter(IsNullFieldListFilter):
class CountryAdmin(RelatedFieldAdmin):
form = CountryForm
search_fields = ('name', 'code')
list_display = ('name', 'code', 'link_to_continent', 'independence_day')
list_display = ('name', 'code', 'independence_day')
list_filter = ('continent', 'independence_day', 'code', ('population', PopulationFilter))
suit_list_filter_horizontal = ('code', 'population')
list_select_related = True
Expand Down Expand Up @@ -314,7 +311,7 @@ def get_urls(self):
"""
urls = super(ShowcaseAdmin, self).get_urls()
my_urls = [
url(r'^(\d+)/clickme/$', showcase_custom_view_example, name='demo_showcase_clickme')
re_path(r'^(\d+)/clickme/$', showcase_custom_view_example, name='demo_showcase_clickme')
]
return my_urls + urls

Expand All @@ -327,3 +324,23 @@ def showcase_custom_view_example(request, pk):
messages.success(request, 'Something legendary was done to "%s"' % instance)

return redirect('admin:demo_showcase_change', pk)

#
# class LargeFilterHorizontalForm(ModelForm):
# class Meta:
# pass
#
#
# @admin.register(LargeFilterHorizontal)
# class LargeFilterHorizontalAdmin(RelatedFieldAdmin):
# form = LargeFilterHorizontalForm
# search_fields = ('title',)
# list_display = ('horizontal_choices1', 'horizontal_choices2', 'horizontal_choices3', 'horizontal_choices4',)
# list_filter = ('horizontal_choices1', 'horizontal_choices2', 'horizontal_choices3', 'horizontal_choices4',
# 'horizontal_choices5', 'horizontal_choices6', 'horizontal_choices7', 'horizontal_choices8')
# suit_list_filter_horizontal = list_filter
#
# fieldsets = [
# ('Main', {'fields': ['horizontal_choices1', 'horizontal_choices2', 'horizontal_choices3', 'horizontal_choices4',
# 'horizontal_choices5', 'horizontal_choices6', 'horizontal_choices7', 'horizontal_choices8']}),
# ]
94 changes: 94 additions & 0 deletions demo/demo/migrations/0013_auto_20201112_1223.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Generated by Django 2.1.15 on 2020-11-12 11:23

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('demo', '0012_auto_20170407_1131'),
]

operations = [
migrations.AlterField(
model_name='book',
name='rating',
field=models.SmallIntegerField(choices=[(1, 'Awesome'), (2, 'Good'), (3, 'Normal'), (4, 'Bad')], help_text='Choose wisely'),
),
migrations.AlterField(
model_name='country',
name='code',
field=models.CharField(help_text='ISO 3166-1 alpha-2 - two character country code', max_length=2),
),
migrations.AlterField(
model_name='country',
name='description',
field=models.TextField(blank=True, help_text='Try and enter few some more lines'),
),
migrations.AlterField(
model_name='movie',
name='rating',
field=models.SmallIntegerField(choices=[(1, 'Awesome'), (2, 'Good'), (3, 'Normal'), (4, 'Bad')], default=2),
),
migrations.AlterField(
model_name='showcase',
name='boolean_with_help',
field=models.BooleanField(default=False, help_text='Boolean field with help text'),
),
migrations.AlterField(
model_name='showcase',
name='choices',
field=models.SmallIntegerField(choices=[(1, 'Tall'), (2, 'Normal'), (3, 'Short')], default=3, help_text='Help text'),
),
migrations.AlterField(
model_name='showcase',
name='country',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='demo.Country'),
),
migrations.AlterField(
model_name='showcase',
name='country2',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='showcase_country2_set', to='demo.Country', verbose_name='Django Select 2'),
),
migrations.AlterField(
model_name='showcase',
name='help_text',
field=models.CharField(help_text='Enter fully qualified name', max_length=64),
),
migrations.AlterField(
model_name='showcase',
name='horizontal_choices',
field=models.SmallIntegerField(choices=[(1, 'Awesome'), (2, 'Good'), (3, 'Normal'), (4, 'Bad')], default=1, help_text='Horizontal choices look like this'),
),
migrations.AlterField(
model_name='showcase',
name='multiple_in_row',
field=models.CharField(help_text='Help text for multiple', max_length=64),
),
migrations.AlterField(
model_name='showcase',
name='raw_id_field',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='showcase_raw_set', to='demo.Country'),
),
migrations.AlterField(
model_name='showcase',
name='readonly_field',
field=models.CharField(default='Some value here', max_length=127),
),
migrations.AlterField(
model_name='showcase',
name='textfield',
field=models.TextField(blank=True, help_text='Try and enter few some more lines', verbose_name='Autosized textfield'),
),
migrations.AlterField(
model_name='showcase',
name='time_only',
field=models.TimeField(blank=True, null=True, verbose_name='Time'),
),
migrations.AlterField(
model_name='showcase',
name='vertical_choices',
field=models.SmallIntegerField(choices=[(1, 'Hot'), (2, 'Normal'), (3, 'Cold')], default=2, help_text='Some help on vertical choices'),
),
]
50 changes: 43 additions & 7 deletions demo/demo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Meta:


class Country(models.Model):
continent = models.ForeignKey(Continent, null=True)
continent = models.ForeignKey(Continent, null=True, on_delete=models.CASCADE)
name = models.CharField(max_length=256)
code = models.CharField(max_length=2,
help_text='ISO 3166-1 alpha-2 - two character country code')
Expand All @@ -38,7 +38,7 @@ class Meta:

class City(models.Model):
name = models.CharField(max_length=64)
country = models.ForeignKey(Country)
country = models.ForeignKey(Country, on_delete=models.CASCADE)
is_capital = models.BooleanField()
area = models.BigIntegerField(blank=True, null=True)
population = models.BigIntegerField(blank=True, null=True)
Expand Down Expand Up @@ -82,9 +82,9 @@ class Showcase(models.Model):
choices = models.SmallIntegerField(
choices=TYPE_CHOICES3, default=3, help_text="Help text")

country = models.ForeignKey(Country, null=True, blank=True)
country2 = models.ForeignKey(Country, null=True, blank=True, related_name='showcase_country2_set', verbose_name='Django Select 2')
raw_id_field = models.ForeignKey(Country, null=True, blank=True, related_name='showcase_raw_set')
country = models.ForeignKey(Country, null=True, blank=True, on_delete=models.SET_NULL)
country2 = models.ForeignKey(Country, null=True, blank=True, related_name='showcase_country2_set', verbose_name='Django Select 2', on_delete=models.SET_NULL)
raw_id_field = models.ForeignKey(Country, null=True, blank=True, related_name='showcase_raw_set', on_delete=models.SET_NULL)
# linked_foreign_key = models.ForeignKey(Country, limit_choices_to={
# 'continent__name': 'Europe'}, related_name='foreign_key_linked')
html5_color = models.CharField(null=True, blank=True, max_length=7)
Expand All @@ -97,7 +97,7 @@ class Meta:

# Tabular inline model for Showcase
class Movie(models.Model):
showcase = models.ForeignKey(Showcase)
showcase = models.ForeignKey(Showcase, on_delete=models.CASCADE)
title = models.CharField(max_length=64)
rating = models.SmallIntegerField(choices=TYPE_CHOICES, default=2)
description = models.TextField(blank=True)
Expand All @@ -113,7 +113,7 @@ def __unicode__(self):

# Stacked inline model for Showcase
class Book(models.Model):
showcase = models.ForeignKey(Showcase)
showcase = models.ForeignKey(Showcase, on_delete=models.CASCADE)
title = models.CharField(max_length=64)
rating = models.SmallIntegerField(choices=TYPE_CHOICES, help_text='Choose wisely')
is_released = models.BooleanField(default=False)
Expand All @@ -124,3 +124,39 @@ class Meta:

def __unicode__(self):
return self.title


# class LargeFilterHorizontal(models.Model):
# title = models.CharField(max_length=64)
#
# TYPE_CHOICES= ((1, 'Awesome'), (2, 'Good'), (3, 'Normal'), (4, 'Bad'))
# TYPE_CHOICES2 = ((1, 'Hot'), (2, 'Normal'), (3, 'Cold'))
# TYPE_CHOICES3 = ((1, 'Tall'), (2, 'Normal'), (3, 'Short'))
# TYPE_CHOICES4 = ((1, 'Black'), (2, 'Purple'), (3, 'Pink'))
# TYPE_CHOICES5 = ((1, 'Image'), (2, 'Video'), (3, 'Sound'))
# TYPE_CHOICES6 = ((1, 'Square'), (2, 'Circle'), (3, 'Triangle'))
# TYPE_CHOICES7 = ((1, 'GIF'), (2, 'JPG'), (3, 'PNG'))
# TYPE_CHOICES8 = ((1, 'Color'), (2, 'B&W'), (3, 'Others'))
# horizontal_choices1 = models.SmallIntegerField(
# choices=TYPE_CHOICES, default=1, help_text='Horizontal1 choices look like this')
# horizontal_choices2 = models.SmallIntegerField(
# choices=TYPE_CHOICES2, default=2, help_text="Horizontal2 choices look like this")
# horizontal_choices3 = models.SmallIntegerField(
# choices=TYPE_CHOICES3, default=3, help_text="Horizontal3 choices look like this")
# horizontal_choices4 = models.SmallIntegerField(
# choices=TYPE_CHOICES4, default=1, help_text='Horizontal4 choices look like this')
# horizontal_choices5 = models.SmallIntegerField(
# choices=TYPE_CHOICES5, default=2, help_text="Horizontal5 choices look like this")
# horizontal_choices6 = models.SmallIntegerField(
# choices=TYPE_CHOICES6, default=3, help_text="Horizontal6 choices look like this")
# horizontal_choices7 = models.SmallIntegerField(
# choices=TYPE_CHOICES7, default=2, help_text="Horizontal7 choices look like this")
# horizontal_choices8 = models.SmallIntegerField(
# choices=TYPE_CHOICES8, default=3, help_text="Horizontal8 choices look like this")
#
# class Meta:
# verbose_name = 'Large Filter Horizontal choice'
# verbose_name_plural = 'Large Filter Horizontal choices'
#
# def __unicode__(self):
# return self.title
4 changes: 2 additions & 2 deletions demo/demo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
'django.contrib.staticfiles',
]

MIDDLEWARE_CLASSES = [
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
#'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
Expand Down
2 changes: 1 addition & 1 deletion demo/demo/templates/admin/custom_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="card-header">
Isn't this neat?
</div>
<div class="card-block">
<div class="card-body">
<h4 class="card-title">Custom view</h4>
<p class="card-text">This is an example how easy you can create custom views and add them to menu.
<br/> Django + Django Suit + Bootstrap 4 = awesome!</p>
Expand Down
2 changes: 1 addition & 1 deletion demo/demo/templates/admin/demo/country/tab_charts.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h2>Statistics</h2>
Activities
</label>
<div class="col-xs-12 col-sm-9 col-md-10 col-lg-9">
<div class="form-control-static">
<div class="form-control-plaintext">
<div id="piechart" style="width: 100%; height: 300px;"></div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions demo/demo/templates/admin/demo/country/tab_docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h2>Documentation</h2>
Tabs
</label>
<div class="col-xs-12 col-sm-9 col-md-10 col-lg-9">
<div class="form-control-static">
<div class="form-control-plaintext">
Tabs you see above are based on mostly CSS/JS solution, therefore integration of tabs is simple and non intrusive - all your form handling will work the same as before.
<br><br>
Tabs can contain fieldsets, inlines and custom/included templates
Expand All @@ -20,7 +20,7 @@ <h2>Documentation</h2>
Includes
</label>
<div class="col-xs-12 col-sm-9 col-md-10 col-lg-9">
<div class="form-control-static">
<div class="form-control-plaintext">
Django Suit provides handy shortcut to include templates into forms, into several positions:
<ul>
<li>top - above fieldsets</li>
Expand Down
4 changes: 2 additions & 2 deletions demo/demo/templates/admin/demo/country/tab_flag.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h2>Country flag</h2>
Flag source:
</label>
<div class="col-xs-12 col-sm-9 col-md-10 col-lg-9">
<div class="form-control-static">
<div class="form-control-plaintext">
<a href="http://www.geonames.org" target="_blank">http://www.geonames.org</a>
</div>
</div>
Expand All @@ -20,7 +20,7 @@ <h2>Country flag</h2>
Flag of {{ original.name }}
</label>
<div class="col-xs-12 col-sm-9 col-md-10 col-lg-9">
<div class="form-control-static">
<div class="form-control-plaintext">
{% if original.pk %}
<img src="http://www.geonames.org/flags/x/{{ original.code|lower }}.gif" alt="" class="img-fluid" style="max-width: 300px">

Expand Down
2 changes: 1 addition & 1 deletion demo/demo/templates/admin/demo/country/tab_notice.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h2>Custom include</h2>
</div>

<div class="card">
<div class="card-block">
<div class="card-body">
Read more on including templates in the last tab.
</div>
</div>
Expand Down
Loading