added hack to fix scopes & CORS for bookmarklet
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 3.1.7 on 2021-03-26 17:42
|
# Generated by Django 3.1.7 on 2021-03-29 11:05
|
||||||
|
|
||||||
import cookbook.models
|
import cookbook.models
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -10,10 +10,15 @@ class Migration(migrations.Migration):
|
|||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
('cookbook', '0116_auto_20210319_0012'),
|
('cookbook', '0117_space_max_recipes'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='userpreference',
|
||||||
|
name='use_fractions',
|
||||||
|
field=models.BooleanField(default=True),
|
||||||
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='BookmarkletImport',
|
name='BookmarkletImport',
|
||||||
fields=[
|
fields=[
|
@ -474,10 +474,13 @@ class ImportLogSerializer(serializers.ModelSerializer):
|
|||||||
read_only_fields = ('created_by',)
|
read_only_fields = ('created_by',)
|
||||||
|
|
||||||
|
|
||||||
|
# CORS, REST and Scopes aren't currently working
|
||||||
|
# Scopes are evaluating before REST has authenticated the user assiging a None space
|
||||||
|
# I've made the change below to fix the bookmarklet, other serializers likely need a similar/better fix
|
||||||
class BookmarkletImportSerializer(serializers.ModelSerializer):
|
class BookmarkletImportSerializer(serializers.ModelSerializer):
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
validated_data['created_by'] = self.context['request'].user
|
validated_data['created_by'] = self.context['request'].user
|
||||||
validated_data['space'] = self.context['request'].space
|
validated_data['space'] = self.context['request'].user.userpreference.space
|
||||||
return super().create(validated_data)
|
return super().create(validated_data)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
if (xhr.readyState == 4 && xhr.status == 201) {
|
if (xhr.readyState == 4 && xhr.status == 201) {
|
||||||
// parse JSON data
|
// parse JSON data
|
||||||
console.log(JSON.parse(xhr.response));
|
console.log(JSON.parse(xhr.response));
|
||||||
|
window.open(redirect.concat('?id=', JSON.parse(xhr.response).id) )
|
||||||
} else {
|
} else {
|
||||||
console.error('Error!');
|
console.error('Error!');
|
||||||
}
|
}
|
||||||
|
@ -94,9 +94,7 @@ def batch_edit(request):
|
|||||||
msg = ngettext(
|
msg = ngettext(
|
||||||
'Batch edit done. %(count)d recipe was updated.',
|
'Batch edit done. %(count)d recipe was updated.',
|
||||||
'Batch edit done. %(count)d Recipes where updated.',
|
'Batch edit done. %(count)d Recipes where updated.',
|
||||||
count) % {
|
count) % {'count': count, }
|
||||||
'count': count,
|
|
||||||
}
|
|
||||||
messages.add_message(request, messages.SUCCESS, msg)
|
messages.add_message(request, messages.SUCCESS, msg)
|
||||||
|
|
||||||
return redirect('data_batch_edit')
|
return redirect('data_batch_edit')
|
||||||
@ -191,7 +189,7 @@ def import_url(request):
|
|||||||
|
|
||||||
return HttpResponse(reverse('view_recipe', args=[recipe.pk]))
|
return HttpResponse(reverse('view_recipe', args=[recipe.pk]))
|
||||||
|
|
||||||
return render(request, 'url_import.html', {'recipe_json': 'undefined', 'recipe_tree': 'undefined', 'recipe_html': 'undefined', 'preview': 'false'})
|
return render(request, 'url_import.html', {})
|
||||||
|
|
||||||
|
|
||||||
class Object(object):
|
class Object(object):
|
||||||
|
Reference in New Issue
Block a user