moved demo to space setting
This commit is contained in:
parent
6fc0c02674
commit
02c5aed0a3
18
cookbook/migrations/0125_space_demo.py
Normal file
18
cookbook/migrations/0125_space_demo.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.3 on 2021-06-04 14:52
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cookbook', '0124_alter_userpreference_theme'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='space',
|
||||
name='demo',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
@ -64,6 +64,7 @@ class Space(models.Model):
|
||||
max_recipes = models.IntegerField(default=0)
|
||||
allow_files = models.BooleanField(default=True)
|
||||
max_users = models.IntegerField(default=0)
|
||||
demo = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
@ -57,7 +57,6 @@ from cookbook.serializer import (FoodSerializer, IngredientSerializer,
|
||||
ViewLogSerializer, CookLogSerializer, RecipeBookEntrySerializer,
|
||||
RecipeOverviewSerializer, SupermarketSerializer, ImportLogSerializer,
|
||||
BookmarkletImportSerializer, SupermarketCategorySerializer)
|
||||
from recipes.settings import DEMO
|
||||
|
||||
|
||||
class StandardFilterMixin(ViewSetMixin):
|
||||
@ -390,7 +389,7 @@ class RecipeViewSet(viewsets.ModelViewSet):
|
||||
obj, data=request.data, partial=True
|
||||
)
|
||||
|
||||
if DEMO:
|
||||
if self.request.space.demo:
|
||||
raise PermissionDenied(detail='Not available in demo', code=None)
|
||||
|
||||
if serializer.is_valid():
|
||||
@ -537,7 +536,7 @@ def get_recipe_file(request, recipe_id):
|
||||
|
||||
@group_required('user')
|
||||
def sync_all(request):
|
||||
if DEMO:
|
||||
if request.space.demo:
|
||||
messages.add_message(
|
||||
request, messages.ERROR, _('This feature is not available in the demo version!')
|
||||
)
|
||||
|
@ -33,7 +33,6 @@ from cookbook.models import (Comment, CookLog, InviteLink, MealPlan,
|
||||
from cookbook.tables import (CookLogTable, RecipeTable, RecipeTableSmall,
|
||||
ViewLogTable)
|
||||
from cookbook.views.data import Object
|
||||
from recipes.settings import DEMO
|
||||
from recipes.version import BUILD_REF, VERSION_NUMBER
|
||||
|
||||
|
||||
@ -284,7 +283,7 @@ def shopping_list(request, pk=None):
|
||||
|
||||
@group_required('guest')
|
||||
def user_settings(request):
|
||||
if DEMO:
|
||||
if request.space.demo:
|
||||
messages.add_message(request, messages.ERROR, _('This feature is not available in the demo version!'))
|
||||
return redirect('index')
|
||||
|
||||
|
@ -27,7 +27,6 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
SECRET_KEY = os.getenv('SECRET_KEY') if os.getenv('SECRET_KEY') else 'INSECURE_STANDARD_KEY_SET_IN_ENV'
|
||||
|
||||
DEBUG = bool(int(os.getenv('DEBUG', True)))
|
||||
DEMO = bool(int(os.getenv('DEMO', False)))
|
||||
|
||||
SOCIAL_DEFAULT_ACCESS = bool(int(os.getenv('SOCIAL_DEFAULT_ACCESS', False)))
|
||||
SOCIAL_DEFAULT_GROUP = os.getenv('SOCIAL_DEFAULT_GROUP', 'guest')
|
||||
|
Loading…
Reference in New Issue
Block a user