Git Product home page Git Product logo

djangocms-file's Introduction

django CMS File

pypi build coverage python django djangocms

django CMS File is a set of plugins for django CMS that allow you to add files to your site You can either choose a single file or an entire folder.

It uses files managed by Django Filer.

This addon is compatible with Divio Cloud for easy installation.

image

Contributing

This is a an open-source project. We'll be delighted to receive your feedback in the form of issues and pull requests. Before submitting your pull request, please review our contribution guidelines.

We're grateful to all contributors who have helped create and maintain this package. Contributors are listed at the contributors section.

One of the easiest contributions you can make is helping to translate this addon on Transifex.

Documentation

See REQUIREMENTS in the setup.py file for additional dependencies:

  • Django Filer 1.7 or higher

Make sure django-filer is installed and configured appropriately.

Installation

For a manual install:

  • run pip install djangocms-file
  • add djangocms_file to your INSTALLED_APPS
  • run python manage.py migrate djangocms_file

Configuration

Note that the provided templates are very minimal by design. You are encouraged to adapt and override them to your project's requirements.

This addon provides a default template for all instances. You can provide additional template choices by adding a DJANGOCMS_FILE_TEMPLATES setting:

DJANGOCMS_FILE_TEMPLATES = [
    ('feature', _('Featured Version')),
]

You'll need to create the feature folder inside templates/djangocms_file/ otherwise you will get a template does not exist error. You can do this by copying the default folder inside that directory and renaming it to feature.

Running Tests

You can run tests by executing:

virtualenv env
source env/bin/activate
pip install -r test_requirements/base.txt
python setup.py test

Updating from cmsplugin-filer

Historically, cmsplugin-filer was used to create file, folder, image, link, teaser & video plugins on your django CMS projects. Now cmsplugin-filer has been archived, you can still migrate your old instances without having to copy them manually to the new djangocms-<file|picture|link|...> plugins.

There's a third-party management command that supports your migration:

migrate_cmsplugin_filer.py

This management command is only a starting point. It has worked out of the box for some people, but we encourage you to read the code, understand what it does, and test it on a development environment before running it on your production server.

The management command is only configured to transfer your cmsplugin_link, cmsplugin_file, cmsplugin_folder and cmsplugin_image plugins to modern djangocms_* plugins. If you need to transfer other cmsplugin_* plugins, you'll have to write your own code.

Alternatively you can use the deprecate_cmsplugin_filer app, which only adds a small migration that transfer the old cmsplugin-filer plugins instances to the new djangocms-<file|picture|link|...> plugins.

djangocms-file's People

Contributors

bashu avatar bplociennik avatar chive avatar corentinbettiol avatar czpython avatar digi604 avatar finalangel avatar fsbraun avatar marksweb avatar mkoistinen avatar multigl avatar stefanfoulis avatar vstoykov avatar vthaian avatar vxsx avatar yakky 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

Watchers

 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

djangocms-file's Issues

Django 3.2 or greater support?

Since django 3.2 is the LTS version, are there any plans to update to support it, or does anyone know if it already works with django 3.2 or greater?

AbstractFile - search_fields = ('name',)

Hello,

I have a problem with ALDRYN_SEARCH and DJANGOCMS_FILE.

During handling of the above exception ('name'), another exception occurred

I guess that problem could be here in "djangocms_file/models.py":

class AbstractFile(CMSPlugin):
    search_fields = ('name',)

    file_name = models.CharField(
        verbose_name=_('Name'),
        blank=True,
        max_length=255,
        help_text=_('Overrides the default file name with the given value.'),
    )

Couldn't be here
search_fields = ('file_name',)
??

Two 0005 migrations and failing tests on Python 3

There are two migrations numbered 0005 0005_auto_20160119_1534.py and 0005_password_reset_email_sent.py. They aren't the same.

--- 0005_auto_20160119_1534.py  2016-09-29 15:27:54.144027471 +0000
+++ 0005_password_reset_email_sent.py   2016-05-09 14:47:11.454822660 +0000
@@ -14,6 +14,6 @@
         migrations.AlterField(
             model_name='file',
             name='target',
-            field=models.CharField(blank=True, max_length=100, choices=[('', 'same window'), ('_blank', 'new window'), ('_parent', 'parent window'), ('_top', 'topmost frame')], help_text='Optional link target.', default='', verbose_name='target'),
+            field=models.CharField(verbose_name='target', default='', choices=[('', 'same window'), ('_blank', 'new window'), ('_parent', 'parent window'), ('_top', 'topmost frame')], help_text='Optional link target.', max_length=100, blank=True),
         ),
     ]

Also, some tests which pass fine on Python 2.7 don't pass on Python 3.4 due to an apparent conflict between migrations 0005_password_reset_email_sent.py and 0010_removed_null_fields.py:

+(gold_py2) vagrant@vagrant-ubuntu-trusty-64:/vagrant$ py.test --create-db accounts
Test session starts (platform: linux2, Python 2.7.6, pytest 3.0.2, pytest-sugar 0.7.1)
Django settings: gold.test_settings (from ini file)
rootdir: /vagrant, inifile: pytest.ini
plugins: django-3.0.0, sugar-0.7.1

 accounts/tests/test_cron.py ✓✓                                                                                                                                                                                                 10% ▉         
 accounts/tests/test_domain.py ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓                                                                                                                                                                                  81% ████████▏ 
 accounts/tests/test_serializers.py ✓✓✓                                                                                                                                                                                         95% █████████▌
 accounts/tests/test_tokens.py ✓                                                                                                                                                                                               100% ██████████

Results (93.24s):
      21 passed
+(gold_py2) vagrant@vagrant-ubuntu-trusty-64:/vagrant$ workon gold_py3

+(gold_py3) vagrant@vagrant-ubuntu-trusty-64:/vagrant$ py.test --create-db accounts
Test session starts (platform: linux, Python 3.4.3, pytest 3.0.2, pytest-sugar 0.7.1)
Django settings: gold.test_settings (from ini file)
rootdir: /vagrant, inifile: pytest.ini
plugins: django-3.0.0, sugar-0.7.1


―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ERROR at setup of test_send_password_reset_reminder ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
/home/vagrant/.virtualenvs/gold_py3/lib/python3.4/site-packages/pytest_django/plugin.py:375: in _django_db_marker
    request.getfuncargvalue('db')
/home/vagrant/.virtualenvs/gold_py3/lib/python3.4/site-packages/pytest_django/fixtures.py:96: in django_db_setup
    **setup_databases_args
/home/vagrant/.virtualenvs/gold_py3/lib/python3.4/site-packages/django/test/runner.py:370: in setup_databases
    serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
/home/vagrant/.virtualenvs/gold_py3/lib/python3.4/site-packages/django/db/backends/base/creation.py:368: in create_test_db
    test_flush=not keepdb,
/home/vagrant/.virtualenvs/gold_py3/lib/python3.4/site-packages/django/core/management/__init__.py:120: in call_command
    return command.execute(*args, **defaults)
/home/vagrant/.virtualenvs/gold_py3/lib/python3.4/site-packages/django/core/management/base.py:445: in execute
    output = self.handle(*args, **options)
/home/vagrant/.virtualenvs/gold_py3/lib/python3.4/site-packages/django/core/management/commands/migrate.py:105: in handle
    "'python manage.py makemigrations --merge'" % name_str
E   django.core.management.base.CommandError: Conflicting migrations detected (0010_removed_null_fields, 0005_password_reset_email_sent in djangocms_file).
E   To fix them run 'python manage.py makemigrations --merge'
----------------------------------------------------------------------------------------------------------- Captured stderr setup ------------------------------------------------------------------------------------------------------------

My guess is the two things are probably related. It could be that on Py2, it's 'randomly' picking one of the two 0005 migrations, and on Py3, it's 'randomly' picking the other. And that's what causing the conflict.

This isn't an issue on djangocms_file==1.0 but is an issue on djangocms_file==2.0.1.

Upgrading from version 0.0.1

Can you provide directions on how to migrate from 0.0.1 version of the plugin with lots of data to 0.1?

Django has been upgraded to 1.7 from 1.6, south is commented out and entry also added to MIGRATION_MODULES. Django CMS version is 3.0.12

makemigrations returns with the message "No changes detected in app 'djangocms_file'"

manage.py migrate/check error

Hi,
I'm working through the django-cms tutorial with Django 4.2.6, django-cms 3.11.4 and django-filer 3.1.0

I ran: pip install djangocms-file, then added 'djangocms_file' to INSTALLED_APPS, but could not migrate because of this error:

djangocms_file.File.file_src: (fields.E300) Field defines a relation with model 'File', which is either not installed, or is abstract.
djangocms_file.Folder.folder_src: (fields.E300) Field defines a relation with model 'Folder', which is either not installed, or is abstract.

I got similar errors for djangocms-link, djangocms-picture, djangocms-video and djangocms-googlemap.
I didn't get any errors for djangocms-snippet or djangocms-style.

I'm running Python 3.10.12 on Ubuntu 20.04

Best,
Dow

Model field name clash in django 1.9

Now that CMS 3.2.1 supports django 1.9, I gave it a try. Unfortunately, this plugin will not work.

The error I am getting is:

ERRORS:
djangocms_file.File.file: (models.E006) The field 'file' clashes with the field 'file' from model 'cms.cmsplugin'.

This happens because djangocms_file.File inherits from CMSPlugin. So then CMSPlugin will have an implicit OneToOneField back to djangocms_file.File, and it will be the lowercased version of the File class. (file) Then, the File class contains a file field of itself. So it is basically clashing with itself.

I am not sure why this didn't break before django 1.9. I'm guessing django used to not check for that?

Django CMS's docs even warn about doing this at http://docs.django-cms.org/en/develop/how_to/custom_plugins.html#storing-configuration:

You cannot name your model fields the same as any installed plugins lower- cased model name, due to the implicit one-to-one relation Django uses for sub-classed models.

Tooltip for a file link

We use the file plugin and end users would like to be able to specify a tooltip which should be shown above a link to the file.

Is it possible with the file plugin? If not, do you think we can add this feature (send a pull request)?

Do not install tests

--- setup.py.orig	2018-11-13 07:08:58.000000000 +0000
+++ setup.py
@@ -41,7 +41,7 @@ setup(
     url='https://github.com/divio/djangocms-file',
     license='BSD',
     long_description=open('README.rst').read(),
-    packages=find_packages(),
+    packages=find_packages(exclude=['tests']),
     include_package_data=True,
     zip_safe=False,
     install_requires=REQUIREMENTS,

djangocms_file.0006_migrate_to_filer...Traceback (most recent call last):

I'm trying to update djangocms_file (and alls djangocms_* plugins) from version 1.0 to the last one, that use django_filer and easy_thumbnails under the hoods.

When I launch python manage.py migrate, I get this error:

bash
File "/Library/Python/2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.OperationalError: (1060, "Duplicate column name 'file_src_id'")

here my current migrations status:
python
djangocms_file
[X] 0001_initial
[X] 0002_auto_20151202_1551
[X] 0003_remove_related_name_for_cmsplugin_ptr
[X] 0004_set_related_name_for_cmsplugin_ptr
[X] 0005_auto_20160119_1534
[ ] 0006_migrate_to_filer
[ ] 0007_adapted_fields
[ ] 0008_add_folder
[ ] 0009_fixed_null_fields
[ ] 0010_removed_null_fields
python

in this phase, I'm updating django-cms to 3.4 too.

Selecting a file opens the change form

I'm just looking at integrating the file plugin, but I'm having an issue with filer opening the change form for a file instead of selecting the file to use.

Comparing what I've got with the CMS demo, the 'choose file' window for me is a full filer admin view, but on the demo it's more of a filer specific thing.

screen shot 2017-12-22 at 15 30 53 2

I don't think there are any template overrides or anything like that, so any ideas what's causing this?

Django==1.10.8
django-cms==3.4.5
djangocms-file==2.0.2

Download missing from PyPI

Looks like this package has been registered but not uploaded:

$ pip install djangocms-file
Downloading/unpacking djangocms-file
  Could not find any downloads that satisfy the requirement djangocms-file
...

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.