Skip to content

Commit

Permalink
[release] version1.3
Browse files Browse the repository at this point in the history
- Add
  - path converter `DateConverter` (`date`)
  - `zip`, `zip_longest` and `chain` tags and `chunked` filter in `boost` template

- Update  
  - add `superuser` option in `StaffMemberRequiredMixin`  
  - support Django3 and python3.8
  - add option `--release` in `support_heroku` command

- Change  
  - `delattr` and `setattr` template tags return value `None` to argument value

- Fix  
  - A problem that some processes may be executed even when re-authentication is required
  • Loading branch information
ChanTsune authored Jan 29, 2020
2 parents 8c12b66 + b1f172b commit f5b0a43
Show file tree
Hide file tree
Showing 31 changed files with 544 additions and 80 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:
- DJANGO_VERSION=2.0
- DJANGO_VERSION=2.1
- DJANGO_VERSION=2.2
- DJANGO_VERSION=3.0
install:
- "python setup.py install"
- "pip install -U pip"
Expand All @@ -18,3 +19,8 @@ install:
script:
- tox
- "python manage.py auto_migrate_test --remove"

matrix:
exclude:
- python: "3.5"
env: DJANGO_VERSION=3.0
19 changes: 18 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
# HISTORYS
# HISTORY

## Versions

### 1.3

- Add
- path converter `DateConverter` (`date`)
- `zip`, `zip_longest` and `chain` tags and `chunked` filter in `boost` template

- Update
- add `superuser` option in `StaffMemberRequiredMixin`
- support Django3 and python3.8
- add option `--release` in `support_heroku` command

- Change
- `delattr` and `setattr` template tags return value `None` to argument value

- Fix
- A problem that some processes may be executed even when re-authentication is required

### 1.2.3

- Add
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,8 @@ URLs are grouped for easy reading.
Easily register Models to Django admin site.

```py
from yourapp import models
from django_boost.admin.site import register_all
from your_app import models
from django_boost.admin.sites import register_all

register_all(models)
```
Expand All @@ -648,7 +648,7 @@ Custom admin classes are also available.
```py
from your_app import models
from your_app import admin
from django_boost.admin.site import register_all
from django_boost.admin.sites import register_all

register_all(models, admin_class=admin.CustomAdmin)
```
Expand Down
2 changes: 1 addition & 1 deletion config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@

STATIC_URL = '/static/'

STSTIC_DIR = os.path.join(BASE_DIR, 'static')
STATIC_DIR = os.path.join(BASE_DIR, 'static')

MEDIA_URL = '/media/'

Expand Down
11 changes: 8 additions & 3 deletions django_boost/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from django.utils.version import get_version
VERSION = (1, 3, 0)

VERSION = (1, 2, 3, 'final', 0)
def get_version(version=VERSION):
if version[2] == 0:
return "%s.%s" % version[:2]
return "%s.%s.%s" % version

__version__ = get_version(VERSION)
__version__ = get_version()

default_app_config = 'django_boost.apps.DjangoBoostConfig'
22 changes: 22 additions & 0 deletions django_boost/admin/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@


def register_all(models, admin_class=admin.ModelAdmin):
"""
Easily register Models to Django admin site.
::
from yourapp import models
from django_boost.admin.sites import register_all
register_all(models)
Register all models defined in `models.py` in Django admin site.
Custom admin classes are also available.
::
from your_app import models
from your_app import admin
from django_boost.admin.sites import register_all
register_all(models, admin_class=admin.CustomAdmin)
"""
for attr in dir(models):
attr = getattr(models, attr, None)
if isinstance(attr, type):
Expand Down
1 change: 1 addition & 0 deletions django_boost/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

class DjangoBoostConfig(AppConfig):
name = 'django_boost'
verbose_name = 'Django Boost'
3 changes: 1 addition & 2 deletions django_boost/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
__all__ = ("ColorCodeField", "ColorInput", "FormUserKwargsMixin",
"UserCreationForm")

User = get_user_model()


class UserCreationForm(BaseUserCreationForm):

class Meta:
User = get_user_model()
model = User
fields = (User.USERNAME_FIELD,)
5 changes: 5 additions & 0 deletions django_boost/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ def __init__(self, attrs=None, check_test=None):

def value_from_datadict(self, data, files, name):
return not super().value_from_datadict(data, files, name)


class Toggleswitch(CheckboxInput):
"""toggle switch styled input"""
template_name = "boost/forms/widgets/toggleswitch.html"
14 changes: 10 additions & 4 deletions django_boost/management/commands/support_heroku.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ class Command(BaseCommand):
help = "Create a configuration file for heroku" + \
"\n`Procfile`,`runtime.txt` and `requirements.txt`\n"
PROCFILE = "Procfile"
PROCFILE_FORMAT = "web: gunicorn %s\n"
PROCFILE_WEB = "web: gunicorn %s\n"
PROCFILE_RELEASE = "release: %s\n"
RUNTIME = "runtime.txt"
RUNTIME_FORMAT = "python-%s\n"
REQUIREMENTS = "requirements.txt"

GUNICORN = 'gunicorn'
GUNICORN = 'gunicorn\n'

def add_arguments(self, parser):
parser.add_argument('--overwrite', action='store_true',
Expand All @@ -41,8 +42,11 @@ def add_arguments(self, parser):
help='Create only `runtime.txt`'
', By default all files are created.')
parser.add_argument('--prockfile', action='store_true',
help='Create only `prockfile`'
help='Create only `Prockfile`'
', By default all files are created.')
parser.add_argument('--release', nargs='+', default=[],
help='Add the command to be executed '
'in the release phase to `Prockfile`')
parser.add_argument('--requirments', action='store_true',
help='Create only `requirments.txt`'
', By default all files are created.')
Expand Down Expand Up @@ -77,7 +81,9 @@ def make_prockfile(self, fpath, **options):
wsgi = ".".join(settings.WSGI_APPLICATION.split(".")[:-1])
if not path.exists(fpath) or options['overwrite']:
with open(fpath, "w") as f:
f.write(self.PROCFILE_FORMAT % wsgi)
for release in options['release']:
f.write(self.PROCFILE_RELEASE % release)
f.write(self.PROCFILE_WEB % wsgi)
self._print_generated_path(fpath, **options)

def make_requirments(self, fpath, no_gunicorn, **options):
Expand Down
65 changes: 65 additions & 0 deletions django_boost/templates/boost/forms/widgets/toggleswitch.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<input class="boost-tgl boost-tgl-light" type="{{ widget.type }}" name="{{ widget.name }}" {% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}{% include "django/forms/widgets/attrs.html" %}/>
<label class="boost-tgl-btn" for="{{ widget.id }}"></label>
<style>
.boost-tgl {
display: none;
}
.boost-tgl,
.boost-tgl:after,
.boost-tgl:before,
.boost-tgl *,
.boost-tgl *:after,
.boost-tgl *:before,
.boost-tgl+.boost-tgl-btn {
box-sizing: border-box;
}
.boost-tgl::selection,
.boost-tgl:after::selection,
.boost-tgl:before::selection,
.boost-tgl *::selection,
.boost-tgl *:after::selection,
.boost-tgl *:before::selection,
.boost-tgl+.boost-tgl-btn::selection {
background: none;
}
.boost-tgl+.boost-tgl-btn {
outline: 0;
display: block;
width: 4em;
height: 2em;
position: relative;
cursor: pointer;
user-select: none;
}
.boost-tgl+.boost-tgl-btn:after,
.boost-tgl+.boost-tgl-btn:before {
position: relative;
display: block;
content: "";
width: 50%;
height: 100%;
}
.boost-tgl+.boost-tgl-btn:after {
left: 0;
}
.boost-tgl+.boost-tgl-btn:before {
display: none;
}
.boost-tgl:checked+.boost-tgl-btn:after {
left: 50%;
}
.boost-tgl-light+.boost-tgl-btn {
background: #f0f0f0;
border-radius: 2em;
padding: 2px;
transition: all 0.4s ease;
}
.boost-tgl-light+.boost-tgl-btn:after {
border-radius: 50%;
background: #fff;
transition: all 0.2s ease;
}
.boost-tgl-light:checked+.boost-tgl-btn {
background: #9FD6AE;
}
</style>
2 changes: 1 addition & 1 deletion django_boost/templates/boost/html.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
</body>
{% block script %}
{% endblock script %}
</html>
{% endblock html %}
</html>
27 changes: 25 additions & 2 deletions django_boost/templatetags/boost.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from ast import literal_eval
from itertools import chain, zip_longest
from warnings import warn

from django.template import Library

from django_boost.utils import isiterable
from django_boost.utils.itertools import chunked

register = Library()

Expand Down Expand Up @@ -56,7 +59,8 @@ def _complex(real, imag=None):

@register.simple_tag(name="delattr")
def _delattr(obj, name):
return delattr(obj, name)
delattr(obj, name)
return obj


@register.filter(name="dir")
Expand Down Expand Up @@ -179,7 +183,8 @@ def _round(number, ndigits=None):

@register.simple_tag(name="setattr")
def _setattr(obj, name, value):
return setattr(obj, name, value)
setattr(obj, name, value)
return obj


@register.filter(name="sorted")
Expand Down Expand Up @@ -209,12 +214,30 @@ def _vars(obj):

@register.filter(name="zip")
def _zip(arg1, arg2):
warn("`zip filter` is deprecated. Use `zip tag` instead.")
return zip(arg1, arg2)


@register.simple_tag(name="zip")
def _zip_tag(*args):
return zip(*args)


@register.simple_tag(name="zip_longest")
def _zip_longest(*args):
return zip_longest(*args)


@register.simple_tag(name="chain")
def _chain(*args):
return chain(*args)


register.filter(isiterable)
register.filter(chunked)
register.simple_tag(literal_eval, name="literal")


@register.simple_tag(name="var")
def var(value):
return value
5 changes: 5 additions & 0 deletions django_boost/templatetags/boost_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ def replace_parameters(request, *args):
for i in range(0, arg_len, 2):
url_dict[args[i]] = str(args[i + 1])
return url_dict.urlencode()


@register.simple_tag
def get_querystring(request, value):
return request.GET.get(value, None)
8 changes: 5 additions & 3 deletions django_boost/urls/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from django_boost.urls.converters import (
BinIntConverter, BinStrConverter, HexIntConverter,
HexStrConverter, OctIntConverter, OctStrConverter,
BinIntConverter, BinStrConverter,
DateConverter,
HexIntConverter, HexStrConverter,
OctIntConverter, OctStrConverter,
register_boost_converters)
from django_boost.urls.static import include_static_files


__all__ = ['UrlSet', 'HexIntConverter', 'HexStrConverter',
'OctIntConverter', 'OctStrConverter', 'BinIntConverter',
'BinStrConverter', 'register_boost_converters',
'BinStrConverter', 'DateConverter', 'register_boost_converters',
'include_static_files']


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.urls import register_converter

from django_boost.urls.converters.date import DateConverter


class HexConverter:
regex = '[0-9a-fA-F]+'
Expand Down Expand Up @@ -76,6 +78,7 @@ def to_url(self, value):
'oct_str': OctStrConverter,
'hex_str': HexStrConverter,
'float': FloatingPointConverter,
'date': DateConverter,
}


Expand Down
Loading

0 comments on commit f5b0a43

Please sign in to comment.