Skip to content

Commit

Permalink
merges with v0.10. and fixes change log conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
fredkingham committed Feb 22, 2018
2 parents 75e3862 + eac54eb commit 8380974
Show file tree
Hide file tree
Showing 36 changed files with 633 additions and 325 deletions.
15 changes: 15 additions & 0 deletions .appveyor.yml
@@ -0,0 +1,15 @@
environment:
matrix:
- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python36"

install:
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "pip install --disable-pip-version-check --user --upgrade pip"
- "%CMD_IN_ENV% python setup.py develop"
- "pip install -r test-requirements.txt"

build: off

test_script:
- "%CMD_IN_ENV% python runtests.py"
25 changes: 17 additions & 8 deletions CHANGELOG.md
@@ -1,6 +1,6 @@
### 0.10.0 (Major Release)

This is a major release with breaking chnges from upstream dependencies.
This is a major release with breaking changes from upstream dependencies.
You are almost certain to require changes to your application. Please see
the upgrade guide for further details.

Expand All @@ -24,7 +24,7 @@ When you delete a user, it will no longer delete all related episodes and subrec

Episode categories now enforce a set of valid `Episode.stage` values.
`EpisodeCategory` now includes the `.get_stages()` and `.has_stage(stage)` methods,
while `Episode` has a `set_stage` setter which is used by the JSON API.
while `Episode` has a `set_stage` setter which is used by the UpdateFromDictMixin JSON API.

#### lookuplists.lookuplists

Expand Down Expand Up @@ -70,12 +70,13 @@ in `opal.core.views.

#### Updates to the Dependency Graph

Django: 1.8.13 -> 1.10.8
Django Reversion: 1.8.7 -> 1.10.2
Django Rest Framework: 3.2.2 -> 3.4.7
Psycopg2: 2.5 -> 2.7
Jinja2: 2.9.6 -> 2.10
Ffs: 0.0.8.1 -> 0.0.8.2
* Django: 1.8.13 -> 1.10.8
* Django Reversion: 1.8.7 -> 1.10.2
* Django Rest Framework: 3.2.2 -> 3.4.7
* Psycopg2: 2.5 -> 2.7
* Jinja2: 2.9.6 -> 2.10
* Ffs: 0.0.8.1 -> 0.0.8.2
* Requests: 2.7.0 -> 2.18.4

#### Testing options

Expand All @@ -86,6 +87,12 @@ If you are a plugin developer upgrading an existing plugin you will have to
manually add support for `--failfast` passthrough to your `runtests.py`.


#### Moves scaffold to be a django management command

The rest of the api is still the same but now
we run `python manage.py scaffold {my_app_name}`


#### Misc Changes

Removes the undocumented `collapsed_multisave` tag from the `pathways` templatetag
Expand All @@ -94,6 +101,8 @@ library.
The ReferralRoute form (referral_route_form.html) has had its appearance tweaked
and improved.

Adds a setting `OPAL_FAVICON_PATH` to specify the application Favicon to use.

### 0.9.1 (Minor Release)

#### Pathways ContextProcessor
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -4,7 +4,7 @@ Opal is developed as an open source project, and as such we welcome contribution

### Reporting bugs

If you find what looks like a bug, add an issue to the [Github Issue tracker](http://github.com/opal/issues).
If you find what looks like a bug, add an issue to the [Github Issue tracker](https://github.com/openhealthcare/opal/issues).

Unclear documentation, unexpected error messages definitely count as bugs - feel free to raise issues about them.

Expand Down Expand Up @@ -34,7 +34,7 @@ That said, we won't merge your pull request if:
Don't worry though - we're happy to guide new contributors through this process.

If you want to discuss ideas you have for changes before making them, you can always propose enhancements on
the [Github Issue tracker](http://github.com/opal/issues) or post questions and open discussions on the
the [Github Issue tracker](https://github.com/openhealthcare/opal/issues) or post questions and open discussions on the
[mailing list](https://groups.google.com/forum/?ohc-dev#!forum/ohc-opal).

### Issues suitable for new contributors
Expand Down
10 changes: 0 additions & 10 deletions bin/opal

This file was deleted.

9 changes: 0 additions & 9 deletions doc/docs/guides/command_line_tool.md
Expand Up @@ -19,15 +19,6 @@ with Opal, creating directories and code boilerplate, and running initial migrat

Creates boilerplate code, and directory structures for a new Opal plugin.

### scaffold <appname>

Use with new record models.

Creates and runs automatic migrations, creates display and form (modal) templates.

Running with `--dry-run` will run makemigrations with `--dry-run` and print display
and form templates that would be generated.

### test <what>

Run our tests suites.
Expand Down
12 changes: 12 additions & 0 deletions doc/docs/reference/episode_categories.md
Expand Up @@ -65,6 +65,18 @@ InpatientEpisode(episode).has_stage('Inpatient')
# -> True
```


### EpisodeCategory.set_stage(stage, user, data)

Sets the stage on the episode. It gets passed the user, and the
rest of the data that's been used to update the episode.

```python
InpatientEpisode(episode).set_stage('Discharged', user, data_dict)
# -> True
```


## InpatientEpisode

This is the default EpisodeCategory imlpementation - applications started with Opal's
Expand Down
10 changes: 10 additions & 0 deletions doc/docs/reference/management_commands.md
Expand Up @@ -73,3 +73,13 @@ By default this command will look in `./yourapp/data/lookuplists.json` as well a
```bash
python manage.py load_lookup_lists
```


### scaffold <appname>

Use with new record models.

Creates and runs automatic migrations, creates display and form (modal) templates.

Running with `--dry-run` will run makemigrations with `--dry-run` and print display
and form templates that would be generated.
5 changes: 5 additions & 0 deletions doc/docs/reference/settings.md
Expand Up @@ -22,6 +22,11 @@ Scaffolded applications set this to 15 minutes by default. Unit is milliseconds.
If `OPAL_LOGO_PATH` is set, the value is passed to the `{% static %}` templatetag to set the
`src` attribute of an image in the default application header and login screen.

## OPAL_FAVICON_PATH

If `OPAL_FAVICON_PATH` is set, the value is passed to the `{% static %}` templatetag
to set the `href` attribute for the favicon tag in the default application `<head>`

## VERSION_NUMBER

The version number of your application. Displayed in the header by default.
Expand Down
1 change: 1 addition & 0 deletions doc/docs/reference/upgrading.md
Expand Up @@ -21,6 +21,7 @@ you have specified them in for instance, a requirements.txt.
psycopg==2.7
ffs==0.0.8.2
opal==0.10.0
requests==2.18.4


After re-installing (via for instance `pip install -r requirements.txt`) you will
Expand Down
2 changes: 1 addition & 1 deletion doc/docs/tutorial.md
Expand Up @@ -24,7 +24,7 @@ From the commandline:

$ opal startproject mynewapp

This will create a mynewap directory where your new project lives.
This will create a mynewapp directory where your new project lives.

Let's have a look at what that created for you:

Expand Down
21 changes: 21 additions & 0 deletions doc/docs/tutorials/theming_tutorial.md
@@ -1 +1,22 @@
# Customising the design of your application

Tutorial Outline (WIP)

* Built in settings
* Adding our own CSS file
* Key overrides and a .sass template to reset key colours
* Changing the layout of the application
* Bundling as a standalone theme

## Changing logos

We can change the logo and favicon of our application by changing settings.
Create a logo and a favicon, place them in `./yourapp/static/img/` and then
update the following settings:

```python
# ./yourapp/settings.py

OPAL_FAVICON_PATH = 'img/my.favicon.ico'
OPAL_LOGO_PATH = 'img/my.logo.png'
```
78 changes: 1 addition & 77 deletions opal/core/commandline.py
Expand Up @@ -4,7 +4,6 @@
In which we expose useful commandline functionality to our users.
"""
import argparse
import inspect
import os
import subprocess
import sys
Expand All @@ -14,14 +13,10 @@
import opal
from opal.core import scaffold as scaffold_utils
from opal.core import test_runner
from opal.utils import stringport, write
from opal.utils import write

USERLAND_HERE = ffs.Path('.').abspath
SCRIPT_HERE = ffs.Path(__file__).parent
OPAL = ffs.Path(opal.__file__).parent
SCAFFOLDING_BASE = OPAL/'scaffolding'
SCAFFOLD = SCAFFOLDING_BASE/'scaffold'
PLUGIN_SCAFFOLD = SCAFFOLDING_BASE/'plugin_scaffold'


def find_application_name():
Expand Down Expand Up @@ -57,62 +52,6 @@ def startplugin(args):
return


def scaffold(args):
"""
Create record boilierplates:
1. Run a south auto migration
2. Create display templates
3. Create forms
"""
app = args.app
name = find_application_name()
scaffold_utils._set_settings_module(name)
sys.path.append(os.path.abspath('.'))

# 1. Let's run a Django migration
dry_run = ''
if args.dry_run:
dry_run = '--dry-run'

if not args.nomigrations:
makemigrations_cmd = "python manage.py makemigrations {app} " \
"--traceback {dry_run}"
makemigrations_cmd = makemigrations_cmd.format(
app=app, dry_run=dry_run)
migrate_cmd = 'python manage.py migrate {app} --traceback'.format(
app=app)

os.system(makemigrations_cmd)
if not args.dry_run:
os.system(migrate_cmd)

# 2. Let's create some display templates
from opal.models import Subrecord, EpisodeSubrecord, PatientSubrecord

models = stringport('{0}.models'.format(app))
for i in dir(models):
thing = getattr(models, i)
if inspect.isclass(thing) and issubclass(thing, Subrecord):
if thing in [Subrecord, EpisodeSubrecord, PatientSubrecord]:
continue
if not thing.get_display_template():
if args.dry_run:
write('No Display template for {0}'.format(thing))
else:
scaffold_utils.create_display_template_for(
thing, SCAFFOLDING_BASE
)
if not thing.get_modal_template():
if args.dry_run:
write('No Form template for {0}'.format(thing))
else:
scaffold_utils.create_form_template_for(
thing, SCAFFOLDING_BASE
)
return


def test(args):
args.userland_here = USERLAND_HERE
args.opal_location = OPAL.parent
Expand Down Expand Up @@ -230,21 +169,6 @@ def parse_args(args):
)
parser_plugin.set_defaults(func=startplugin)

parser_scaffold = subparsers.add_parser("scaffold")
parser_scaffold.add_argument('app', help='Django app to scaffold')
scaffold_help = "Just print the templates we would create - don't " \
"actually create them"
parser_scaffold.add_argument(
'--dry-run',
action='store_true',
help=scaffold_help)
parser_scaffold.add_argument(
'--nomigrations',
action='store_true',
help="Don't run Django migration related commands"
)
parser_scaffold.set_defaults(func=scaffold)

parser_test = subparsers.add_parser("test")
parser_test.add_argument(
'what', default='all', choices=['all', 'py', 'js'], nargs='*')
Expand Down
15 changes: 15 additions & 0 deletions opal/core/episodes.py
Expand Up @@ -63,6 +63,21 @@ def has_stage(self, stage):
"""
return stage in self.get_stages()

def set_stage(self, stage, user, data):
"""
Setter for Episode.stage
Validates that the stage being set is appropriate for the category
and raises ValueError if not.
"""
if not self.has_stage(stage):
if stage is not None:
msg = "Can't set stage to {0} for {1} Episode".format(
stage, self.display_name
)
raise ValueError(msg)
self.episode.stage = stage


class InpatientEpisode(EpisodeCategory):
display_name = 'Inpatient'
Expand Down

0 comments on commit 8380974

Please sign in to comment.