Skip to main content

BaseApp Blocks

Project description

BaseApp Blocks

Reusable app to enable any model block/unblock any model.

Requirements:

- **baseapp-core** >= 0.2.3

Run pip install baseapp-blocks And make sure to add the frozen version to your requirements/base.txt file

If you want to develop, install using this other guide.

How to use

Add baseapp_blocks to your project's INSTALLED_APPS

Add baseapp_blocks.permissions.BlocksPermissionsBackend to the AUTHENTICATION_BACKENDS list in your django settings file.

Now make sure all models you'd like to get blocks also inherits BlockableModel, like:

from baseapp_blocks.models import BlockableModel

class User(models.Model, BlockableModel):

Also make sure your GraphQL object types extends BlocksInterface interface:

from baseapp_blocks.graphql.object_types import BlocksInterface

class UserNode(DjangoObjectType):
    class Meta:
        interfaces = (relay.Node, BlocksInterface)

Expose BlocksMutations in your GraphQL/graphene endpoint, like:

from baseapp_blocks.graphql.mutations import BlocksMutations

class Mutation(graphene.ObjectType, BlocksMutations):
    pass

schema = graphene.Schema(query=Query, mutation=Mutation)

This will expose blockToggle mutation and add fields and connections to all your GraphqlQL Object Types using interface BlocksInterface.

Example:

    mutation BlockButtonMutation($input: BlockToggleInput!) {
        blockToggle(input: $input) {
            block {
                node {
                id
                }
            }
            target {
                id
                blockersCount
                isBlockedByMe
            }
            actor {
                id
                blockingCount
            }
        }
    }

How to develop

Clone the project inside your project's backend dir:

git clone git@github.com:silverlogic/baseapp-backend.git

And manually install the package:

pip install -e baseapp-backend/baseapp-blocks

The -e flag will make it like any change you make in the cloned repo files will effect into the project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

baseapp-blocks-0.0.7.tar.gz (10.3 kB view details)

Uploaded Source

File details

Details for the file baseapp-blocks-0.0.7.tar.gz.

File metadata

  • Download URL: baseapp-blocks-0.0.7.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for baseapp-blocks-0.0.7.tar.gz
Algorithm Hash digest
SHA256 48286b78093dd59b78bf351920b4bb8586ab1f35ceabf07f821d549fdf2fe922
MD5 26e13f5d8f90b5736eb333bffac6da4e
BLAKE2b-256 e3dcb0a8ea54506b8ed8291f7c0dc26d2056f40813983e7f01a1cb0d27e510e6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page