Skip to content

nonamesec/OneSilaHeadless

Repository files navigation

codecov

OneSila Headless Backend

Quickstart

Install dependencies:

virtualenv venv
source venv/bin/active

pip install -r requirements.txt

Create your local settings:

cp OneSila/settings/local_template.py OneSila/settings/local.py

And create a postgres db + set the settings in your local.py setting file. Also add CORS settings to your local file.

CORS_ALLOWED_ORIGINS = [
    "http://localhost:5173",  # check the right port from your frontend npm run dev.
]

Next, migrate your db:

./manange.py migrate

Viewing docs

Docs are housed inside of the docs folder. You can view them easily by running mkdocs serve like so:

source venv/bin/active
mkdocs serve
# Now open: http://127.0.0.1:8000

Graphql

Getting data out of - and putting in - is done using graphql. eg, creating a company via (graphiql)[http://127.0.0.1:8080/graphql/]:

mutation createCompany {
  createCompany(data: {name: "Company ltd"}) {
    id
    name
    multiTenantCompany{
      name
    }
  }
}

will yield:

{
  "data": {
    "createCompany": {
      "id": "Q29tcGFueVR5cGU6OQ==",
      "name": "Company ltd",
      "multiTenantCompany": {
        "name": "Owner"
      }
    }
  }
}

You can also subscribe to it's updates:

subscription companySubscriptionClass {
  company(pk: "Q29tcGFueVR5cGU6OQ==") {
    id
    name
    createdAt
    updatedAt
  }
}

will yield:

{
  "data": {
    "company": {
      "id": "Q29tcGFueVR5cGU6OQ==",
      "name": "Company ltd",
      "createdAt": "2023-10-03T16:11:21.900275+00:00",
      "updatedAt": "2023-10-03T16:11:21.900310+00:00"
    }
  }
}

Importing images via GraphQL

Images can be uploaded in bulk by calling the uploadImagesFromUrls mutation. Each entry accepts the image URL, type, and an optional title:

mutation uploadImagesFromUrls {
  uploadImagesFromUrls(
    urls: [
      { url: "https://example.com/product.jpg", type: "PACK", title: "Front shot" }
    ]
  ) {
    id
    title
  }
}

Running tests

Runings tests, including coverage:

coverage run --source='.' manage.py test

To see the results

coverage report -m

Or with html

coverage html

Supported Currencies

The list of available currencies can be found in currencies/currencies.py. Each entry contains the ISO code, human readable name and symbol. Recent additions include codes such as AFN (Afghan Afghani) and CHF (Swiss Franc).

About

Public mirror of OneSila/OneSilaHeadless (upstream deleted from github.com). Used by source_code_analysis_llm test fixture P_54 (Python/Django/Strawberry framework traversal). Pinned commit: 7ead0ec.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages