Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

volumes:
pip-dir:

services:
build:
image: python:3.10-buster
volumes:
- pip-dir:/pip_dir
- .:/open-needs-server
working_dir: /open-needs-server
healthcheck:
test: test -f /pip_dir/bin/ons || exit 1
interval: 5s
timeout: 10s
retries: 6
environment:
PYTHONUSERBASE: /pip_dir
command:
- /bin/bash
- -c
- |
python3 -m pip install --user . --upgrade
while true;
do sleep 30
done
backend:
image: python:3.10-buster
ports:
- 9595:9595
network_mode: "host"
networks: []
configs: []
volumes:
- pip-dir:/pip_dir
- .:/open-needs-server # still need the settings.toml file at runtime
working_dir: /open-needs-server
depends_on:
build:
condition: service_healthy
environment:
PYTHONPATH: /pip_dir/lib/python3.10/site-packages:$PYTHONPATH
PATH: /pip_dir/bin:$PATH
command: ons

2 changes: 1 addition & 1 deletion docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Documentation build

.. code-block:: bash

pip install -r requirements/docs.txt
python3 -m pip install .[docs]
cd docs
make html
5 changes: 1 addition & 4 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,5 @@ From source

git clone git@github.com:open-needs/open-needs-server.git
cd open-needs-server
pip install -e .
python3 -m pip install .
ons



4 changes: 2 additions & 2 deletions open_needs_server/extensions/domain/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ async def get_domains(db: AsyncSession, skip: int = 0, limit: int = 100):


async def create_domain(db: AsyncSession, domain: DomainSchema):
cursor = await db.execute(insert(DomainModel), domain)
cursor = await db.execute(insert(DomainModel).values(**domain).returning(DomainModel.id))
await db.commit()
domain_id = cursor.inserted_primary_key[0]
domain_id = cursor.fetchone()[0]
return {**domain, "id": domain_id}


Expand Down
4 changes: 2 additions & 2 deletions open_needs_server/extensions/need/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ async def create_need(ext: ONSExtension, db: AsyncSession, need: NeedReturnSchem
data = ext.fire_event("need_create", {"need": need, "project": db_project})
need = data["need"]

cursor = await db.execute(insert(NeedModel), need)
cursor = await db.execute(insert(NeedModel).values(**need).returning(NeedModel.id))
await db.commit()
need_id = cursor.inserted_primary_key[0]
need_id = cursor.fetchone()[0]

need = ext.fire_event("need_create_done", need)

Expand Down
6 changes: 3 additions & 3 deletions open_needs_server/extensions/ons_admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import importlib
import logging
from sqladmin import Admin, ModelAdmin
from sqladmin import Admin, ModelView

from open_needs_server.extensions.base import ONSExtension
from open_needs_server.database import engine
Expand All @@ -24,7 +24,7 @@ def __init__(self, *args, **kwargs):
self.admin = Admin(self.ons_app, engine)

for admin_model in self._get_models():
self.admin.register_model(admin_model)
self.admin.add_view(admin_model)

def _get_models(self):
models = []
Expand All @@ -49,7 +49,7 @@ def _get_models(self):

new_class = types.new_class(
name=f"{class_str}Admin",
bases=(ModelAdmin,),
bases=(ModelView,),
kwds={"model": clazz},
exec_body=lambda ns: ns.update(
{
Expand Down
4 changes: 2 additions & 2 deletions open_needs_server/extensions/organization/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ async def create_organization(
ext: ONSExtension, db: AsyncSession, organization: OrganizationCreateSchema
):
organization = ext.fire_event("org_create", organization)
cursor = await db.execute(insert(OrganizationModel), organization)
cursor = await db.execute(insert(OrganizationModel).values(**organization).returning(OrganizationModel.id))
await db.commit()
organization_id = cursor.inserted_primary_key[0]
organization_id = cursor.fetchone()[0]
new_organization = {**organization, "id": organization_id}
new_organization = ext.fire_event("org_create_done", new_organization)
return new_organization
Expand Down
9 changes: 7 additions & 2 deletions open_needs_server/extensions/project/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ async def create_project(db: AsyncSession, project: ProjectSchema):
raise HTTPException(404, detail=f"Unknown domain id: {domain_id}")
domains_db.append(domain_db)

cursor = await db.execute(insert(ProjectModel), project)

project = {
"title": project["title"],
"organization_id": project["organization_id"]
}
cursor = await db.execute(insert(ProjectModel).values(**project).returning(ProjectModel.id))
await db.commit()
project_id = cursor.inserted_primary_key[0]
project_id = cursor.fetchone()[0]
project_db = await get_project(db, project_id)
project_db.domains = domains_db
await db.commit()
Expand Down
33 changes: 33 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "open_needs_server"
version = "0.1.0"
authors = [
{ name="Open-Needs community", email="daniel@useblocks.com" },
]
description = "Open-Needs Server"
readme = "README.md"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dynamic = ["dependencies", "optional-dependencies"]

[tool.setuptools.packages.find]
where = ["."]
include = ["open_needs_server"]
namespaces = false

[tool.setuptools.dynamic]
dependencies = {file = ["requirements/server.txt"]}
optional-dependencies.docs = {file = ["requirements/docs.txt"] }
optional-dependencies.data = {file = ["requirements/data.txt"] }


[project.scripts]
ons = "open_needs_server.main:start"
4 changes: 2 additions & 2 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
sphinx
sphinx>=5.0.0
jinja2<3.1
sphinx-immaterial # The theme
sphinxcontrib-plantuml # Used for all architecture and mockup images
sphinxcontrib-httpdomain # Used REST-API documentation
sphinxcontrib-needs # need objects and filtering
sphinxcontrib-needs>=0.7.9 # need objects and filtering
sphinx-panels # tabs, dropdonws, cards and more
sphinx-disqus # comment field integration
sphinx-preview # iframe-preview for links
Expand Down
18 changes: 9 additions & 9 deletions requirements/server.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
rich
uvicorn
pydantic
fastapi
fastapi-users[sqlalchemy]>=10.0.0
aiosqlite
dynaconf
sqladmin
jsonschema
rich==13.7.0
uvicorn==0.30.1
pydantic==2.5.3
fastapi==0.111.0
fastapi-users[sqlalchemy]==13.0.0
aiosqlite==0.20.0
dynaconf==3.2.5
sqladmin==0.17.0
jsonschema>=3.2.0
20 changes: 0 additions & 20 deletions setup.py

This file was deleted.