Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Nov 16, 2024
1 parent e55d1e6 commit 46e2c8d
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 16 deletions.
3 changes: 3 additions & 0 deletions tin/apps/assignments/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class LanguageAdmin(admin.ModelAdmin):
list_filter = ("language",)
actions = ["make_deprecated"]

# prevent someone from accidentally using this
exclude = ("use_java_folder",)

@admin.action(description="Mark languages as deprecated")
def make_deprecated(self, request, queryset) -> None:
changed = 0
Expand Down
2 changes: 1 addition & 1 deletion tin/apps/assignments/migrations/0033_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Migration(migrations.Migration):
('name', models.CharField(help_text='The name of the language', max_length=50)),
('executable', models.CharField(help_text='The path to the language executable', max_length=100)),
('use_java_folder', models.BooleanField(default=False, help_text="Store the assignment grader in the Java folder, regardless of language")),
('version', models.PositiveSmallIntegerField(help_text="The version of the executable. 0 if executable is /dev/null.")),
('version', models.PositiveSmallIntegerField(help_text="The version of the executable.")),
],
options={'ordering': ['-language', '-version']},
),
Expand Down
11 changes: 2 additions & 9 deletions tin/apps/assignments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,12 +685,7 @@ def run(self, assignment: Assignment):


class Language(models.Model):
"""Which version of a language is used for an assignment.
.. tip::
Use :attr:`executable` over :attr:`path`.
"""
"""Which version of a language is used for an assignment."""

LANGUAGES = (
("P", "Python 3"),
Expand All @@ -703,9 +698,7 @@ class Language(models.Model):
is_deprecated = models.BooleanField(default=False)

# for decimals like 3.10, use 310
version = models.PositiveSmallIntegerField(
help_text="The version of the executable. 0 if executable is /dev/null."
)
version = models.PositiveSmallIntegerField(help_text="The version of the executable.")

# This is deprecated, new models should NOT use this attribute.
use_java_folder = models.BooleanField(
Expand Down
2 changes: 0 additions & 2 deletions tin/apps/submissions/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ def run_submission(submission_id):
if submission.assignment.venv_fully_created
else submission.assignment.language_details.executable
)
if python_exe is None:
return

if not settings.DEBUG or shutil.which("bwrap") is not None:
folder_name = "sandboxed"
Expand Down
1 change: 1 addition & 0 deletions tin/apps/venvs/migrations/0006_venv_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def delete_python_310_from_venvs(apps, schema_editor):
executable="/usr/bin/python3.10",
language="P",
version=310,
is_deprecated=False,
)
.first()
)
Expand Down
2 changes: 0 additions & 2 deletions tin/apps/venvs/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ def create_venv(venv_id):
success = False
try:
python = venv.language.executable
if python is None:
raise VenvCreationError("No Python executable found")
try:
res = subprocess.run(
[
Expand Down
4 changes: 2 additions & 2 deletions tin/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ def course(teacher, student):

@pytest.fixture
def python():
major, minor, micro = platform.python_version_tuple()
major, minor, _micro = platform.python_version_tuple()
return Language.objects.create(
name=f"Python {platform.python_version()}",
executable=sys.executable,
language="P",
version=int(f"{major}{minor}{micro}"),
version=int(f"{major}{minor}"),
)


Expand Down

0 comments on commit 46e2c8d

Please sign in to comment.