Skip to content

Commit

Permalink
Merge branch 'master' into wsevent-dirty-json
Browse files Browse the repository at this point in the history
  • Loading branch information
leduythuccs authored Oct 6, 2023
2 parents 176ff5b + 019edcf commit 9dbecba
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 19 deletions.
6 changes: 6 additions & 0 deletions judge/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ class Meta:
if settings.VNOJ_OFFICIAL_CONTEST_MODE:
fields.remove('first_name')

def clean_first_name(self):
first_name = self.cleaned_data['first_name']
if len(first_name) > 30:
raise ValidationError(_('Your full name is too long!'), code='NAME_LIMIT_EXCEEDED')
return first_name


class ProposeProblemSolutionForm(ModelForm):
class Meta:
Expand Down
17 changes: 2 additions & 15 deletions make_style.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
#!/bin/bash
if ! [ -x "$(command -v npx sass)" ]; then
echo 'Error: sass is not installed.' >&2
exit 1
fi

if ! [ -x "$(command -v npx postcss)" ]; then
echo 'Error: postcss is not installed.' >&2
exit 1
fi

if ! [ -x "$(command -v npx autoprefixer)" ]; then
echo 'Error: autoprefixer is not installed.' >&2
exit 1
fi

cd "$(dirname "$0")" || exit

node scripts/check-package-installed.js postcss sass autoprefixer || exit

build_style() {
echo "Creating $1 style..."
cp resources/vars-$1.scss resources/vars.scss
Expand Down
28 changes: 28 additions & 0 deletions scripts/check-package-installed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @ts-check
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);

if (process.argv.length < 3) {
throw new Error("Please specify a package/packages to check.");
}

/**
* @type {string[]}
*/
const failedPackages = [];

for (let i = 2; i < process.argv.length; ++i) {
const packageName = process.argv[i];
try {
require(packageName);
} catch {
failedPackages.push(packageName);
}
}

if (failedPackages.length !== 0) {
throw new Error(
`${failedPackages.join(", ")} ${failedPackages.length === 1 ? "is" : "are"} not installed.`,
);
}
12 changes: 8 additions & 4 deletions templates/user/edit-profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,18 @@
{% block body %}
<div class="centered-form">
<form id="edit-form" action="" method="post" class="form-area">
{% if form.errors %}
{% if form.errors or form_user.errors %}
<div class="alert alert-danger alert-dismissable">
<a href="#" class="close">x</a>
{{ form.non_field_errors() }}
{{ form.about.errors }}
{% if form.errors %}
{{ form.non_field_errors() }}
{{ form.about.errors }}
{% endif %}
{% if form_user.errors %}
{{ form_user.first_name.errors }}
{% endif %}
</div>
{% endif %}

{% csrf_token %}
{% if form_user.first_name %}
<table>
Expand Down

0 comments on commit 9dbecba

Please sign in to comment.