added internal notes and improved invite link form
This commit is contained in:
parent
439539f56d
commit
b599c4f6a9
@ -0,0 +1,34 @@
|
|||||||
|
# Generated by Django 4.1.9 on 2023-06-30 20:34
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('cookbook', '0194_alter_food_properties_food_amount'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='invitelink',
|
||||||
|
name='internal_note',
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='userspace',
|
||||||
|
name='internal_note',
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='userspace',
|
||||||
|
name='invite_link',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='cookbook.invitelink'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='userpreference',
|
||||||
|
name='theme',
|
||||||
|
field=models.CharField(choices=[('TANDOOR', 'Tandoor'), ('BOOTSTRAP', 'Bootstrap'), ('DARKLY', 'Darkly'), ('FLATLY', 'Flatly'), ('SUPERHERO', 'Superhero'), ('TANDOOR_DARK', 'Tandoor Dark (INCOMPLETE)')], default='TANDOOR', max_length=128),
|
||||||
|
),
|
||||||
|
]
|
@ -415,6 +415,9 @@ class UserSpace(models.Model, PermissionModelMixin):
|
|||||||
# that having more than one active space should just break certain parts of the application and not leak any data
|
# that having more than one active space should just break certain parts of the application and not leak any data
|
||||||
active = models.BooleanField(default=False)
|
active = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
invite_link = models.ForeignKey("InviteLink", on_delete=models.PROTECT, null=True, blank=True)
|
||||||
|
internal_note = models.TextField(blank=True, null=True)
|
||||||
|
|
||||||
created_at = models.DateTimeField(auto_now_add=True)
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
updated_at = models.DateTimeField(auto_now=True)
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
@ -1144,6 +1147,8 @@ class InviteLink(ExportModelOperationsMixin('invite_link'), models.Model, Permis
|
|||||||
created_by = models.ForeignKey(User, on_delete=models.CASCADE)
|
created_by = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
created_at = models.DateTimeField(auto_now_add=True)
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
|
internal_note = models.TextField(blank=True, null=True)
|
||||||
|
|
||||||
space = models.ForeignKey(Space, on_delete=models.CASCADE)
|
space = models.ForeignKey(Space, on_delete=models.CASCADE)
|
||||||
objects = ScopedManager(space='space')
|
objects = ScopedManager(space='space')
|
||||||
|
|
||||||
|
@ -322,8 +322,8 @@ class UserSpaceSerializer(WritableNestedModelSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = UserSpace
|
model = UserSpace
|
||||||
fields = ('id', 'user', 'space', 'groups', 'active', 'created_at', 'updated_at',)
|
fields = ('id', 'user', 'space', 'groups', 'active', 'internal_note', 'invite_link', 'created_at', 'updated_at',)
|
||||||
read_only_fields = ('id', 'created_at', 'updated_at', 'space')
|
read_only_fields = ('id', 'invite_link', 'created_at', 'updated_at', 'space')
|
||||||
|
|
||||||
|
|
||||||
class SpacedModelSerializer(serializers.ModelSerializer):
|
class SpacedModelSerializer(serializers.ModelSerializer):
|
||||||
@ -1245,7 +1245,7 @@ class InviteLinkSerializer(WritableNestedModelSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = InviteLink
|
model = InviteLink
|
||||||
fields = (
|
fields = (
|
||||||
'id', 'uuid', 'email', 'group', 'valid_until', 'used_by', 'reusable', 'created_by', 'created_at',)
|
'id', 'uuid', 'email', 'group', 'valid_until', 'used_by', 'reusable', 'internal_note', 'created_by', 'created_at',)
|
||||||
read_only_fields = ('id', 'uuid', 'created_by', 'created_at',)
|
read_only_fields = ('id', 'uuid', 'created_by', 'created_at',)
|
||||||
|
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ def invite_link(request, token):
|
|||||||
link.used_by = request.user
|
link.used_by = request.user
|
||||||
link.save()
|
link.save()
|
||||||
|
|
||||||
user_space = UserSpace.objects.create(user=request.user, space=link.space, active=False)
|
user_space = UserSpace.objects.create(user=request.user, space=link.space, internal_note=link.internal_note, invite_link=link, active=False)
|
||||||
|
|
||||||
if request.user.userspace_set.count() == 1:
|
if request.user.userspace_set.count() == 1:
|
||||||
user_space.active = True
|
user_space.active = True
|
||||||
|
@ -258,12 +258,14 @@ export class Models {
|
|||||||
field: "description",
|
field: "description",
|
||||||
label: "Description",
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "emoji",
|
type: "emoji",
|
||||||
field: "icon",
|
field: "icon",
|
||||||
label: "Icon",
|
label: "Icon",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
full_name: {
|
full_name: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -295,6 +297,7 @@ export class Models {
|
|||||||
field: "plural_name",
|
field: "plural_name",
|
||||||
label: "Plural name",
|
label: "Plural name",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -302,6 +305,7 @@ export class Models {
|
|||||||
field: "description",
|
field: "description",
|
||||||
label: "Description",
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
open_data_slug: {
|
open_data_slug: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -310,6 +314,7 @@ export class Models {
|
|||||||
disabled: true,
|
disabled: true,
|
||||||
label: "Open_Data_Slug",
|
label: "Open_Data_Slug",
|
||||||
help_text: "open_data_help_text",
|
help_text: "open_data_help_text",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -364,12 +369,14 @@ export class Models {
|
|||||||
field: "description",
|
field: "description",
|
||||||
label: "Description",
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "emoji",
|
type: "emoji",
|
||||||
field: "icon",
|
field: "icon",
|
||||||
label: "Icon",
|
label: "Icon",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
filter: {
|
filter: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -377,6 +384,7 @@ export class Models {
|
|||||||
field: "filter",
|
field: "filter",
|
||||||
label: "Custom Filter",
|
label: "Custom Filter",
|
||||||
list: "CUSTOM_FILTER",
|
list: "CUSTOM_FILTER",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -401,6 +409,7 @@ export class Models {
|
|||||||
field: "description",
|
field: "description",
|
||||||
label: "Description",
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -451,6 +460,7 @@ export class Models {
|
|||||||
field: "description",
|
field: "description",
|
||||||
label: "Description",
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
categories: {
|
categories: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -461,6 +471,7 @@ export class Models {
|
|||||||
field: "category_to_supermarket",
|
field: "category_to_supermarket",
|
||||||
label: "Categories", // form.label always translated in utils.getForm()
|
label: "Categories", // form.label always translated in utils.getForm()
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
open_data_slug: {
|
open_data_slug: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -469,6 +480,7 @@ export class Models {
|
|||||||
disabled: true,
|
disabled: true,
|
||||||
label: "Open_Data_Slug",
|
label: "Open_Data_Slug",
|
||||||
help_text: "open_data_help_text",
|
help_text: "open_data_help_text",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
config: {
|
config: {
|
||||||
@ -507,6 +519,7 @@ export class Models {
|
|||||||
field: "description",
|
field: "description",
|
||||||
label: "Description",
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -652,6 +665,7 @@ export class Models {
|
|||||||
disabled: true,
|
disabled: true,
|
||||||
label: "Open_Data_Slug",
|
label: "Open_Data_Slug",
|
||||||
help_text: "open_data_help_text",
|
help_text: "open_data_help_text",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -685,6 +699,7 @@ export class Models {
|
|||||||
field: "icon",
|
field: "icon",
|
||||||
label: "Icon",
|
label: "Icon",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
unit: {
|
unit: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -692,6 +707,7 @@ export class Models {
|
|||||||
field: "unit",
|
field: "unit",
|
||||||
label: "Unit",
|
label: "Unit",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -699,6 +715,7 @@ export class Models {
|
|||||||
field: "description",
|
field: "description",
|
||||||
label: "Description",
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
open_data_slug: {
|
open_data_slug: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -707,6 +724,7 @@ export class Models {
|
|||||||
disabled: true,
|
disabled: true,
|
||||||
label: "Open_Data_Slug",
|
label: "Open_Data_Slug",
|
||||||
help_text: "open_data_help_text",
|
help_text: "open_data_help_text",
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -853,15 +871,8 @@ export class Models {
|
|||||||
apiName: "InviteLink",
|
apiName: "InviteLink",
|
||||||
paginated: false,
|
paginated: false,
|
||||||
create: {
|
create: {
|
||||||
params: [["email", "group", "valid_until", "reusable"]],
|
params: [["email", "group", "valid_until", "reusable", "internal_note"]],
|
||||||
form: {
|
form: {
|
||||||
email: {
|
|
||||||
form_field: true,
|
|
||||||
type: "text",
|
|
||||||
field: "email",
|
|
||||||
label: "Email",
|
|
||||||
placeholder: "",
|
|
||||||
},
|
|
||||||
group: {
|
group: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "lookup",
|
type: "lookup",
|
||||||
@ -878,6 +889,14 @@ export class Models {
|
|||||||
label: "Valid Until",
|
label: "Valid Until",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
|
email: {
|
||||||
|
form_field: true,
|
||||||
|
type: "text",
|
||||||
|
field: "email",
|
||||||
|
label: "Email",
|
||||||
|
placeholder: "",
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
reusable: {
|
reusable: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
@ -886,6 +905,15 @@ export class Models {
|
|||||||
help_text: "reusable_help_text",
|
help_text: "reusable_help_text",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
|
internal_note: {
|
||||||
|
form_field: true,
|
||||||
|
type: "textarea",
|
||||||
|
field: "internal_note",
|
||||||
|
label: "Note",
|
||||||
|
placeholder: "",
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
form_function: "InviteLinkDefaultValid",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -14,6 +14,7 @@ import {BToast} from "bootstrap-vue"
|
|||||||
// * */
|
// * */
|
||||||
import Vue from "vue"
|
import Vue from "vue"
|
||||||
import {Actions, Models} from "./models"
|
import {Actions, Models} from "./models"
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
export const ToastMixin = {
|
export const ToastMixin = {
|
||||||
name: "ToastMixin",
|
name: "ToastMixin",
|
||||||
@ -721,6 +722,10 @@ export const formFunctions = {
|
|||||||
form.fields.filter((x) => x.field === "inherit_fields")[0].value = getUserPreference("food_inherit_default")
|
form.fields.filter((x) => x.field === "inherit_fields")[0].value = getUserPreference("food_inherit_default")
|
||||||
return form
|
return form
|
||||||
},
|
},
|
||||||
|
InviteLinkDefaultValid: function (form){
|
||||||
|
form.fields.filter((x) => x.field === "valid_until")[0].value = moment().add(7, "days").format('yyyy-MM-DD')
|
||||||
|
return form
|
||||||
|
},
|
||||||
AutomationOrderDefault: function (form) {
|
AutomationOrderDefault: function (form) {
|
||||||
if (form.fields.filter((x) => x.field === "order")[0].value === undefined) {
|
if (form.fields.filter((x) => x.field === "order")[0].value === undefined) {
|
||||||
form.fields.filter((x) => x.field === "order")[0].value = 1000
|
form.fields.filter((x) => x.field === "order")[0].value = 1000
|
||||||
|
Loading…
Reference in New Issue
Block a user