Git Product home page Git Product logo

django-blog-lotus's People

Contributors

sam-b0t avatar sveetch avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

thehawk3r

django-blog-lotus's Issues

Use pathlib instead of os

There may be some usage in code of os module for file path computation.

We should review code and migrate every usage of os module to pathlib Path.

Use 'sorl_thumbnail' instead of 'thumbnail'

Is your feature request related to a problem? Please describe.
Lotus use Smart Media which use Sorl.

Another common thumbnail library is Easy thumbnail which use the templatetag lib name thumbnail than Sorl, they do conflict, the latter one in settings.INSTALLED_APP will have its tag lib loaded. Resulting in error with template which use the tag lib that is not loaded, the argument syntax is different and so it raise exception.

Describe the solution you'd like
Use the explicit tag lib name sorl_thumbnail that mirror Sorl thumbnail tag lib. Also add a warning about it for project with Easy thumbnail.

Describe alternatives you've considered
We may try to allow for another tag library to be able to choose between Sorl and Easy thumbnail. Or we could just switch to Easy thumbnail if possible.

Additional context
This issue has been raised from installing Lotus into a project with CMS and Django filer that stands on Easy thumbnail. It may be something to fix from Smart media.

Improve Admin

  • List field displays;
  • Useful list filters;
  • Fieldset structure to group fields by theme (translation? parameters? status? content? relations? dates? etc);
  • How to preselect language ? Enforce a select input in form with choices builded from language setting;
  • Enforce FK and M2M choice limits (original language, related not self, categories languages);
  • Test coverage;

Move to zoneinfo instead of pytz

Is your feature request related to a problem? Please describe.
Django 4.0 included a move to zoneinfo instead of Pytz for timezone in datetime/time. Pytz support will be totally remove in Django 5.0

Describe the solution you'd like
Currently a transitional settings USE_DEPRECATED_PYTZ is used to keep pytz usage since we have Django<4.0 support that don't have the zoneinfo support.

We should drop this settings and move to zoneinfo usage instead of pytz everywhere it is directly used.

Describe alternatives you've considered
Including a support for both libraries would be too difficult to manage.

Enhancement for SEO fields in Article admin

  • Lead field should be moved into a SEO part in admin form, possibly at the end below content part;
  • Change lead field help to mention common usage in meta description;
  • Additional (and optional) "title" field for SEO usage: use it in meta title if not empty, else fallback to the common article title field;

Article model publication state method

Currently the publication state of an article is only implemented in manager and admin controller.

However, it may be useful to have this also from an Article object, so as a method available from Article model.

ArticleAdmin controller have a method "is_published" which should be ported to the model which then could be used everywhere, firstly from admin controller and also for "publication" filter for the admin change list.

Basic sandbox refinement

The basic layout is here but need some refinements for later:

  • Category limit in settings does not match anymore the category list layout which is now on 4 category by row, so it must be multiple of 4, i recommend a limit to 8 at least or 12 at maximum;
  • Migration to Bootstrap 5.1.x ?
  • Category detail content is not really styled, it's a little bit rude. It need basic styling;
  • Article states should be reflected with icon(accumulated? or keeping the most important one when there is multiple states?) (using Bootstrap icons);
  • Category and Article images are very basic blue squares, this never match any of available space. Article cover should be a little taller, Category cover may keep its square size, Article large image need something more large like an image for a Hero component. Finally, either each image have a different color (but will be a little ugly) or we create something more like common placeholder (grey image with its size written in or a text like "Article cover", etc..);
  • There is no breadcrumb #23;

Originally posted by @sveetch in #21 (comment)

Improve language features

Language are correctly modelized but actually not fully functionally implemented.

We need some helpers to add translation for enabled language, preselect original object and navigation.

Ideas:

  • Add contextual language navigation in detail views, such as an object with translation or an original should have language relation links in detail. Keep the main menu language switcher unchanged (returning to home);
  • User should be able to duplicate an original article to translate it, easily and without to create it from zero each time;
  • Helper link in edit admin view to go to other item translation when there at least one translation or original ?
  • Improve lotus_demo management command to create translations for each enabled languages;

Add CKEditor usage on content fields

If django-ckeditor is installed, admin forms should enable CKEditor usage on some fields like Category.description, Article.introduction and Article.content. But not Article.lead which is used for meta information, so keep it in plain text.

More failsafe demo maker

The lotus_demo command is making a lot of computation with articles and so require a minimum article length, however this is not enforced by validation or documentation.

Let's add some argument validation and improve command doc helps.

  • Minimal article length is around 7;
  • Add some mention about the factory usage which is not totally safe and can lead sometime to failure on unique constraints (like sometime the Author factory can try to use the same user name twice);

Admin mode URL argument is not adopted by links

Links in a page viewed with admin enabled (?admin=1) do not include it so you can look for a list with admin mode but some detail links may lead to 404 since the admin mode is not passed and so the detail will not find object with default queryset.

And also, we should think about another argument name than "admin" which can troubling, maybe something like "preview" ?

Add tags

Is your feature request related to a problem? Please describe.
Article only have categories to organize thematics.

Describe the solution you'd like
It is very common for weblog to have both categories and tags.

Also tags can be used for custom structure which need to find some objects with a criteria than is not the only one object criteria (opposed to article can have only one category).

Tags have been putted away during Lotus conception because django libraries did not looked nice or properly maintained, also tags works with complex queryset that will not be simple to include within lotus querysets.

At first, we need to review django tags libraries to find a proper one.

Describe alternatives you've considered
Living without tags is not critical but it's something that will definitively be asked many times.

Article constraint at db or programming level

Currently An Article can't have the same combination of slug, publish date and language, this is enforced at db level with a model constraint. This has been made because we plan to have Article detail url on this combination so user can create many Article with either the same slug or same date.

But if a developer want to change urls to display only the slug and not the date, the slug should be unique.

It could be possible to manage constraint in some validators which could be customized, but it may decrease performance against the db level way.. ?

Add REST API

This should be optional, enabled only when DRF is available. Add an extra requirement "api" to install DRF.

We aim for a read only API first. The write capacity may come in a future another issue.

This will need:

  • Article Serializers;
  • Category Serializers;
  • Author Serializers;
  • Article Viewsets;
  • Category Viewsets;
  • Author Viewsets
  • Pagination enabled;
  • Queryset have to respect the publication criterias and language;
  • API URLs have to live in their own map apart so it can be mounted outside Lotus views path;
  • API must be optional depending drf is installed or not (a new extra dependancies);
  • Tests depending drf is installed or not, so we can check with/without it through a Tox environment;
  • Look for possible resumed object payload in list and a more complete one from detail;

Add smart image feature

Alike in cmsplugin-block, it would add nice upload fields, image thumbnailer and svg support.

Publish time usage implementation in queryset may result to empty queryset

Usage of "publish_time" field in BasePublishedQuerySet.get_published (and get_unpublished) may sometime returns an empty queryset.

It does not happen in tests since we forced a fixed neutral datetime, it is only reproducible for now on frontend when running development server.

This is often raised during night around after midgnight. This is likely to be caused by the fact we use a combination of a date field and a time field which are not technically the same thing that a singular datetime in a queryset.

First thing it to create an unittest to reproduce this wrong behavior in test environment, then fix it.

Hash image filenames

It would be better if image filenames are a random hash instead of original name from upload.

Original filenames can have many exotic characters which can lead to some various issues and random hash is safer.

Translated object should inherit from some of original content

Is your feature request related to a problem? Please describe.
When creating a translation object from an original one, the create form is almost blank except the "orginal" relation.

Describe the solution you'd like
Category has nothing valuable to share with translation.

Article translation should inherit from states and publication dates because we can assume it should be identical on its visibility behaviors and the user should be aware enough to change these value for specific case.

Describe alternatives you've considered
Let this as it work currently, this is not a breaking issue but this is not really useful for users to apply again all the original value.

Lotus should works without i18n

Is your feature request related to a problem? Please describe.
Actually Lotus is not really ready to work on a non i18n project. More precisely, it is almost required to be mount on a i18n url pattern.

Describe the solution you'd like
Not everyone needs to use translated article or to serve different languages. Although it is a major feature from Lotus, it may be expected to be used without using i18n on url pattern or else.

I don't know yet how to do this technically, since all querysets require a language prefix, something will need to simulate the language middleware which set language to request context and just use the defaut language from settings.

Also, a settings could exists to disable the translation behavior like to hide the "original" field in admin.

Describe alternatives you've considered
Not any.

About Article modularity

Zinnia have a nice feature for Article model modularity with a setting to use a custom Article model to include or change basic features without to duplicate zinnia code as an "in project" application.

However it brings some more work and i don't know really yet how to test it correctly so i dropped it since it is not fundamental.

But it would be nice to think about it.

Non original article should not be choosable as an original article

In the article admin form, the "original" field list every other article, including the non original ones.

This does not seems correct to set a translation as an original article. Even it should work, this is not really logic and may perturb some display.

The field should be modified to only list article in another language and who have the "original" field empty (since this means the article is an original).

Admin date fields are localized in object language ?

If i create a new article with french language selected once saved the article detail form localizes the date field, something like 17/02/2021 but the form actually expected the english (or default site locale?) like 2021-02-17 and so the form is invalid.

Management commands are not shipped in package

Describe the bug
Installed Lotus into a project then tried to use command "lotus_demo" to add some demo data and Django failed to find it:

Unknown command: 'lotus_demo'
Type 'manage.py help' for usage.

Environment
Describe your environment:

  • Plateform: Linux distribution
  • Python version: 3.8
  • Django version: 4.0

To Reproduce

  1. Install lotus into a project
  2. Once properly installed, try to use command "lotus_demo"
  3. Django fails to find this command although Lotus is working and correctly installed;

Expected behavior
I would expect to be able to use the command.

When digging to find a reason, i found that the management directory is unexpectedly missing from build package. I installed Lotus 0.5.0 and lookup into the package from the same version as it is available from Pypi.

That's weird since this command exist since before the 0.5.0.

SVG support

Describe the bug
Trying to upload a SVG file in any image field in an article or category return a form validation error:

Upload a valid image. The file you uploaded was either not an image or a corrupted image.

Despite the SVG created from Demo are properly saved and working on frontend.

Environment
Describe your environment:

  • Plateform: Linux
  • Python version: 3.8
  • Django version: 4.0

However this should be an issue on any plateform, Python and Django versions.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the create/edit form for Article or Category
  2. Fill required fields and at least one image field with a SVG file
  3. Submit form
  4. Form validation return an error

Expected behavior
SVG file support was thought to be ok since the demo create some ones. But SVG does not seems to be explicitely tested on model, however the model itself may not perform any validation, it may be only done from form validator (this is something to ensure). And so this issue was hided until some front tests have been done.

So finally the expected behavior is that we should be able to upload SVG files.

This is a well known problem that ImageField does not support SVG since it validate file with PIL. A workaround is to use FileField instead with a basic file extension/mime validator to reject non image files.

Implementation of smart image management from #11 should resolve this since it was its first purpose.

Add Category.lead field

Alike Article.lead it will be plain text dedicated to meta information in Category detail page.

Category tree

Is your feature request related to a problem? Please describe.
There is only a single level of categories.

Describe the solution you'd like
Category could have a parent category and so a category could have many category children.

This would result to a tree of categories. It is very basic to implement in model but more difficult to implement well in rendering and views.

We will need some performant enough code to render a category tree without making too many big querysets.

Did Category URL will have to consume multiple name to get a high URI ? This would need to validate every category name for correct relationship. Like for "Camembert" category, with parent category "Cheese", the url could be /cheese/camembert/.

There may be some missing points for this subject yet.

Add 'translate' button to object detail

Is your feature request related to a problem? Please describe.
Currently, the "Translate" button is only available from the Django admin detail view.

Describe the solution you'd like
Object detail view in frontend already have an "Edit" button, we could add the "Translate" button also just below to ease translation (it just avoid a single click but could be worth).

Describe alternatives you've considered
Nothing.

Make a Django-CMS plugin in a contrib application

Is your feature request related to a problem? Please describe.

One of Lotus goal is to integrate properly with DjangoCMS as an optional feature. Although it works well, it lacks of
CMS plugins and CMS apphook to fully integrate.

Describe the solution you'd like

We need to do so in an additional and optional package like "djangocms-lotus" that will:

  • have a CMS plugin to include articles in a cms page;
  • have a CMS plugin to include category list in a cms page;
  • have a CMS apphook to integrate Lotus as a CMS page;
  • perform again the admin override that seems overwritten by admin-style, currently it results on Article and Category change form in admin to lack of additional buttons for translation and preview;

Describe alternatives you've considered
Include this in Lotus package itself, it would seem easier to do but won't viable on long term maintenance (cms part needs to fit to CMS versions support but Lotus has its own life that would conflict in the same package).

Improve Article and Category admin listing

Article and category list admin view would be better within a tree where first level is for original language item only and then add their translation as children ?

Well at least something which make the listing more readable and clear.

This should be implemented in a new change list screen and the basic one from Django admin should be keeped, so user can switch to it if needed.

Make admin mode configurable from settings

Admin mode context var and url argument name are set from here:

adminmode_argument_name = "admin"

However this should be configurable from settings to avoid possible conflict with other apps, since "admin" is a very common word.

There is also probably some few other code part elsewhere which may use directly "admin" word for "admin mode" feature, at least in the admin forms and tests.

Images from non public articles should be protected

Is your feature request related to a problem? Please describe.
Currently image from draft/private/non published are just reachable from anyone that know its link.

Although it is planned to hash media filename, which will make it impossible to guess, this is not a solution since the link can still be shared or used elsewhere.

Describe the solution you'd like
Media from non public articles should be protected. The more obvious solution is to implement the common "sendfile" method for webservers, like with django-sendfile2

Fix responsive in sandbox

Describe the bug
Sandbox layout has been quickly done and ignored responsive, result is that sandbox layout is a little broke in mobile resolutions.

This happen almost everywhere, not everything is broken but almost all page have problems like detail image too wide, grid list missing responsive classes, etc..

Environment
Describe your environment:

  • Lotus: 0.5.0-pre.2
  • Plateform: Any
  • Python version: Any
  • Django version: Any

To Reproduce
Steps to reproduce the behavior:

  1. Browse anywhere on lotus pages;
  2. Turn the browser in responsive mode (like with CTRL + SHIFT + m)
  3. Set the width to something between 320px and 800px (it happen on larger resolutions too but this is less visible);
  4. Layout is broken

Expected behavior
Sandbox layout should be fully responsive.

We could just use the right responsive classes on grid everywhere and enable a default responsive behavior for image maximum width (since Bootstrap avoid it).

Improve basic sandbox

Currently it's just basic raw HTML sample, but it start to be hard to use even just for development.

A very basic styling would be good, with a simple header, top level menu, language chooser and better article and category layout.

  • Add Bootstrap
  • Put a basic layout on everything with Bootstrap components;
  • Prefix article states (article--)
  • Fix tests for new prefixes
  • Ensure tests are working well after putting layout and ensure they are not so much troubled when layout change (avoid direct selector, only select element through internal classes)

Cannot access images in documentation overview

Image is not accessible: only preview is shown.

Steps to reproduce the behavior:

  1. Go to documentation
  2. Click on any image in #demonstration

Expected behavior:
On click, browser should redirect to full size image.

Possible solution:
Provide link to /docs/_static/demo/<an_image>

Add special tests for environment or feature cases

For some specific cases depending from packages or low level configuration, it is too difficult to test it correctly in the base test suite.

It would be helpful to make other specific test suites to run explicitely (with a new make "test-something" action) and its own test settings file.

This is not currently required but writed here for possible further feature.

Category detail sidebar

Is your feature request related to a problem? Please describe.
Opposed to Article detail, the category one does not have any sidebar. It was left out since category does not have many information to display like an Article.

Describe the solution you'd like
However a Category have language version too and they are not displayed in detail. Also since there is no sidebar, an Edit button has not been added too.

Describe alternatives you've considered
It may not be a formal sidebar, something could work too, it just have to be as ergonomic as the sidebar is.

Watch for DAL update with dark mode support

Is your feature request related to a problem? Please describe.
Current django-autocomplete-light (DAL) version (3.9.4) is not yet compatible Django admin and dark mode.

So for now, we included the following patch in templates/admin/lotus/article/change_form.html :

yourlabs/django-autocomplete-light#1308

Describe the solution you'd like
A new DAL release which should include the dark mode support from PR1308. Once released we will upgrade requirement to this new version then remove the backported fix from "change_form" template.

Describe alternatives you've considered
Keeping the patch in the template, but if DAL does not update anymore, it should be removed from requirements because we won't attach Lotus to an unmaintained application.

'Available in languages' from object detail should indicate publication status

Is your feature request related to a problem? Please describe.
Currently, the menu "Available in languages" from article detail sidebar display all available language versions. Respecting the publication criteria, a lambda user does not see the non published ones and admin can see everything.

Describe the solution you'd like
Language versions that are not published yet should indicate it, either by the way of an icon, its status or a tiny accurate help text so admins does not have to click every versions to check for their publication status.

Describe alternatives you've considered
Keeping it without any indication is not critical but not very useful.

Add Breadcrumbs

There is currently no breadcrumbs, i could make it almost hardcoded in templates using a block and block.super, but it may not be the best way.

However i'm not sure this is the most urgent thing to develop a little module to manage breadcrumbs from code (likerly used in a templatetag).

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.