Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Project Allocator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
edtech
Project Allocator
Commits
c526d2d7
Commit
c526d2d7
authored
2 years ago
by
Andrea Callia D'Iddio
Browse files
Options
Downloads
Patches
Plain Diff
Feat: add endpoint and related page for ranking management for lecturers.
parent
b0caac87
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#307836
passed
2 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/models/project.py
+4
-0
4 additions, 0 deletions
app/models/project.py
app/templates/pages/staff/projects-ranking.html
+64
-0
64 additions, 0 deletions
app/templates/pages/staff/projects-ranking.html
app/views/staff.py
+12
-1
12 additions, 1 deletion
app/views/staff.py
with
80 additions
and
1 deletion
app/models/project.py
+
4
−
0
View file @
c526d2d7
...
...
@@ -11,5 +11,9 @@ class Project(db.Model):
timestamp
=
db
.
Column
(
db
.
DateTime
,
nullable
=
False
,
server_default
=
utcnow
())
deleted
=
db
.
Column
(
db
.
DateTime
)
shortlistings
=
db
.
relationship
(
"
Shortlisting
"
,
backref
=
"
project
"
,
lazy
=
True
,
cascade
=
"
all,delete-orphan
"
)
def
is_student_proposal
(
self
)
->
bool
:
return
self
.
on_behalf
is
not
None
This diff is collapsed.
Click to expand it.
app/templates/pages/staff/projects-ranking.html
0 → 100644
+
64
−
0
View file @
c526d2d7
{% extends "components/layout.html" %}
{% block content %}
<div
class=
"w3-content"
>
<div
class=
"w3-container"
>
<section
class=
"w3-section"
>
<h1
class=
"w3-center w3-text-blue"
>
Who wants to do a project with you
</h1>
<ul
class=
"w3-ul"
id=
"projects"
>
{% for shortlisting in projects %}
<li
class=
"w3-display-container"
data-id=
"{{ shortlisting.id }}"
>
<span
class=
"w3-bar-item sort-list-handle"
>
<i
class=
"fa-solid fa-bars"
></i>
 
</span>
<span>
{{ shortlisting.project.title }} - {{ shortlisting.student }}
</span>
</li>
{% endfor %}
</ul>
</section>
<button
id=
"save-button"
type=
"button"
class=
"w3-btn w3-blue w3-right"
>
Save
</button>
</div>
</div>
{% endblock %}
{% block scripts %}
<script
src=
"{{ url_for('static', filename='js/lib/sortable.min.js') }}"
></script>
<script>
const
projectList
=
document
.
getElementById
(
"
projects
"
)
const
sortableProjectList
=
Sortable
.
create
(
projectList
,
{
handle
:
"
.sort-list-handle
"
,
ghostClass
:
"
ghost
"
,
})
/*
const saveButton = document.getElementById("save-button")
saveButton.addEventListener("click", async () => {
saveButton.setAttribute("disabled", "")
saveButton.innerHTML = "Saving..."
await fetch("{{ url_for("student.update_ranking") }}", {
method: 'put',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(sortableProjectList.toArray().map(id => parseInt(id)))
})
.then((response) => {
saveButton.removeAttribute("disabled")
if (!response.ok) {
saveButton.classList.replace("w3-blue", "w3-red")
saveButton.innerHTML = "Error!"
} else {
saveButton.classList.replace("w3-blue", "w3-green")
saveButton.innerHTML = "Saved!"
setTimeout(() => {
saveButton.classList.remove("w3-green", "w3-red")
saveButton.classList.add("w3-blue")
saveButton.innerHTML = "Save"
}, 5000)
}
})
}) */
</script>
{% endblock %}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/views/staff.py
+
12
−
1
View file @
c526d2d7
...
...
@@ -3,7 +3,7 @@ from datetime import datetime
from
flask
import
render_template
,
Blueprint
,
redirect
,
url_for
,
flash
from
flask_login
import
login_required
,
current_user
from
app
import
Project
,
db
,
messages
from
app
import
Project
,
db
,
messages
,
Shortlisting
from
app.forms.project
import
ProjectForm
bp
=
Blueprint
(
"
staff
"
,
__name__
,
url_prefix
=
"
/staff
"
)
...
...
@@ -63,3 +63,14 @@ def edit_project(project_id):
return
render_template
(
"
pages/project-form.html
"
,
form
=
form
,
project
=
project
)
flash
(
messages
.
PROJECT_NOT_FOUND
)
return
redirect
(
url_for
(
"
staff.projects
"
))
@bp.route
(
"
/projects/ranking
"
)
@login_required
def
projects_ranking
():
projects
:
list
[
Shortlisting
]
=
(
Shortlisting
.
query
.
join
(
Project
)
.
filter
(
Project
.
proposer
==
current_user
.
username
)
.
all
()
)
return
render_template
(
"
pages/staff/projects-ranking.html
"
,
projects
=
projects
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment