diff --git a/cookbook/forms.py b/cookbook/forms.py index d53d9c5b..2a583873 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -238,7 +238,7 @@ class StorageForm(forms.ModelForm): class Meta: model = Storage - fields = ('name', 'method', 'username', 'password', 'token', 'url') + fields = ('name', 'method', 'username', 'password', 'token', 'url', 'path') help_texts = { 'url': _('Leave empty for dropbox and enter only base url for nextcloud (/remote.php/webdav/ is added automatically)'), # noqa: E501 diff --git a/cookbook/migrations/0101_storage_path.py b/cookbook/migrations/0101_storage_path.py new file mode 100644 index 00000000..175df3d1 --- /dev/null +++ b/cookbook/migrations/0101_storage_path.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2021-01-22 18:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0100_recipe_servings_text'), + ] + + operations = [ + migrations.AddField( + model_name='storage', + name='path', + field=models.CharField(blank=True, default='', max_length=256), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index 2aa2c496..04204fe9 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -124,6 +124,7 @@ class Storage(models.Model): password = models.CharField(max_length=128, blank=True, null=True) token = models.CharField(max_length=512, blank=True, null=True) url = models.URLField(blank=True, null=True) + path = models.CharField(blank=True, default='', max_length=256) created_by = models.ForeignKey(User, on_delete=models.PROTECT) def __str__(self): diff --git a/cookbook/provider/nextcloud.py b/cookbook/provider/nextcloud.py index e63c4f70..81d1f16a 100644 --- a/cookbook/provider/nextcloud.py +++ b/cookbook/provider/nextcloud.py @@ -20,6 +20,8 @@ class Nextcloud(Provider): 'webdav_password': storage.password, 'webdav_root': '/remote.php/dav/files/' + storage.username } + if storage.path != '': + options['webdav_root'] = storage.path return wc.Client(options) @staticmethod diff --git a/cookbook/views/api.py b/cookbook/views/api.py index 035a2cc0..739c340d 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -402,7 +402,7 @@ def get_recipe_file(request, recipe_id): @group_required('user') def sync_all(request): - if DEMO or True: + if DEMO: messages.add_message( request, messages.ERROR, _('This feature is not available in the demo version!') ) diff --git a/docs/features/external_recipes.md b/docs/features/external_recipes.md index 382eabf5..bc8c4e94 100644 --- a/docs/features/external_recipes.md +++ b/docs/features/external_recipes.md @@ -10,7 +10,8 @@ This feature is now called External recipes. To use external recipes you will first need to configure a storage source. After that a synced path can be created. Lastly you will need to sync with the external path and import recipes you desire. -# Storage Backends +## Storage + !!! success Currently only Nextcloud and Dropbox are supported. There are plans to add more provider @@ -18,10 +19,32 @@ A `Storage Backend` is a remote storage location where files are **read** from. To add a new backend click on `Storage Data` and then on `Storage Backends`. There click the plus button. -Enter a name (just a display name for you to identify it) and an API access Token for the account you want to use. -Dropboxes API tokens can be found on the -[Dropboxes API explorer](https://dropbox.github.io/dropbox-api-v2-explorer/#auth_token/from_oauth1) -with the button on the top right. For Nextcloud, you can use an App password created in the settings. +The basic configuration is the same for all providers. + +| Field | Value | +|----------|-------| +| Name | Your identifier for this storage source, can be everything you want. | +| Method | The desired method. | + +### Dropbox + +| Field | Value | +|----------|-------| +| Username | Dropbox username | +| Token | Dropbox API Token. Can be found [here](https://dropbox.github.io/dropbox-api-v2-explorer/#auth_token/from_oauth1)| + +### Nextcloud + +!!! warning "Path" + It appears that the correct webdav path varies from installation to installation (for whatever reason). + In the Nextcloud webinterface click the `Settings` button in the bottom left corner, there your WebDav Url will be displayed. + +| Field | Value | +|----------|-------| +| Username | Nextcloud username | +| Password | Nextcloud app password | +| Url | Nextcloud Server URL (e.g. `https://cloud.mydomain.com`) | +| Path | (optional) webdav path (e.g. `/remote.php/dav/files/vabene1111`). If no path is supplied `/remote.php/dav/files/` plus your username will be used. | ## Adding Synced Paths To add a new path from your Storage backend to the sync list, go to `Storage Data >> Configure Sync` and