Skip to content

Commit

Permalink
Merge pull request #344 from nofusscomputing/feature-v1-3
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-nfc authored Nov 28, 2024
2 parents 26b0bfa + 8050a7a commit 069251d
Show file tree
Hide file tree
Showing 515 changed files with 58,194 additions and 975 deletions.
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

- [ ] :checkered_flag: Milestone assigned

- [ ] :gear: :test_tube: [Functional Test(s) Written](https://nofusscomputing.com/projects/centurion_erp/development/testing/)

- [ ] :test_tube: [Unit Test(s) Written](https://nofusscomputing.com/projects/centurion_erp/development/testing/)

_ensure test coverage delta is not less than zero_
Expand Down
17 changes: 15 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "0.2.0",
"configurations": [
{
"name": "Debug: Django",
"name": "Centurion",
"type": "debugpy",
"request": "launch",
"args": [
Expand All @@ -17,6 +17,7 @@
"program": "${workspaceFolder}/app/manage.py"
},
{

"name": "Debug: Gunicorn",
"type": "debugpy",
"request": "launch",
Expand All @@ -35,9 +36,21 @@
"autoStartBrowser": false,
"cwd": "${workspaceFolder}/app"
},
{
"name": "Migrate",
"type": "debugpy",
"request": "launch",
"args": [
"migrate"
],
"django": true,
"autoStartBrowser": false,
"program": "${workspaceFolder}/app/manage.py"

},
{
"name": "Debug: Celery",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "celery",
"console": "integratedTerminal",
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
"ITSM"
],
"cSpell.language": "en-AU",
"jest.enable": false,
}
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ Included within the root of the repository is a makefile that can be used during
> this doc is yet to receive a re-write

## Docker Container

within the `deploy/` directory there is a docker compose file. running `docker compose up` from this directory will launch a full stack deployment locally containing Centurion API, User Interface, a worker and a RabbitMQ server. once launched you can navigate to `http://127.0.0.1/` to start browsing the site.

You may need to run migrations if your not mounting your own DB. to do this run `docker exec -ti centurion-erp python manage.py migrate`



# Old working docs


Expand Down
30 changes: 28 additions & 2 deletions Release-Notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## Version 1.4.0

API redesign in preparation for moving the UI out of centurion to it's [own project](https://github.com/nofusscomputing/centurion_erp_ui). This release introduces a **Feature freeze** to the current UI. Only bug fixes will be done for the current UI.
API v2 is a beta release and is subject to change. On completion of the new UI, API v2 will more likely than not be set as stable.

- A large emphasis is being placed upon API stability. This is being achieved by ensuring the following:

- Actions can only be carried out by users whom have the correct permissions

- fields are of the correct type and visible when required as part of the API response

- Data validations work and notify the user of any issue

We are make the above possible by ensuring a more stringent test policy.

- New API will be at path `api/v2`.

- API v1 is now **Feature frozen** with only bug fixes being completed. It's recommended that you move to and start using API v2 as this has feature parity with API v1.

- API v1 is **depreciated**

- Depreciation of **ALL** API urls. API v1 Will be [removed in v2.0.0](https://github.com/nofusscomputing/centurion_erp/issues/343) release of Centurion.


# Version 1.3.0

!!! danger "Security"
Expand All @@ -14,10 +38,12 @@ This release updates the docker container to be a production setup for deploymen
- To setup container as "Worker", set `IS_WORKER='True'` environmental variable within container. _**Note:** You can still use command `celery -A app worker -l INFO`, although **not** recommended as the container health check will not be functioning_


# Version 1.0.0
## Version 1.0.0


Initial Release of Centurion ERP.

## Breaking changes

### Breaking changes

- Nil
34 changes: 34 additions & 0 deletions app/access/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ class AutoCreatedField(models.DateTimeField):
"""

help_text = 'Date and time of creation'

verbose_name = 'Created'

def __init__(self, *args, **kwargs):

kwargs.setdefault("editable", False)

kwargs.setdefault("default", now)

kwargs.setdefault("help_text", self.help_text)

kwargs.setdefault("verbose_name", self.verbose_name)

super().__init__(*args, **kwargs)


Expand All @@ -28,6 +36,18 @@ class AutoLastModifiedField(AutoCreatedField):
"""

help_text = 'Date and time of last modification'

verbose_name = 'Modified'

def __init__(self, *args, **kwargs):

kwargs.setdefault("help_text", self.help_text)

kwargs.setdefault("verbose_name", self.verbose_name)

super().__init__(*args, **kwargs)

def pre_save(self, model_instance, add):

value = now()
Expand All @@ -45,6 +65,20 @@ class AutoSlugField(models.SlugField):
"""

help_text = 'slug for this field'

verbose_name = 'Slug'


def __init__(self, *args, **kwargs):

kwargs.setdefault("help_text", self.help_text)

kwargs.setdefault("verbose_name", self.verbose_name)

super().__init__(*args, **kwargs)


def pre_save(self, model_instance, add):

if not model_instance.slug or model_instance.slug == '_':
Expand Down
17 changes: 17 additions & 0 deletions app/access/migrations/0002_alter_team_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.1.2 on 2024-10-13 06:42

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('access', '0001_initial'),
]

operations = [
migrations.AlterModelOptions(
name='team',
options={'ordering': ['team_name'], 'verbose_name': 'Team', 'verbose_name_plural': 'Teams'},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Generated by Django 5.1.2 on 2024-10-13 15:27

import access.models
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('access', '0002_alter_team_options'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.AlterField(
model_name='organization',
name='id',
field=models.AutoField(help_text='ID of this item', primary_key=True, serialize=False, unique=True, verbose_name='ID'),
),
migrations.AlterField(
model_name='organization',
name='manager',
field=models.ForeignKey(help_text='Manager for this organization', null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='Manager'),
),
migrations.AlterField(
model_name='organization',
name='model_notes',
field=models.TextField(blank=True, default=None, help_text='Tid bits of information', null=True, verbose_name='Notes'),
),
migrations.AlterField(
model_name='organization',
name='name',
field=models.CharField(help_text='Name of this Organization', max_length=50, unique=True, verbose_name='Name'),
),
migrations.AlterField(
model_name='team',
name='is_global',
field=models.BooleanField(default=False, help_text='Is this a global object?', verbose_name='Global Object'),
),
migrations.AlterField(
model_name='team',
name='model_notes',
field=models.TextField(blank=True, default=None, help_text='Tid bits of information', null=True, verbose_name='Notes'),
),
migrations.AlterField(
model_name='team',
name='organization',
field=models.ForeignKey(help_text='Organization this belongs to', null=True, on_delete=django.db.models.deletion.CASCADE, to='access.organization', validators=[access.models.TenancyObject.validatate_organization_exists], verbose_name='Organization'),
),
migrations.AlterField(
model_name='team',
name='team_name',
field=models.CharField(default='', help_text='Name to give this team', max_length=50, verbose_name='Name'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Generated by Django 5.1.2 on 2024-10-16 06:54

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('access', '0003_alter_organization_id_alter_organization_manager_and_more'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.AlterModelOptions(
name='organization',
options={'ordering': ['name'], 'verbose_name': 'Organization', 'verbose_name_plural': 'Organizations'},
),
migrations.AlterModelOptions(
name='teamusers',
options={'ordering': ['user'], 'verbose_name': 'Team User', 'verbose_name_plural': 'Team Users'},
),
migrations.AlterField(
model_name='teamusers',
name='id',
field=models.AutoField(help_text='ID of this Team User', primary_key=True, serialize=False, unique=True, verbose_name='ID'),
),
migrations.AlterField(
model_name='teamusers',
name='manager',
field=models.BooleanField(blank=True, default=False, help_text='Is this user to be a manager of this team', verbose_name='manager'),
),
migrations.AlterField(
model_name='teamusers',
name='team',
field=models.ForeignKey(help_text='Team user belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='team', to='access.team', verbose_name='Team'),
),
migrations.AlterField(
model_name='teamusers',
name='user',
field=models.ForeignKey(help_text='User who will be added to the team', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User'),
),
]
18 changes: 18 additions & 0 deletions app/access/migrations/0005_alter_team_team_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.1.2 on 2024-11-07 06:28

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('access', '0004_alter_organization_options_alter_teamusers_options_and_more'),
]

operations = [
migrations.AlterField(
model_name='team',
name='team_name',
field=models.CharField(help_text='Name to give this team', max_length=50, verbose_name='Name'),
),
]
20 changes: 20 additions & 0 deletions app/access/migrations/0006_alter_team_organization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 5.1.2 on 2024-11-20 02:41

import access.models
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('access', '0005_alter_team_team_name'),
]

operations = [
migrations.AlterField(
model_name='team',
name='organization',
field=models.ForeignKey(help_text='Organization this belongs to', on_delete=django.db.models.deletion.CASCADE, to='access.organization', validators=[access.models.TenancyObject.validatate_organization_exists], verbose_name='Organization'),
),
]
19 changes: 16 additions & 3 deletions app/access/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def object_organization(self) -> int:

if hasattr(self, '_object_organization'):

return self._object_organization
return int(self._object_organization)

try:

Expand Down Expand Up @@ -124,9 +124,13 @@ def is_member(self, organization: int) -> bool:

is_member = False

if organization in self.user_organizations():
if organization is None:

return True
return False

if int(organization) in self.user_organizations():

is_member = True

return is_member

Expand All @@ -136,6 +140,10 @@ def get_permission_required(self):
Override of 'PermissionRequiredMixin' method so that this mixin can obtain the required permission.
"""

if not hasattr(self, 'permission_required'):

return []

if self.permission_required is None:
raise ImproperlyConfigured(
f"{self.__class__.__name__} is missing the "
Expand Down Expand Up @@ -216,6 +224,11 @@ def has_organization_permission(self, organization: int = None, permissions_requ

organization = self.object_organization()

else:

organization = int(organization)


if self.is_member(organization) or organization == 0:

groups = Group.objects.filter(pk__in=self.user_groups)
Expand Down
Loading

0 comments on commit 069251d

Please sign in to comment.