From f9368ca594b2fb884c6e01052547c888dc75c84e Mon Sep 17 00:00:00 2001 From: Seva D Date: Wed, 20 Nov 2024 23:04:49 +0300 Subject: [PATCH] Fix password (#78) Fix password --- docs/build.py | 6 ++++ docs/index.html | 23 ++++++++++-- examples/fastapi_sqlalchemy/example.py | 1 - examples/fastapi_tortoiseorm/example.py | 1 - fastadmin/models/base.py | 19 ++++++++++ fastadmin/static/index.min.js | 36 +++++++++---------- .../components/password-input/index.test.tsx | 2 +- .../src/components/password-input/index.tsx | 8 ++--- pyproject.toml | 2 +- 9 files changed, 69 insertions(+), 29 deletions(-) diff --git a/docs/build.py b/docs/build.py index 36424c3..93602df 100644 --- a/docs/build.py +++ b/docs/build.py @@ -39,6 +39,12 @@ def read_cls_docstring(cls): def get_versions(): return [ + { + "version": "0.2.15", + "changes": [ + "Fix password logic for user.", + ], + }, { "version": "0.2.14", "changes": [ diff --git a/docs/index.html b/docs/index.html index 9dbde3a..ff841e8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,7 +2,7 @@
  • - -->

    FastAdmin | Documentation

    • Created: 7 March 2023
    • Updated: 20 November 2024

    Introduction

    FastAdmin is an easy-to-use Admin Dashboard App for FastAPI/Django/Flask inspired by Django Admin.

    FastAdmin was built with relations in mind and admiration for the excellent and popular Django Admin. It's engraved in its design that you may configure your admin dashboard for FastAPI/Django/Flask easiest way.

    FastAdmin is designed to be minimalistic, functional and yet familiar.


    Getting Started

    If you have any questions that are beyond the scope of the documentation, Please feel free to email us.

    Installation

    Follow the steps below to setup FastAdmin:

    Install the package using pip:

    Note: For zsh and macos use: pip install fastadmin[fastapi,django]

    +              -->  

    FastAdmin | Documentation

    • Created: 7 March 2023
    • Updated: 20 November 2024

    Introduction

    FastAdmin is an easy-to-use Admin Dashboard App for FastAPI/Django/Flask inspired by Django Admin.

    FastAdmin was built with relations in mind and admiration for the excellent and popular Django Admin. It's engraved in its design that you may configure your admin dashboard for FastAPI/Django/Flask easiest way.

    FastAdmin is designed to be minimalistic, functional and yet familiar.


    Getting Started

    If you have any questions that are beyond the scope of the documentation, Please feel free to email us.

    Installation

    Follow the steps below to setup FastAdmin:

    Install the package using pip:

    Note: For zsh and macos use: pip install fastadmin[fastapi,django]

       
     
     pip install fastadmin[fastapi,django]  # for fastapi with django orm
    @@ -1140,6 +1140,25 @@
             """
             raise NotImplementedError
     
    +    async def save_model(self, id: UUID | int | None, payload: dict) -> dict | None:
    +        """This method is used to save orm/db model object.
    +
    +        :params id: an id of object.
    +        :params payload: a payload from request.
    +        :return: A saved object or None.
    +        """
    +        obj = await super().save_model(id, payload)
    +        fields = self.get_model_fields_with_widget_types(with_m2m=False, with_upload=False)
    +        password_fields = [field.name for field in fields if field.form_widget_type == WidgetType.PasswordInput]
    +        if obj and id is None and password_fields:
    +            # save hashed password for create
    +            pk_name = self.get_model_pk_name(self.model_cls)
    +            pk = obj[pk_name]
    +            password_values = [payload[field] for field in password_fields if field in payload]
    +            if password_values:
    +                await self.change_password(pk, password_values[0])
    +        return obj
    +
       
     

    Form Field Types

    There are form field types for model admin:

       
    @@ -1282,7 +1301,7 @@
         min_num: int = 1
     
       
    -

    Changelog

    See what's new added, changed, fixed, improved or updated in the latest versions.

    v0.2.14

    Make permissions functions awaitable. Bump frontend/backend packages.

    v0.2.13

    Fix edit page frontend issue for Date field.

    v0.2.12

    Remove python-dotenv dep. Bump django. Add django example.

    v0.2.11

    Fixes for examples. Fixes for Pony ORM (delete, update m2m). Allow sorting by custom columns. Fix for list_display ordering.

    v0.2.10

    Fix issue empty m2m. Optimisation on unit tests. Fix for pony orm. Optimisation on search for tortoise orm.

    v0.2.9

    Fix issue with modal inline dialogs. Fix issue with m2m multiple select.

    v0.2.8

    Fix sqlalchemy delete functionality. Add more examples.

    v0.2.7

    Fix helpers function. Add regexps.

    v0.2.6

    Add edit btn for async select.

    v0.2.5

    Fix for async select in inlines.

    v0.2.4

    Fix dashboard widgets and auto register inlines.

    v0.2.3

    Fix filters issue on lists. Remove jinja from dependencies.

    v0.2.2

    Fix bugs with datetime.

    v0.2.1

    Update packages. Fix linters and tests in vite frontend. Removed pydantic from dependencies.

    v0.2.0

    Update packages. Use vite instead obsolete react-scripts.