Skip to content

Permission System

How LCOJ checks permissions, how to grant them through groups or directly in the admin site, and the full list of custom permissions.

⏱ ~10 min (granting) · 👤 System administrators · 🔑 Superuser (or staff with auth.change_group / auth.change_user)

When you need this page

Use this page when someone needs to do something a regular account cannot (setting problems, running contests, moderating comments, and so on), or when someone reports "permission denied" and you need to know which permission is missing. The first part explains how to grant permissions; the rest is a reference table.

LCOJ uses Django's permission system: every sensitive action (editing a problem, rejudging, viewing a private contest, and so on) is checked against a permission named <app>.<codename>, for example judge.edit_own_problem. This page lists every custom LCOJ permission, explains what each one lets you do, and shows how to grant permissions in the admin site.

How permissions work

ConceptMeaning
SuperuserHas every permission automatically. Reserve it for system administrators.
Staff (is_staff)Lets the user sign in to the admin site at /admin/. It grants nothing else on its own; you still need to assign specific permissions.
User permissionsPermissions assigned directly to one account.
GroupsA named set of permissions. Members of a group get all of the group's permissions.

A user's effective permissions are their direct permissions plus the permissions of every group they belong to. There is no way to "deny" a permission; to revoke one, remove it from the user or remove the user from the group.

Prefer groups

Create one group per role (for example "Problem setters" or "Contest organizers") and add people to it. When a role needs different permissions, you only edit the group once.

Granting permissions in the admin site

  1. Go to /admin/auth/group/ (for example https://luyencode.net/admin/auth/group/).
  2. Click Add to create a new group and give it a name (for example "Problem setters").
  3. In the Permissions box, select the permissions you need and click the arrow to move them to the chosen column. Type a codename (for example edit_own_problem) in the filter box to find it quickly.
  4. Save the group.
  5. Go to /admin/auth/user/, open the account, add the group under Groups, and save.

Option 2: Directly on a user

  1. Go to /admin/auth/user/ and open the account.
  2. If the person needs the admin site, turn on Staff status.
  3. Under User permissions, select the permissions. Each entry is shown as judge.edit_own_problem | Edit own problems (app, codename, then label).
  4. Save.

Verify

  • The person reloads the page and tries the action that needs the permission (for example Edit problem on one of their problems).
  • If the role needs the admin site, they can open /admin/ and see the matching sections.

Search by codename

Permission labels are stored in the database in English, and many of them have no Vietnamese translation. Search for permissions by codename (the first column in the tables below). If labels in the database are out of date after a code update, run ./scripts/manage.py update_permissions (see Management commands).

Django's default permissions

For every model, Django creates four permissions automatically: add_<model>, change_<model>, delete_<model>, and view_<model> (for example judge.change_problem). They mostly control which admin pages a staff user can see and use. Some admin pages also check the custom permissions below; for example, editing an organization in the admin requires judge.change_organization, and which organizations you can edit depends on judge.edit_all_organization.

Custom permissions

Permissions are grouped by the object they apply to. The Label column is the name shown in the admin.

Problems (judge · Problem)

CodenameLabelWhat it allows
see_private_problemSee hidden problemsView every problem, including hidden (non-public) problems and organization-private problems.
edit_own_problemEdit own problemsEdit problems where you are an author or curator. Required for edit_public_problem and edit_all_problem to take effect. Also needed to use the submission admin for your own problems.
edit_public_problemEdit all public problemsEdit every public problem, and view or edit submissions to those problems.
edit_all_problemEdit all problemsEdit every problem; view all submissions and all organization-private problems.
create_organization_problemCreate organization problemCreate private problems inside an organization you administer.
problem_full_markupEdit problems with full markupTurn full markup (unsanitized HTML in the statement) on or off, and edit problems that use it.
clone_problemClone problemClone a problem you can edit.
upload_file_statementUpload file-type statementUpload a file (PDF) statement.
change_public_visibilityChange is_public fieldChange a problem's is_public field and use the bulk "make public / make private" admin actions.
change_manually_managedChange is_manually_managed fieldChange the is_manually_managed field (test data managed by hand on the judge servers).
see_organization_problemSee organization-private problemsView private problems of any organization, even without membership.
import_polygon_packageImport Codeforces Polygon packageImport problems from a Codeforces Polygon package.
edit_type_group_all_problemEdit type and group for all problemsEdit the type and group of any problem (without needing edit access to the problem).

Solutions (judge · Solution)

CodenameLabelWhat it allows
see_private_solutionSee hidden solutionsView editorials that are not public yet or not past their publish time. Anyone who can edit the problem can also see its editorial.

Submissions (judge · Submission)

CodenameLabelWhat it allows
abort_any_submissionAbort any submissionAbort anyone's submission. Without it, users can only abort their own submissions (and not in official contest mode).
rejudge_submissionRejudge the submissionRejudge submissions to problems you can edit (also requires edit_own_problem).
rejudge_submission_lotRejudge a lot of submissionsBulk rejudge: go past DMOJ_SUBMISSIONS_REJUDGE_LIMIT (default 10) submissions per action in the admin, and use rejudge on a problem's manage-submissions page.
spam_submissionSubmit without limitSubmit without a queue limit. Users without it can have at most DMOJ_SUBMISSION_LIMIT (default 2) submissions waiting to be judged at once.
view_all_submissionView all submissionView the source code of every submission.
resubmit_otherResubmit others' submissionResubmit someone else's submission.
lock_submissionChange lock status of submissionEdit a submission's locked_after field in the admin.

Contests (judge · Contest)

CodenameLabelWhat it allows
see_private_contestSee private contestsView every contest, including hidden, private, and organization-private contests.
edit_own_contestEdit own contestsEdit contests where you are an author or curator; required to open the contest change page in the admin.
edit_all_contestEdit all contestsView and edit every contest.
clone_contestClone contestClone a contest you can edit.
moss_contestMOSS contestRun MOSS (plagiarism detection) on a contest. The MOSS tab always appears for users with this permission, but it only works once a valid MOSS_API_KEY is set; without a key, running MOSS fails.
contest_ratingRate contestsMake a contest rated (the is_rated, rate_all, rate_exclude fields) and run rating recalculation in the admin.
contest_access_codeContest access codesSet a contest's access code (access_code).
create_private_contestCreate private contestsMake a contest private or organization-private (the is_private, private_contestants, is_organization_private, organization fields); create contests inside an organization you administer.
change_contest_visibilityChange contest visibilityMake any contest visible (is_visible). Users with only create_private_contest can make only private or organization-private contests visible.
contest_problem_labelEdit contest problem label scriptEdit the contest's problem label script (problem_label_script).
lock_contestChange lock status of contestLock a contest (locked_after) and use the bulk lock/unlock admin actions.

For choosing a contest format and its configuration, see Contest formats.

Organizations (judge · Organization)

CodenameLabelWhat it allows
organization_adminAdminister organizationsIn the admin: edit an organization's admin list, is_open, slots, and judging credit (paid_credit, monthly free credit limit).
edit_all_organizationEdit all organizationsEdit every organization without being one of its admins; join closed or unlisted organizations from the profile form.
change_open_organizationChange is_open fieldHas no effect on its own: the is_open field in the admin is controlled by organization_admin, so grant that permission instead.
spam_organizationCreate organization without limitCreate organizations beyond VNOJ_ORGANIZATION_ADMIN_LIMIT (default: admin of 3 organizations). See the note below.

spam_organization only works for superusers

Currently only superusers can go past the organization limit. Granting this permission to a regular user does not lift the limit for them.

Users (judge · Profile)

CodenameLabelWhat it allows
test_siteShows in-progress development stuffThe "Enable experimental features" flag. Every user can turn it on or off on their own profile edit page; no feature currently uses this flag.
totpEdit TOTP settingsView and edit a user's TOTP key and scratch codes (two-factor authentication) in the admin.
can_upload_imageCan upload image directly to server via martorUpload images to the server from the Markdown editor. Staff users are always allowed.
high_problem_timelimitCan set high problem timelimitSet a problem time limit above VNOJ_PROBLEM_TIMELIMIT_LIMIT (default 5 seconds).
long_contest_durationCan set long contest durationSet a contest duration above VNOJ_CONTEST_DURATION_LIMIT (default 14 days).
create_mass_testcasesCan create unlimitted number of testcases for a problemCreate more than VNOJ_TESTCASE_HARD_LIMIT (default 100) test cases for a problem, without the warning shown past VNOJ_TESTCASE_SOFT_LIMIT (default 50).
ban_userBan usersBan user accounts. You cannot ban yourself or a superuser.

Blog posts (judge · BlogPost)

CodenameLabelWhat it allows
edit_all_postEdit all postsEdit every post; see all organization posts, including unpublished ones.
edit_organization_postEdit organization postsCreate posts inside an organization you administer.
mark_global_postMark post as globalMark an organization post as "global" (shown on the home page).
pin_postPin postPin a post (the sticky field).
manage_magazine_postManage magazine blog postsEdit a post's tags, authors, and summary in the post editor.

Comments (judge · Comment, CommentLock)

CodenameLabelWhat it allows
view_all_user_commentView all comments by a userOpen the page listing all of a user's comments and hide those comments in bulk.
override_comment_lockOverride comment lockComment on pages where comments are locked.

Quizzes (quiz · QuizQuestion)

CodenameLabelWhat it allows
edit_own_quizEdit own quizzes and questionsWrite your own questions and quizzes; browse the public question bank.
edit_all_quizEdit all quizzes and questionsView and edit every question and quiz.

For details, see Quiz authoring.

URL shortener (urlshortener)

The URL shortener app has no custom permissions; it uses Django's four default permissions: urlshortener.view_urlshortener, add_urlshortener, change_urlshortener, and delete_urlshortener. For details, see URL shortener.

Suggested roles

These are starting points; adjust them to your needs. Remember to turn on Staff status if the role needs the admin site.

RoleSuggested permissions
Problem setteredit_own_problem, clone_problem, rejudge_submission, upload_file_statement, can_upload_image
Senior problem setterThe above, plus edit_public_problem or edit_all_problem, see_private_problem, change_public_visibility, rejudge_submission_lot, import_polygon_package
Contest organizeredit_own_contest, clone_contest, contest_access_code, create_private_contest, moss_contest, contest_problem_label
Moderatoredit_all_post, pin_post, override_comment_lock, view_all_user_comment, ban_user
Quiz teacheredit_own_quiz

Grant permissions carefully

  • problem_full_markup allows unsanitized HTML in problem statements; grant it only to people you fully trust.
  • edit_all_problem, edit_all_contest, and view_all_submission expose everyone's contest data and source code.
  • Review group and user permissions regularly, and remove permissions from people who are no longer involved.

Troubleshooting

SymptomFix
Cannot open /admin/ despite having permissionsTurn on Staff status for the account.
Has edit_all_problem but still cannot edit problemsAlso grant edit_own_problem; without it, edit_public_problem and edit_all_problem have no effect.
Cannot find a permission in the listSearch by codename instead of the label. If labels are stale, run ./scripts/manage.py update_permissions.
Granted spam_organization but the user is still limitedThis permission currently only works for superusers (see the warning under Organizations).
Bulk rejudge is capped at 10 submissionsAlso grant rejudge_submission_lot.

Next steps