Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit c5a225d

Browse files
committed
Remove dependency on Azure storage and update documentation
1 parent b4405ad commit c5a225d

File tree

4 files changed

+35
-30
lines changed

4 files changed

+35
-30
lines changed

README.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ INSTALLED_APPS = [
1515
]
1616
```
1717

18+
Useful Imports
19+
--------------
20+
```python
21+
from django.db import models
22+
from django.db.models.signals import pre_save
23+
24+
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList, PageChooserPanel
25+
from wagtail.core.models import Page
26+
27+
from wagtailreacttaxonomy.models import TaxonomyMixin, PageTaxonomyPermissionsMixin,\
28+
ModelTaxonomyPermissionsMixin, format_permissions_json
29+
from wagtailreacttaxonomy.edit_handlers import TaxonomyPanel, PermissionsPanel
30+
```
31+
1832
How to use Taxonomy Term Component
1933
----------------------------------
2034

@@ -110,34 +124,38 @@ How to contribute
110124
##### Requirements
111125
* Docker
112126
* docker-compose
113-
You'll get all this lot installed nicely with (https://docs.docker.com/docker-for-mac/install).
114127

115-
##### Add git hook
128+
You'll get all this lot installed nicely with https://docs.docker.com/docker-for-mac/install.
129+
130+
### Add git hook
116131
```
117132
./scripts/install-hooks.sh
118133
```
134+
Now you are set
119135

120-
### Now you are set
121-
122-
#### Build the containers
136+
### Build the containers
123137
```
124138
docker-compose build
125139
```
126-
#### Create super user
140+
### Create super user
127141
```
128142
docker-compose run --rm web python manage.py createsuperuser
129143
```
130-
#### Exercise the application
131-
132-
##### Run the containers
144+
### Exercise the application
133145

146+
#### Run the containers
134147
```
135148
docker-compose up
136149
```
137150

138-
##### Browse to http://localhost:8000/admin and make your changes with live reload
151+
#### Browse to http://localhost:8000/admin and make your changes with live reload
152+
153+
1. Log in as superuser
154+
1. You will see a Taxonomy Terms entry in the admin menu
155+
1. Use this entry to upload and save the JSON text of your taxonomy
156+
1. Taxonomies are stored in your Django media folder (media in the test configuration)
139157

140-
#### Run tests as required
158+
### Run tests as required
141159

142160
```
143161
docker-compose run --rm web python manage.py test

config/settings/base.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,6 @@
183183
# WAGTAILIMAGES_IMAGE_MODEL = 'wagtailapiimagerendition.CustomImage'
184184
WAGTAIL_USAGE_COUNT_ENABLED = True
185185

186-
# DEFAULT_FILE_STORAGE = 'storages.backends.azure_storage.AzureStorage'
187-
AZURE_ACCOUNT_NAME = os.environ.get('AZURE_ACCOUNT_NAME') # eg. 'campaignstorage'
188-
AZURE_ACCOUNT_KEY = os.environ.get('AZURE_ACCOUNT_KEY') # eg. '<secret key>'
189-
AZURE_CONTAINER = os.environ.get('AZURE_CONTAINER') # eg. 'campaign-resource-centre'
190-
AZURE_FILE_SHARE = os.environ.get('AZURE_FILE_SHARE')
191-
192186
ENV = os.environ.get('CMS_ENV', 'local')
193187

194188
# INITIALIZER = os.environ.get('INITIALIZER', False)

requirements.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ wagtail~=2.16
33
psycopg2>=2.8,<2.9
44
python-crontab>=2.5,<2.6
55
django-cors-headers>=3.5,<3.6
6-
django-storages[azure]~=1.12
7-
azure-storage-common~=2.1
8-
azure-storage-file~=2.1
9-
azure-storage-blob~=12.9
10-
azure-core~=1.23
6+
django-storages~=1.12
117
coverage>=5.2,<5.3
128
gunicorn>=20.0,<20.1
139
flake8>=3.8,<3.9

wagtailreacttaxonomy/models.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
import logging
33
from django.conf import settings
44

5-
from azure.storage.file import FileService
6-
from azure.common import AzureMissingResourceHttpError
7-
from azure.storage.file.models import File as AzureFile, Directory as AzureDirectory
8-
9-
from azure.storage.blob import BlobServiceClient
5+
from django.core.files.base import ContentFile
6+
from django.core.files.storage import default_storage
107

118
from django.db import models
129
from django.db.models.signals import pre_save
@@ -30,12 +27,13 @@ def update_taxonomy_terms_on_blobstore(sender, instance, **kwargs):
3027
content['terms'] = terms_with_vocab
3128

3229
blobPath = f'taxonomy/{instance.taxonomy_id}.json'
33-
blob_service = BlobServiceClient(account_name=settings.AZURE_ACCOUNT_NAME, account_key=settings.AZURE_ACCOUNT_KEY)
34-
blob_service.create_blob_from_text(settings.AZURE_CONTAINER, blobPath, to_json(content))
30+
blobFile = ContentFile (to_json (content))
31+
default_storage.save (blobPath, blobFile)
3532
logger.info('Successfully wrote taxonomy json to BlobStore %s', blobPath)
3633

3734
except Exception as e:
3835
logger.info('Could not build taxonomy json and send to BlobStore %s', e)
36+
raise
3937

4038
def get_terms_from_terms_json(data):
4139
terms = dict()
@@ -105,5 +103,4 @@ def format_permissions_json(sender, instance, **kwargs):
105103
for action_key, vocs in groups.items():
106104
permissions_json_formatted[group_key].extend(['{0}.{1}'.format(action_key, voc) for voc in vocs])
107105
instance.permissions_json_formatted = permissions_json_formatted
108-
print(permissions_json_formatted)
109106
return instance

0 commit comments

Comments
 (0)