forked from pennlabs/penn-courses
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from pennlabs/degree-editor
Degree editor
- Loading branch information
Showing
9 changed files
with
380 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,53 @@ | ||
from django.conf.urls import url | ||
from django.contrib import admin | ||
from django.template.response import TemplateResponse | ||
from django.urls import reverse | ||
from django.utils.html import format_html | ||
|
||
from degree.models import Degree, DegreePlan, DoubleCountRestriction, Rule, SatisfactionStatus | ||
|
||
|
||
# Register your models here. | ||
admin.site.register(Degree) | ||
admin.site.register(Rule) | ||
@admin.register(Rule) | ||
class RuleAdmin(admin.ModelAdmin): | ||
search_fields = ["title", "id"] | ||
list_display = ["title", "id", "parent"] | ||
list_select_related = ["parent"] | ||
|
||
|
||
admin.site.register(DegreePlan) | ||
admin.site.register(SatisfactionStatus) | ||
admin.site.register(DoubleCountRestriction) | ||
|
||
|
||
@admin.register(DoubleCountRestriction) | ||
class DoubleCountRestrictionAdmin(admin.ModelAdmin): | ||
autocomplete_fields = ["rule", "other_rule"] | ||
|
||
|
||
@admin.register(Degree) | ||
class DegreeAdmin(admin.ModelAdmin): | ||
autocomplete_fields = ["rules"] | ||
list_display = ["program", "degree", "major", "concentration", "year", "view_degree_editor"] | ||
|
||
def view_degree_editor(self, obj): | ||
return format_html( | ||
'<a href="{url}?id={id}">View in Degree Editor</a>', | ||
id=obj.id, | ||
url=reverse("admin:degree-editor"), | ||
) | ||
|
||
def get_urls(self): | ||
# get the default urls | ||
urls = super().get_urls() | ||
custom_urls = [ | ||
url( | ||
r"^degree-editor/$", | ||
self.admin_site.admin_view(self.degree_editor), | ||
name="degree-editor", | ||
) | ||
] | ||
return custom_urls + urls | ||
|
||
def degree_editor(self, request): | ||
context = dict(self.admin_site.each_context(request)) | ||
return TemplateResponse(request, "degree-editor.html", context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Generated by Django 3.2.23 on 2024-02-07 06:05 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('courses', '0061_merge_20231112_1524'), | ||
('degree', '0006_auto_20240205_1950'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='degreeplan', | ||
name='degrees', | ||
field=models.ManyToManyField(help_text='The degrees this degree plan is associated with.', to='degree.Degree'), | ||
), | ||
migrations.AlterField( | ||
model_name='degreeplan', | ||
name='person', | ||
field=models.ForeignKey(help_text='The user the degree plan belongs to.', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AlterField( | ||
model_name='doublecountrestriction', | ||
name='max_courses', | ||
field=models.PositiveSmallIntegerField(help_text='\nThe maximum number of courses you can count for both rules.\nIf null, there is no limit, and max_credits must not be null.\n', null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='doublecountrestriction', | ||
name='max_credits', | ||
field=models.DecimalField(decimal_places=2, help_text='\nThe maximum number of CUs you can count for both rules.\nIf null, there is no limit, and max_credits must not be null.\n', max_digits=4, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='doublecountrestriction', | ||
name='rule', | ||
field=models.ForeignKey(help_text='\nA rule in the double count restriction.\n', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='degree.rule'), | ||
), | ||
migrations.AlterField( | ||
model_name='fulfillment', | ||
name='historical_course', | ||
field=models.ForeignKey(help_text='\nThe last offering of the course with the full code, or null if\nthere is no such historical course.\n', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='courses.course'), | ||
), | ||
migrations.AlterField( | ||
model_name='rule', | ||
name='q', | ||
field=models.TextField(blank=True, help_text='\nString representing a Q() object that returns the set of courses\nsatisfying this rule. Non-empty iff this is a Rule leaf.\nThis Q object is expected to be normalized before it is serialized\nto a string.\n', max_length=1000), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.editor { | ||
height: 100%; | ||
width: 100%; | ||
font-family: "Space Mono", "Arial", sans-serif; | ||
} | ||
|
||
.react-flow__handle-top { | ||
background-color: blue; | ||
} | ||
|
||
.react-flow__handle-bottom { | ||
background-color: red; | ||
} | ||
|
||
.react-flow__handle-connecting .react-flow__handle-valid { | ||
width: 8px; | ||
height: 8px; | ||
} | ||
|
||
.react-flow__handle-connecting:not(.react-flow__handle-valid) { | ||
background-color: darkgray; | ||
} | ||
|
||
#content { | ||
width: 100%; | ||
height: 80vh; | ||
padding: 0; | ||
} |
Oops, something went wrong.