added internal notes and improved invite link form

This commit is contained in:
vabene1111 2023-06-30 23:09:22 +02:00
parent 439539f56d
commit b599c4f6a9
7 changed files with 5837 additions and 15 deletions

View File

@ -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),
),
]

View File

@ -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
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)
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_at = models.DateTimeField(auto_now_add=True)
internal_note = models.TextField(blank=True, null=True)
space = models.ForeignKey(Space, on_delete=models.CASCADE)
objects = ScopedManager(space='space')

View File

@ -322,8 +322,8 @@ class UserSpaceSerializer(WritableNestedModelSerializer):
class Meta:
model = UserSpace
fields = ('id', 'user', 'space', 'groups', 'active', 'created_at', 'updated_at',)
read_only_fields = ('id', 'created_at', 'updated_at', 'space')
fields = ('id', 'user', 'space', 'groups', 'active', 'internal_note', 'invite_link', 'created_at', 'updated_at',)
read_only_fields = ('id', 'invite_link', 'created_at', 'updated_at', 'space')
class SpacedModelSerializer(serializers.ModelSerializer):
@ -1245,7 +1245,7 @@ class InviteLinkSerializer(WritableNestedModelSerializer):
class Meta:
model = InviteLink
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',)

View File

@ -370,7 +370,7 @@ def invite_link(request, token):
link.used_by = request.user
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:
user_space.active = True

View File

@ -258,12 +258,14 @@ export class Models {
field: "description",
label: "Description",
placeholder: "",
optional: true,
},
icon: {
form_field: true,
type: "emoji",
field: "icon",
label: "Icon",
optional: true,
},
full_name: {
form_field: true,
@ -295,6 +297,7 @@ export class Models {
field: "plural_name",
label: "Plural name",
placeholder: "",
optional: true,
},
description: {
form_field: true,
@ -302,6 +305,7 @@ export class Models {
field: "description",
label: "Description",
placeholder: "",
optional: true,
},
open_data_slug: {
form_field: true,
@ -310,6 +314,7 @@ export class Models {
disabled: true,
label: "Open_Data_Slug",
help_text: "open_data_help_text",
optional: true,
},
},
},
@ -364,12 +369,14 @@ export class Models {
field: "description",
label: "Description",
placeholder: "",
optional: true,
},
icon: {
form_field: true,
type: "emoji",
field: "icon",
label: "Icon",
optional: true,
},
filter: {
form_field: true,
@ -377,6 +384,7 @@ export class Models {
field: "filter",
label: "Custom Filter",
list: "CUSTOM_FILTER",
optional: true,
},
},
},
@ -401,6 +409,7 @@ export class Models {
field: "description",
label: "Description",
placeholder: "",
optional: true,
},
},
},
@ -451,6 +460,7 @@ export class Models {
field: "description",
label: "Description",
placeholder: "",
optional: true,
},
categories: {
form_field: true,
@ -461,6 +471,7 @@ export class Models {
field: "category_to_supermarket",
label: "Categories", // form.label always translated in utils.getForm()
placeholder: "",
optional: true,
},
open_data_slug: {
form_field: true,
@ -469,6 +480,7 @@ export class Models {
disabled: true,
label: "Open_Data_Slug",
help_text: "open_data_help_text",
optional: true,
},
},
config: {
@ -507,6 +519,7 @@ export class Models {
field: "description",
label: "Description",
placeholder: "",
optional: true,
},
type: {
form_field: true,
@ -652,6 +665,7 @@ export class Models {
disabled: true,
label: "Open_Data_Slug",
help_text: "open_data_help_text",
optional: true,
},
},
@ -685,6 +699,7 @@ export class Models {
field: "icon",
label: "Icon",
placeholder: "",
optional: true,
},
unit: {
form_field: true,
@ -692,6 +707,7 @@ export class Models {
field: "unit",
label: "Unit",
placeholder: "",
optional: true,
},
description: {
form_field: true,
@ -699,6 +715,7 @@ export class Models {
field: "description",
label: "Description",
placeholder: "",
optional: true,
},
open_data_slug: {
form_field: true,
@ -707,6 +724,7 @@ export class Models {
disabled: true,
label: "Open_Data_Slug",
help_text: "open_data_help_text",
optional: true,
},
},
@ -853,15 +871,8 @@ export class Models {
apiName: "InviteLink",
paginated: false,
create: {
params: [["email", "group", "valid_until", "reusable"]],
params: [["email", "group", "valid_until", "reusable", "internal_note"]],
form: {
email: {
form_field: true,
type: "text",
field: "email",
label: "Email",
placeholder: "",
},
group: {
form_field: true,
type: "lookup",
@ -878,6 +889,14 @@ export class Models {
label: "Valid Until",
placeholder: "",
},
email: {
form_field: true,
type: "text",
field: "email",
label: "Email",
placeholder: "",
optional: true,
},
reusable: {
form_field: true,
type: "checkbox",
@ -886,6 +905,15 @@ export class Models {
help_text: "reusable_help_text",
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

View File

@ -14,6 +14,7 @@ import {BToast} from "bootstrap-vue"
// * */
import Vue from "vue"
import {Actions, Models} from "./models"
import moment from "moment";
export const ToastMixin = {
name: "ToastMixin",
@ -721,6 +722,10 @@ export const formFunctions = {
form.fields.filter((x) => x.field === "inherit_fields")[0].value = getUserPreference("food_inherit_default")
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) {
if (form.fields.filter((x) => x.field === "order")[0].value === undefined) {
form.fields.filter((x) => x.field === "order")[0].value = 1000