Giter Site home page Giter Site logo

dpgmediamagazines / django-arctic Goto Github PK

View Code? Open in Web Editor NEW
68.0 13.0 21.0 43.69 MB

Django Arctic is a framework that simplifies the creation of custom content management systems.

Home Page: http://django-arctic.readthedocs.io/en/latest/

License: MIT License

Python 54.36% HTML 17.64% JavaScript 8.13% Dockerfile 0.09% SCSS 19.79%
django arctic cms framework

django-arctic's Introduction

Django Arctic

PyPi version Build Status Coverage Status Read the Docs Downloads

Django Arctic is a framework that speeds up the creation of custom content management systems. It provides a Bootstrap 4 based user interface, role based authentication and a number of generic Django Views that provide great looking and feature-rich lists and forms.

  • Lists support sorting, searching, links, nested fields, custom columns and data sources not only from databases but also from APIs
  • The Forms have enhanced widgets for DateTime, AutoComplete and MultiSelect and also support custom layouts without having to create extra templates.

arctic screenshot

Why

There are a lot of content management systems in the market that are a good fit for the creation of many web sites. Most CMS's make assumptions about the data model for posts, authentication and the administration interface.

There is however a tipping point, where customizing a CMS product is so extensive that it ends up being better to use some lower level framework.

This is the case that Arctic wants to solve, creation of a CMS with a high degree of customization. Instead of being a ready-to-use CMS, Arctic is a framework that facilitates the construction of content management systems.

Compatibility

  • Python 3.7, 3.8, 3.9
  • Django 2.2, 3.0, 3.1

django-arctic's People

Contributors

allardmuis avatar andreyrusanov avatar aodarc avatar arpe avatar bartvdwaerden avatar baskoopmans avatar daan944 avatar david-esteves avatar ddaan avatar dependabot-preview[bot] avatar dependabot[bot] avatar dgbc avatar edgarsvincans avatar gooliver2 avatar leon740gk avatar maartenpi avatar markotibold avatar mmarcos avatar r4ym3 avatar rdeknijf avatar silveron avatar spinnerok avatar stasosovskyi avatar volodiakhl avatar wolendranh avatar z2i avatar zemanel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-arctic's Issues

Authentication and Permissions

Arctic needs an authentication/permissions system, it should be:

  • optional app
  • authentication should be possible to override
  • support roles
  • page level permissions should be enough

read_only_fields option in UpdateView

similar to what django admin offers, it should be possible to provide a list of fields that should be displayed as read only in an UpdateView, it would use the following form:
read_only_fields = ['field1', 'field2', ...]

GridView

When displaying media a grid view with image thumbnails and a title/caption can be more effective than a standard view.
A rough example is attached
page-grid

Burger menu in safari

the burger menu in safari doesn't usually turn into a cross when clicked, instead it removes the middle bar and doesn't do the animation to create a cross.
Before:
screen shot 2016-05-18 at 21 14 30
After:
screen shot 2016-05-18 at 21 14 45

ListView: Search field empty not working for null foreign keys

I have a model with a foreign key, which may be nullable (zero to many). When i add this field to the ListView:
search_fields = ['model__title', 'model__id']
And i search with an empty value, it should return all items. Instead, it filters out all null references. This is very applicable when you have both search fields and filters:
filter_fields = ['model_status']
Now when i filter on status and keep the search field empty, it still filters out all null referenced items.

I can fix it by removing the ?search= in the request url. Now it shows all fields i would expect.

Fix is probably to only filter search results IF the search parameter is provided AND not empty.

Swappable models

Arctic introduces 2 models:
Role - a list of roles with name and is_enabled fields
UserRole - the connection between a User and a Role

These models should be swappable, which means someone using arctic should be able to replace these models with their own if needed.

Invalid foreign key IDs

In the list view, when I add one field to be a link to another method, it doesn't create the foreign key ids to the proper object, as it uses the ID of the listed object instead of the ID of the FK. For instance I have this code:

field_links = { 'id': 'user-pictures:update', 'user__user_slug': 'sbusers:update', }

And for the sake of argument let's say that I have User Pictures with IDs 1 to 10, and all of them belong to Users with IDs 1 to 3.

This will result in a ListView of 10 items, 'id' will point to User Picture 1, 2, 3, 4, 5, etc., but the User Slug will point to the Users with IDs 1, 2, 3, 4, 5, etc., using the same PK as the User Picture, instead of pointing to the correct Users with IDs 1, 1, 1, 2, 2, 2, etc. (it may be a bit confusing to read, sorry about that!)

The Foreign Keys should take the correct user_id instead of the listed object's id.

Make delete confirm message override-able

Current delete confirm template shows:

`{% block content %}


{% if can_delete %}

            {% csrf_token %}
            <h5>Are you sure you want to delete "{{ object }}"?</h5>
            <p>This cannot be undone</p>
            <p></p>`

I cannot overrule this text, without implementing the complete template.

Datetime selectors show undefined on focus and NaN when clicking on a date

I tested a datetime in the platform, and when clicking on the field it shows the following "undefined:undefined" display.

screen shot 2016-10-05 at 09 35 57

Once you click on "today" it shows the current month, but if you click on a particular day (for instance today's number), it shows the following NaN invalid value:

screen shot 2016-10-04 at 19 01 07

To actually fix it you must write manually a valid date/time.

hardcoded tabpanel within tabs

In base_detail.html there's a tab panel hardcoded without defining a corresponding tab. Which gives the problem that the panel never goes away OR never goes back.

<div class="tabs-panel is-active">
     {% block form %}
         {% include "arctic/partials/form_fields.html" with form=form style="horizontal" %}
     {% endblock %}
 </div>

Menu hamburger to cross

Sometimes when resizing the browser window triggering the sliding out of the side menu, the hamburger menu stops working properly, either showing the cross icon while the menu is open or not sliding in/out the side menu at all.

Add support for sorting in ListView

The ListView generic class from Arctic needs to support sorting, there is already a ordering_fields method that can be set, but its not yet functional.

Hide links when permissions are not allowed

In the side menu, action links and tool links, links should be hidden if the user does not have enough permissions to access them, this can be done by finding the class based view from the url, and then querying the permission with the has_perm() method on the respective link.

Clear search filters

Once there is a search done in a ListView, there is no way to clear the search filters except clicking on the left menu again, which is not intuitive for the final CMS users.

screen shot 2016-10-03 at 16 46 59

links on detailview doenst work

code e.g.:

links = [
    (_('View'), 'custom_admin:items:item-list'),
]

give reverse error, because the dashboard_url method didn't receive a named url but the whole tuple.

Virtual fields in ListView

The ListView includes a fields property that indicates which fields should be displayed in a table. These fields currently need to match an existing field in a database model, but sometimes it is necessary to format the field data in a different way, combine several fields in one column or even display a field that doesn't exist in the datamodel.

Supporting virtual fields can be done by creating a method and using the method name in the fields property. This method receives a row instance and will return a string.

For example:

class MyListView(arctic.ListView):
    fields = (model_field1, model_field2, not_a_model_field)

    def not_a_model_field(row_instance):
        return '<b>' + row_instance.model_field3 + '</b>'

Capitalise the Columns of the ListView

This is a very small issue, but it would be nice to see the column titles start with a capital letter also for the field columns. Currently only the Actions column has this behaviour.

screen shot 2016-10-05 at 10 46 15

it should be mandatory to set required_permission on all views

And give an exception if you did not. This way users will not accidentally access a newly written views.

Settings required_permission to empty string or tuple should be enough, or extend a newly created get_required_permission method.

Furthermore it should be possible to add multiple permissions.

Listvew not compatible with 'values' querysets (query with GROUP BY)

For example:

queryset = Event.objects.values('source').annotate( max_date_created=Max('date_created') )

Two issues here:

1# There is no pk, but the listview expect it and wants to place the primary key as first item of the list_items.
2# Does not return objects of certain model, but a dictionary.

Overflow hidden on textarea

The textarea component has a default css property "overflow:hidden". This means, users cannot scroll trough large texts. Please remove this property from the textarea.

Choices field proper display in the ListView

When displaying a choices field in the ListView, it shows the actual value instead of the display, which is preferred in the CMS environment. Setting it to the field name memory_type displays this:

screen shot 2016-10-05 at 10 41 05

While if you put the actual helper method that gets added automatically, get_memory_type_display, it displays correctly the content, but displays an invalid title then:

screen shot 2016-10-05 at 10 42 30

It would be nice that before displaying the column, there would be a check trying to find a "get_XXX_display" in the instance, and if it's there, show that value instead of the field's value.

Create modular blocks to use in layouts and articles.

Most sites nowadays need snippets of variable data-structure for cross platform compatibilty and a better user-experience. A snippet will be parsed by an app (website or phone app) and behavior is dependent of implementation.

You could use these snippets to display:

  • Video
  • Slideshow
  • Questionnaire / form
    In articles or layouts.

These snippets, we call them 'blocks', need context for proper functioning. E.g. a videoblock needs to know what video to display. Since all sites need to build their own blocks, we need a model and form that is highly customizable, syncs with JS and can support all kinds of context.

Acceptance criteria:

  1. Is context stored in JSON? yes
  2. Is a block easily added by a developer? yes
  3. Is there need to add a template/form by the developer? no
  4. If desired, can the template be customized by the developer? yes
  5. Is this block validated by the backend before saving? yes

@bartee and I already started work on it.

Settings missing model defaults after Swappable models introduced

The following commit broke my running admin a few days ago:

4b585a6

In here the role models allowed overriding the default model, but the line role = models.ForeignKey(settings.ARCTIC_ROLE_MODEL) breaks compatibility with existing running platforms that didn't define that setting variable.

Both ARCTIC_ROLE_MODEL and ARCTIC_USER_ROLE_MODEL should have proper default values for backwards compatibility, and also because users who don't want to swap the model don't need to define the default value.

I want to show Font Awesome icons as actions links

In a list view, it is possible to add action links per row:
action_links = [ ('edit', 'contributions:detail'), ('delete', 'contributions:delete'), ]
Sometimes, i will need as much as 6 or 7 of these. When these are displayed as text, they will be far too big. I would like to use the build in Font Awesome icons in this case.

I would suggest adding an extra (optional) property to the action links, which specifies if an icon should be shown, fa classes will be added, and the inner HTML will be empty:

action_links = [ ('edit', 'contributions:detail', True), ('delete', 'contributions:delete'), ]
This should render an edit icon with class "fa fa-edit", and delete will be shown the old way. The "edit" name should be the first parameter, which currently also sets the classname.

Layout property in forms

Forms are by default displayed in single column rows, this is not always the best approach, for example sometimes it is useful to display related fields next to each other, for example first name and surname or street name and house number.
The current option is to create custom templates to display the fields in a custom way, but this can be overkill in most use cases.
A proposed solution to this is to add a layout property which describes the fields and how they should be positioned. Each field can also optionally specify how wide it should be using a scale from 1 to 12 or 'min' or 'max' (respectively shrink or expand as much as possible).

The layout property would be either a list or a dictionary (for multiple fieldsets).
Example 1 - first field full width in a row, then 2 fields evenly spaced in another row:

  layout = ('field1', ('field2', 'field3'))

Example 2 - first field half width in a row, then 2 fields in another row, the first expanded to use most of the space and the second shrunk to its minimum size.

layout = ('field1|6', ('field2|max', 'field3|min'))

Example 3 - using fieldsets, first fieldset is opened, the second and third are collapsed (by prepending '-'), second fieldset also has a description (after '|'):

layout = {
    'fieldset1': ('field1, field2'),
    '-fieldset2|some description here': ('field3', ('field4', 'field5')),
    '-fieldset3': ('field6, field7')
}

The layout property should be available as a mixin for FormView, UpdateView and CreateView.

Visual separation and title in Inlines

Hey there! I have tried the inlines, but I'm missing the possibility of adding a title to them (like Django Admin) and also a space of separation between the main model and the Inline. In the screenshot attached, the parent model finishes after 'modified', and the child model starts with 'marital_status'.

screen shot 2016-10-03 at 16 08 34

Possibility to define readonly fields in the detail views

It would be nice to be able to define read only fields in a list of field names, as this is a feature used in many models on a CMS.

For instance I have made a workaround on this by defining a base ModelForm, and using it as the view's form. The code looks like this:

class ReadOnlyModelForm(forms.ModelForm):

    def __init__(self, *args, **kwargs):
            if kwargs.get('instance') and hasattr(self.Meta, 'readonly_fields'):
                initial = kwargs.get('initial', {})
                for readonly_field in self.Meta.readonly_fields:
                    if readonly_field in self.base_fields:
                        # Define model disabled field
                        self.base_fields[readonly_field].disabled = True
                    elif readonly_field not in self.declared_fields:
                        # If not in base fields, it should be previously defined, otherwise raise exc
                        raise RuntimeError(
                            "The form does not have any field '{}' defined. Please define it.".format(
                                readonly_field
                            )
                        )

                    # Define initial value
                    initial[readonly_field] = getattr(kwargs['instance'], readonly_field, None)

            super(ReadOnlyModelForm, self).__init__(*args, **kwargs)

With this you can define a Model form like:

class SbUserForm(ReadOnlyModelForm):

    class Meta:
        model = SbUser
        fields = (
            'user',
            'user_type',
            'user_slug',
            'initials',
            'maiden_name',
            'gender',
            'dob',
            'birth_city',
            'current_city',
            'postal_code',
            'country',
            'phone',
            'mobile',
            'known_users',
        )
        readonly_fields = (
            'user_slug',
        )

Which is kind of convenient already, but forces us to define a ModelForm for every Model even if it's only to define a single read only field. If this could be done automatically at the view level it would be a great developer experience improvement. It would also prevent every Arctic user having to redefine the ReadOnlyModelForm again ;)

Please say if there is any simpler other approach that I may have missed.

Thanks!

Create flexible layout and article editor.

Read #89 first!

Articles and layouts consist of more than just text, we also need blocks (see ticket #89). To build your layout, you'll need to drag/drop these blocks (and edit them, see ticket #89).

Acceptance criteria:

  1. Are layouts and articles using the same base? Yes
  2. Can a user drag/drop blocks in an article? Yes
  3. Can a user drag/drop blocks in a layout? Yes
  4. Can a user save articles and layouts? Yes

I already started work on it, a proof of concept is available upon request.

Boolean filters in ListView

Whenever a boolean field is selected to be used as a filter, a dropdown with a placeholder "Unknown" and options "Yes" and "No" is created.
This is makes the option very unclear.
One solution would be to create a dropdown with the field name as a placeholder, '{field name}: Yes' and '{field name}: No' as options.
Other possible solution ideas are welcome!

Login redirect should preserve querystring params

Querystring params are truncated in the ?next= qs param that is used in the login page.

Probably having the entire original url, including qs params, in an url-encoded way will do.

Example:

[~:]$ curl -I http://admin-2.test.nu.nl/contributions/?foo=bar
HTTP/1.1 302 FOUND
Content-Type: text/html; charset=utf-8
Date: Mon, 01 Aug 2016 09:10:55 GMT
Location: http://admin-2.test.nu.nl/login/?next=/contributions/
Server: nginx
Vary: Cookie
X-Id: webnginx-001
Connection: keep-alive

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.