Giter Club home page Giter Club logo

django-nacl-fields's People

Contributors

atezet avatar defrex avatar ebpmp avatar gimbo avatar matthijswendelaar avatar obrienmd avatar roaldnefs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

django-nacl-fields's Issues

Contributing section in the README

A contributing section in the README would be nice. I made a short draft for you:

Contributing

Start a postgres Docker container for testing using:

docker run --rm -e POSTGRES_PASSWORD=postgres POSTGRES_DB=github_actions postgres

Then, you can run tests in another window using:

virtualenv env
source env/bin/activate
pip install '.[test]'
python manage.py test

Before you contribute, make sure you lint your code:

pip install '.[lint]'
flake8 --exclude .git,pycache,docs/conf.py,build,dist,env

After your code is done, feel free to open a PR.

NaClFieldMixin does not work with JSONField

Because of json parsing inside from_db_value method when loading data, you end up with the raw json string instead of the python object.

I wrote this as a fix, however there might be better ways.

class NaClJSONField(NaClFieldMixin, models.JSONField):
    def from_db_value(self, value, expression, connection, *args, **kwargs):
        if value is not None:
            value = bytes(value)
            if value != b'':
                value = self._crypto_box.decrypt(value)

            # JSONField does conversion from JSON to python object in this method.
            # so we need to extend the NaCl mixin
            value = force_text(value)
            if isinstance(expression, KeyTransform) and not isinstance(value, str):
                return value
            try:
                value = json.loads(value, cls=self.decoder)
            except json.JSONDecodeError:
                pass

            return super(NaClFieldMixin, self).to_python(value)

New release

Would it be possible for you to deploy a new release of the project to pypi? Those of us using Django 4 still has to install the project from git, which isn't ideal.

Thanks!

Django 4.0 Support

Hi,

I noticed that there is a small incompatibility with Django 4 in the library. The deprecated function force_text needs to be replaced with force_str, as the function has been removed in Django 4. Other than that, the library seems to work fine with Django 4, so it should be simple to add official support to the library.

Let me know if you want me to create a PR.

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.