Skip to content

Commit

Permalink
Merge 7899588 into 6f517e6
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarcos committed Mar 5, 2020
2 parents 6f517e6 + 7899588 commit c1c0a66
Show file tree
Hide file tree
Showing 17 changed files with 322 additions and 93 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ sudo: false
language: python
python:
- 3.6
- 3.7
- 3.8
matrix:
fast_finish: true
include:
- python: 3.7
dist: xenial
sudo: true

before_install:
- pip install flake8
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

Always reference the ticket number at the end of the issue description.

## [unreleased]

### Added
Compatibility with Django 3.0 and Python 3.8

## 1.4.2 (2019-12-12)

### Added
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ Instead of being a ready-to-use CMS, Arctic is a framework that facilitates the

## Compatibility

* Python 3.6, 3.7
* Django 1.11, 2.1, 2.2
* Python 3.6, 3.7, 3.8
* Django 2.1, 2.2, 3.0
117 changes: 75 additions & 42 deletions arctic/bin/arctic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ class bcolors:
"""
ANSI escape sequences for terminal colors
"""
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'

HEADER = "\033[95m"
OKBLUE = "\033[94m"
OKGREEN = "\033[92m"
WARNING = "\033[93m"
FAIL = "\033[91m"
ENDC = "\033[0m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"


def create_project(parser, options, args):
Expand Down Expand Up @@ -119,10 +120,11 @@ def create_app(parser, options, args):
"name. Please try another name.".format(app_name)
)

print((
bcolors.HEADER
+ "Creating an App named {}"
+ bcolors.ENDC + "\n").format(app_name))
print(
(
bcolors.HEADER + "Creating an App named {}" + bcolors.ENDC + "\n"
).format(app_name)
)

# First find the path to Arctic
import arctic
Expand All @@ -144,34 +146,63 @@ def create_app(parser, options, args):
utility = ManagementUtility(utility_args)
utility.execute()

print((
"Congratulations! {0} folder has been created it contains the "
"following structure.\n\n"
+ bcolors.OKBLUE
+ " -{0}\n"
" ---__init__.py\n"
" ---apps.py\n"
" ---forms.py\n"
" ---models.py\n"
" ---urls.py\n"
" ---views.py\n\n"
+ bcolors.ENDC
+ "The next steps are:\n\n"
" Add the app name to " + bcolors.UNDERLINE + "INSTALLED_APPS" + bcolors.ENDC + " in the settings.py\n" # NOQA
+ bcolors.OKGREEN + "\"{0}\"," + bcolors.ENDC + "\n"
" Add the app name and path to " + bcolors.UNDERLINE + "ARCTIC_MENU" + bcolors.ENDC + " in the settings.py\n" # NOQA
+ bcolors.OKGREEN + "(\"{1}\", \"{0}:list\", \"fa-folder\")," + bcolors.ENDC + "\n" # NOQA
" Add the urls to config/urls.py.\n"
+ bcolors.OKGREEN + "url(r\"^{0}/\", include(\"{0}.urls\", \"{0}\"))," + bcolors.ENDC + "\n" # NOQA
" Add fields in the models.py file\n"
"- Run " + bcolors.OKGREEN + "./manage.py makemigrations {0}" + bcolors.ENDC + "\n" # NOQA
"- Run " + bcolors.OKGREEN + "./manage.py migrate" + bcolors.ENDC + "\n\n" # NOQA
"The " + bcolors.BOLD + "forms.py" + bcolors.ENDC + " has a form with all the fields in the model and \n" # NOQA
"the " + bcolors.BOLD + "views.py" + bcolors.ENDC + " contains views for list, create, edit and delete. \n" # NOQA
"All of then can be tweaked to better satisfy the needs of the "
"project/app\n").format(
app_name, app_name.capitalize()
)
print(
(
"Congratulations! {0} folder has been created it contains the "
"following structure.\n\n" + bcolors.OKBLUE + " -{0}\n"
" ---__init__.py\n"
" ---apps.py\n"
" ---forms.py\n"
" ---models.py\n"
" ---urls.py\n"
" ---views.py\n\n" + bcolors.ENDC + "The next steps are:\n\n"
" Add the app name to "
+ bcolors.UNDERLINE
+ "INSTALLED_APPS"
+ bcolors.ENDC
+ " in the settings.py\n" # NOQA
+ bcolors.OKGREEN
+ '"{0}",'
+ bcolors.ENDC
+ "\n"
" Add the app name and path to "
+ bcolors.UNDERLINE
+ "ARCTIC_MENU"
+ bcolors.ENDC
+ " in the settings.py\n" # NOQA
+ bcolors.OKGREEN
+ '("{1}", "{0}:list", "fa-folder"),'
+ bcolors.ENDC
+ "\n" # NOQA
" Add the urls to config/urls.py.\n"
+ bcolors.OKGREEN
+ 'url(r"^{0}/", include("{0}.urls", "{0}")),'
+ bcolors.ENDC
+ "\n" # NOQA
" Add fields in the models.py file\n"
"- Run "
+ bcolors.OKGREEN
+ "./manage.py makemigrations {0}"
+ bcolors.ENDC
+ "\n" # NOQA
"- Run "
+ bcolors.OKGREEN
+ "./manage.py migrate"
+ bcolors.ENDC
+ "\n\n" # NOQA
"The "
+ bcolors.BOLD
+ "forms.py"
+ bcolors.ENDC
+ " has a form with all the fields in the model and \n" # NOQA
"the "
+ bcolors.BOLD
+ "views.py"
+ bcolors.ENDC
+ " contains views for list, create, edit and delete. \n" # NOQA
"All of then can be tweaked to better satisfy the needs of the "
"project/app\n"
).format(app_name, app_name.capitalize())
)


Expand All @@ -183,8 +214,10 @@ def create_app(parser, options, args):

def main():
# Parse options
parser = OptionParser(usage="Usage: arctic start project_name [directory]"
"Usage: arctic createapp appname [directory]")
parser = OptionParser(
usage="Usage: arctic start project_name [directory]"
"Usage: arctic createapp appname [directory]"
)
(options, args) = parser.parse_args()

# Find command
Expand Down
17 changes: 8 additions & 9 deletions arctic/generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import json
from collections import OrderedDict

import extra_views
from django.conf import settings
from django.contrib import messages
from django.contrib.auth import authenticate, login, logout
Expand All @@ -23,16 +22,15 @@
from django.shortcuts import redirect, render, resolve_url
from django.urls import NoReverseMatch, reverse
from django.utils.formats import get_format
from django.utils.html import (
mark_safe,
strip_tags,
)
from django.utils.html import mark_safe, strip_tags
from django.utils.http import is_safe_url, quote
from django.utils.text import capfirst
from django.utils.translation import ugettext as _
from django.utils.translation import get_language
from django.utils.translation import ugettext as _
from django.views import generic as base

import extra_views

from .mixins import (
FormMediaMixin,
FormMixin,
Expand Down Expand Up @@ -484,9 +482,10 @@ def get_list_header(self):
item["label"] = field_name
item["name"] = prefix + name
if name in ordering_fields:
item["order_url"], item[
"order_direction"
] = self.ordering_url(name)
(
item["order_url"],
item["order_direction"],
) = self.ordering_url(name)
result.append(item)

return result
Expand Down
24 changes: 8 additions & 16 deletions arctic/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
import importlib
import sys
import warnings
from collections import OrderedDict

from django.conf import settings
from django.contrib import messages
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
from django.urls import reverse
from django.utils import six
from django.utils.translation import ugettext_lazy as _

from collections import OrderedDict

from .forms import SimpleSearchForm
from .loading import get_role_model, get_user_role_model
from .utils import arctic_setting, reverse_url, view_from_url, generate_id
from .utils import arctic_setting, generate_id, reverse_url, view_from_url
from .widgets import SelectizeAutoComplete

Role = get_role_model()
Expand Down Expand Up @@ -237,7 +235,7 @@ def get_layout(self, inline_layout=None, fields=None):
):
for i, (fieldset, rows) in enumerate(layout.items()):
fieldset = self._return_fieldset(fieldset)
if isinstance(rows, six.string_types):
if isinstance(rows, str):
allowed_rows.update(
{i: {"fieldset": fieldset, "rows": rows}}
)
Expand All @@ -262,9 +260,7 @@ def get_layout(self, inline_layout=None, fields=None):
def _process_first_level(self, rows, fields):
allowed_rows = []
for row in rows:
if isinstance(row, six.string_types) or isinstance(
row, six.text_type
):
if isinstance(row, str):
allowed_rows.append(self._return_field(row, fields))
elif type(row) in (list, tuple):
rows = self._process_row(row, fields)
Expand All @@ -281,9 +277,7 @@ def _process_row(self, row, fields):
# Yeah, like this isn't incomprehensible yet. Let's add recursion
if type(field) in (list, OrderedDict):
_row[index] = self._process_row(field)
elif isinstance(field, six.string_types) or isinstance(
field, six.text_type
):
elif isinstance(field, str):
name, column = self._split_str(field)
if column:
has_column[index] = self._return_field(field, fields)
Expand Down Expand Up @@ -599,10 +593,8 @@ def get_fields(self, strip_labels=False):
"""
Hook to dynamically change the fields that will be displayed
"""
if self.fields == '__all__':
return [
f.name for f in self.model._meta.get_fields()
]
if self.fields == "__all__":
return [f.name for f in self.model._meta.get_fields()]
if strip_labels:
return [
f[0] if type(f) in (tuple, list) else f for f in self.fields
Expand Down Expand Up @@ -893,7 +885,7 @@ def get_permission_required(cls):
"Define {0}.permission_required, or override "
"{0}.get_permission_required().".format(cls.__name__)
)
if isinstance(cls.permission_required, six.string_types):
if isinstance(cls.permission_required, str):
if cls.permission_required != "":
perms = (cls.permission_required,)
else:
Expand Down

0 comments on commit c1c0a66

Please sign in to comment.