Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta Release #468

Merged
merged 4 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions apps/wizarr-backend/wizarr_backend/api/routes/onboarding_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,34 @@ def put(self, onboarding_id: int):
if not page:
return {"error": "Onboarding page not found"}, 404

if(value is not None):
if value is not None:
page.value = value
if(enabled is not None):
if enabled is not None:
page.enabled = enabled in ["true", "True", "1"]

if order is not None and page.order != order:
step = 1 if page.order > order else -1
start, end = sorted([page.order, order])

# Update orders of affected pages
# Temporarily set the order of the target page to a value that won't conflict
max_order = OnboardingDB.select(fn.MAX(OnboardingDB.order)).scalar() or 0
page.order = max_order + 1
page.save()

# Shift orders of affected pages
affected_pages = OnboardingDB.select().where(
OnboardingDB.id != onboarding_id,
OnboardingDB.order >= start,
OnboardingDB.order <= end,
)
).order_by(OnboardingDB.order.asc() if step > 0 else OnboardingDB.order.desc())

for p in affected_pages:
p.order += step
p.save() # Save each affected page
p.save()

# Update the target page
# Finally, set the target page to its new order
page.order = order
page.save() # Save the target page

try:
transaction.commit() # Commit the transaction
except Exception as e:
transaction.rollback() # Rollback in case of error
return {"error": str(e)}, 500
return loads(dumps(model_to_dict(page), indent=4, sort_keys=True, default=str)), 200

@api.doc(description="Delete a single onboarding page")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def validate_code(self, _, value: str):
if value is None:
return

# Check that the code is a 6 character string of only letters and numbers
if not isinstance(value, str) or len(value) != 6 or not value.isalnum():
# Check that the code only contains letters and numbers
if not isinstance(value, str) or not value.isalnum():
raise ValidationError("Invalid code")

# Check that the code has not been used
Expand Down Expand Up @@ -104,7 +104,7 @@ def create_code():
raise ValidationError("Unable to generate a unique code")

# If code is None, generate a new code
if not invitation["code"] or len(invitation["code"]) != 6 or not str(invitation["code"]).isalnum():
if not invitation["code"] or not str(invitation["code"]).isalnum():
invitation["code"] = create_code()

# Upper case the code
Expand Down
28 changes: 22 additions & 6 deletions apps/wizarr-frontend/src/assets/scss/md-editor-v3.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
--md-theme-quote-border: 5px solid rgb(208, 49, 67) !important;
--md-theme-link-color: rgb(208, 49, 67) !important;
--md-theme-link-hover-color: rgb(208, 49, 67) !important;
--md-theme-code-inline-color: rgb(208, 49, 67) !important;
--md-theme-code-inline-bg-color: rgba(208, 49, 67, 0.1) !important;
--md-theme-code-block-bg-color: rgb(17, 24, 39) !important;
}

.md-editor.md-editor-dark, .md-editor-modal-container[data-theme='dark'] {
--md-color: #fff;
--md-bk-color: rgb(55, 65, 81);
--md-scrollbar-bg-color: rgb(55, 65, 81);
}

.md-editor.md-editor-previewOnly {
background-color: inherit !important;
}

.md-editor-preview {
Expand All @@ -10,21 +23,24 @@
h1, h2, h3, h4, h5, h6 {
word-break: normal !important;
}
h1, h2, h3, h4, h5, h6 {
> h1, > h2, > h3, > h4, > h5, > h6 {
&:first-child {
margin-top: 0;
}
}
}

.md-editor.md-editor-dark, .md-editor-modal-container[data-theme='dark'] {
--md-color: #fff;
}
.md-editor-preview {
ol {
list-style-type: decimal;
}

.md-editor.md-editor-previewOnly {
background-color: inherit !important;
ul {
list-style-type: disc;
}
}


.md-editor.md-editor-previewOnly .md-editor-preview-wrapper {
padding: inherit !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<FormKit type="form" name="inviteForm" id="inviteForm" @submit="createInvite" :actions="!eventBus" v-model="invitationData" :disabled="disabled" :submit-label="__('Create Invitation')" :submit-attrs="{ inputClass: 'w-full justify-center mt-2' }">
<div class="space-y-4">
<!-- Invite Code -->
<FormKit type="text" placeholder="XMFGEJI" label="Invitation Code" name="inviteCode" validation="length:6,6|uppercase" />
<FormKit type="text" placeholder="XMFGEJI" label="Invitation Code" name="inviteCode" validation="uppercase" />

<!-- Select Expiration -->
<FormKit type="select" label="Invitation Expiration" name="expiration" :options="expirationOptions" />
Expand Down Expand Up @@ -399,8 +399,7 @@ export default defineComponent({
watch: {
"invitationData.inviteCode": {
immediate: true,
handler(inviteCode) {
if (inviteCode.length >= 7) this.invitationData.inviteCode = inviteCode.slice(0, 6);
handler() {
this.invitationData.inviteCode = this.invitationData.inviteCode.replace(/[^a-zA-Z0-9]/g, "");
this.invitationData.inviteCode = this.invitationData.inviteCode.toUpperCase();
},
Expand Down
4 changes: 2 additions & 2 deletions apps/wizarr-frontend/src/modules/home/pages/JoinForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default defineComponent({
methods: {
async join() {
// Check if the code is inputted
if (!this.code || this.code.length !== 6) {
this.$toast.info(this.__('Please enter an invite code'));
if (!this.code) {
this.$toast.info(this.__("Please enter an invite code"));
return;
}

Expand Down
Loading