Skip to content

Commit

Permalink
Merge pull request #300 from Lexpedite/owners
Browse files Browse the repository at this point in the history
Owners
  • Loading branch information
Gauntlet173 authored Jul 11, 2022
2 parents 74bcab1 + 6f7a4d2 commit c0ea739
Show file tree
Hide file tree
Showing 34 changed files with 772 additions and 593 deletions.
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,23 @@ As of v0.2-alpha, this project is attempting to adhere to [Semantic Versioning](
While alpha, however, any version may include breaking changes that may not be specifically noted as such,
and breaking changes will not necessarily result in changes to the main version number.

## Since Last Release
## [v1.3.20-alpha](https://github.com/Lexpedite/blawx/releases/tag/v1.3.20-alpha) 2022-07-11

This release adds user registration, restricts access to projects that the user created,
and allows the user to create new projects from templates and tutorials.

These features make it possible for Blawx to be used in a multi-user environment.

### Added
* User registration
* User registration - non-admin users can create user accounts for themselves.
* Users can now only see and interact with projects they created.

### Changed
* Tutorials and Examples are now available from the New Project button.
* Updates to Beginner's Guide and Examples documentation.

### Fixed
* A bug in the project import method has been fixed.

## [v1.3.19-alpha](https://github.com/Lexpedite/blawx/releases/tag/v1.3.19-alpha) 2022-07-07

Expand Down
6 changes: 5 additions & 1 deletion blawx/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ class WorkspaceAdmin(admin.ModelAdmin):
fields = ['ruledoc','workspace_name','xml_content','scasp_encoding']

class RuleDocAdmin(admin.ModelAdmin):
fields = ['ruledoc_name','scasp_encoding','tutorial']
fields = ['ruledoc_name','scasp_encoding','tutorial','owner']

class BlawxTestAdmin(admin.ModelAdmin):
fields = ['ruledoc','test_name','xml_content','scasp_encoding', 'tutorial']

# class RuleDocTemplateAdmin(admin.ModelAdmin):
# fields = ['template_name','yaml_content']

admin.site.register(Workspace,WorkspaceAdmin)
admin.site.register(RuleDoc,RuleDocAdmin)
admin.site.register(BlawxTest,BlawxTestAdmin)
# admin.site.register(RuleDocTemplate,RuleDocTemplateAdmin)
15 changes: 0 additions & 15 deletions blawx/fixtures/accounts/demo.yaml

This file was deleted.

24 changes: 3 additions & 21 deletions blawx/fixtures/docs/components/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,9 @@
The Blawx Administration Interface is available by navigating to `/admin` on your
Blawx Server.

## User Accounts
The primary purpose of accessing the admin interface is currently to be able to create
user accounts. This can be done by logging into the admin interface using an
admin username and password, click on users on the left side of the screen, and clicking
"add user" on the top right of the users screen.
Once you have created an account here, it will be possible for users to log in using that
account in the main Blawx Interface.
Note that Blawx' user permissions currently require that the user be logged in to be able
to access anything other than the main page, the login screen, or the documentation. However,
all users have access to all functions of the server.
More fine-grained user control will be implemented in future versions.
The admin interface can be used to view and make changes to the projects owned by anyone on the server,
and to add, change, and delete user accounts.

By default, on a new installation of Blawx, there is an admin account created with the user
name `admin` and the password `blawx2022`. When installing a server to which you want to
restrict access, make sure to change the admin password immediately.
Servers will also be created with a demo account with the username `demo` and the password
`blawx2022`. This user account should be deleted in the admin interface if you are trying
to restrict access to your server. The demo account is capable of doing anything inside
the system except add and remove users and access the admin interface.
restrict access, make sure to change the admin password immediately.
7 changes: 3 additions & 4 deletions blawx/fixtures/docs/examples/beards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
content: |
# Beard Tax Act

The Beard Tax Act example included with Blawx is [available here](/12/) (assuming it hasn't been
deleted from your system).
All the example projects are available under the New Project button.

It is an implemention inside Blawx of the Beard Tax Act rules as code demonstration task
This example is an implementation inside Blawx of the Beard Tax Act rules as code demonstration task
described at [the Better Rules github page](https://github.com/BetterRules/example-rules-as-code).

It includes a single test designed to be run inside BlawxBot. Open the project, click on the name
of the test, and click Bot to run the demo.
of the test, and click "Bot" to run the demo.
5 changes: 2 additions & 3 deletions blawx/fixtures/docs/examples/bird.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
content: |
# Bird Act

The Bird Act example included with Blawx is [available here](/6/) (assuming it hasn't been
deleted from your system).
All the example projects are available under the New Project button.

It is used to demonstrate the use of defaults and exceptions, and references to source
The Bird Act example is used to demonstrate the use of defaults and exceptions, and references to source
legislation in explanations.
5 changes: 2 additions & 3 deletions blawx/fixtures/docs/examples/mortality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
content: |
# Mortality Act

The Mortality Act example included with Blawx is [available here](/5/) (assuming it hasn't been
deleted from your system).
All the example projects are available under the New Project button.

It is used as a minimal example of a Blawx project.
The Mortality Act example is used as a minimal example of a Blawx project.
5 changes: 2 additions & 3 deletions blawx/fixtures/docs/examples/net30.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
content: |
# Net 30

The Net 30 example included with Blawx is [available here](/8/) (assuming it hasn't been
deleted from your system).
All the example projects are available under the New Project button.

It is used to demonstrate the use of dates and durations in Blawx.
The Net 30 example is used to demonstrate the use of dates and durations in Blawx.
5 changes: 2 additions & 3 deletions blawx/fixtures/docs/examples/r34.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
content: |
# Rule 34

The Rule 34 example included with Blawx is [available here](/4/) (assuming it hasn't been
deleted from your system).
All the example projects are available under the New Project button.

It is used to demonstrate the use of Blawx to detect drafting flaws in legislative texts.
The Rule 34 example is used to demonstrate the use of Blawx to detect drafting flaws in legislative texts.
5 changes: 2 additions & 3 deletions blawx/fixtures/docs/examples/rps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
content: |
# Rock Paper Scissors Act

The Rock Paper Scissors Act example included with Blawx is [available here](/2/) (assuming it hasn't been
deleted from your system).
All the example projects are available under the New Project button.

It is used to demonstrate many different features of Blawx.
The Rock Paper Scissors Act example is used to demonstrate many different features of Blawx.

A complete run-through of how to generate the Rule Paper Scissors example from scratch
is available as [a tutorial in the Beginner's Guide](/docs/guide/rps).
5 changes: 2 additions & 3 deletions blawx/fixtures/docs/examples/wills.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
content: |
# Wills Act

The Wills Act example included with Blawx is [available here](/9/) (assuming it hasn't been
deleted from your system).
All the example projects are available under the New Project button.

It is used to demonstrate the relevance reasoning features of the interview endpoint
The Wills Act example is used to demonstrate the relevance reasoning features of the interview endpoint
for Blawx tests, as seen in BlawxBot.

The rules set out that a person is entitled to make a will if they are over the age of 18,
Expand Down
5 changes: 2 additions & 3 deletions blawx/fixtures/docs/examples/wills_tutorial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
content: |
# Wills Act Tutorial

The Wills Act Tutorial included with Blawx is [available here](/14/) (assuming it hasn't been
deleted from your system).
All the tutorial projects are available under the New Project button.

It contains a single-section rule, a single test, and no code. Instead, if you click the "Tutorial"
The Wills Act Tutorial contains a single-section rule, a single test, and no code. Instead, if you click the "Tutorial"
button in the button bar, it will take you through a short tutorial of how to encode your rule,
test it, and deploy it using BlawxBot.

Expand Down
6 changes: 4 additions & 2 deletions blawx/fixtures/docs/guide/legal_text.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@

## Creating a New Project

To begin, go to [the root of your Blawx server](/), which will look something like this:
To begin, go to [the root of your Blawx server](/). You may need to create a user account if
you have not done so already. When you are logged in, the root of the server will look something like this:

![Blawx Root Screen](/static/blawx/docs/images/blawx_root_screen.png)

Once there, click "Create Rule". This will open the Project Editor screen, which will
Once there, click "New Project", and in the resulting drop-down choose "New Blank Project".
This will open the Project Editor screen, which will
look like this:

![Project Editor Screen](/static/blawx/docs/images/project_editor_screen.png)
Expand Down
22 changes: 22 additions & 0 deletions blawx/migrations/0020_ruledoc_owner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.0.1 on 2022-07-08 18:25

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


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('blawx', '0019_blawxtest_tutorial'),
]

operations = [
migrations.AddField(
model_name='ruledoc',
name='owner',
field=models.ForeignKey(default=3, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
preserve_default=False,
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.1 on 2022-07-08 23:00

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('blawx', '0020_ruledoc_owner'),
]

operations = [
migrations.RenameField(
model_name='workspacetemplate',
old_name='xml_content',
new_name='yaml_content',
),
]
17 changes: 17 additions & 0 deletions blawx/migrations/0022_rename_workspacetemplate_ruledoctemplate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.0.1 on 2022-07-08 23:05

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('blawx', '0021_rename_xml_content_workspacetemplate_yaml_content'),
]

operations = [
migrations.RenameModel(
old_name='WorkspaceTemplate',
new_name='RuleDocTemplate',
),
]
16 changes: 16 additions & 0 deletions blawx/migrations/0023_delete_ruledoctemplate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.0.1 on 2022-07-11 18:40

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('blawx', '0022_rename_workspacetemplate_ruledoctemplate'),
]

operations = [
migrations.DeleteModel(
name='RuleDocTemplate',
),
]
12 changes: 7 additions & 5 deletions blawx/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from django.contrib.auth.models import User
from .parse_an import generate_tree
from cobalt.hierarchical import Act
from clean.clean import generate_akn
Expand All @@ -10,6 +11,7 @@ class RuleDoc(models.Model):
# akoma_ntoso = models.TextField(default="",blank=True)
scasp_encoding = models.TextField(default="",blank=True)
tutorial = models.TextField(default="",blank=True)
owner = models.ForeignKey(User,on_delete=models.CASCADE,)

def __str__(self):
return self.ruledoc_name
Expand Down Expand Up @@ -52,12 +54,12 @@ class Meta:
models.UniqueConstraint(fields=['ruledoc','test_name'],name='unique_test_and_ruledoc')
]

class WorkspaceTemplate(models.Model):
template_name = models.CharField(max_length=200)
xml_content = models.TextField(default="")
# class RuleDocTemplate(models.Model):
# template_name = models.CharField(max_length=200)
# yaml_content = models.TextField(default="")

def __str__(self):
return self.template_name
# def __str__(self):
# return self.template_name

class Query(models.Model):
ruledoc = models.ForeignKey(Workspace, on_delete=models.CASCADE)
Expand Down
Loading

0 comments on commit c0ea739

Please sign in to comment.