forked from ScoDoc/ScoDoc
Edition partition parcours. Closes #435.
This commit is contained in:
parent
54bf4a4f0f
commit
251949c220
@ -359,6 +359,8 @@ def partition_create(formsemestre_id: int):
|
|||||||
partition_name = data.get("partition_name")
|
partition_name = data.get("partition_name")
|
||||||
if partition_name is None:
|
if partition_name is None:
|
||||||
return error_response(404, "missing partition_name or invalid data format")
|
return error_response(404, "missing partition_name or invalid data format")
|
||||||
|
if partition_name == scu.PARTITION_PARCOURS:
|
||||||
|
return error_response(404, f"invalid partition_name {scu.PARTITION_PARCOURS}")
|
||||||
if not Partition.check_name(formsemestre, partition_name):
|
if not Partition.check_name(formsemestre, partition_name):
|
||||||
return error_response(404, "invalid partition_name")
|
return error_response(404, "invalid partition_name")
|
||||||
numero = data.get("numero", 0)
|
numero = data.get("numero", 0)
|
||||||
@ -482,7 +484,10 @@ def partition_edit(partition_id: int):
|
|||||||
data = request.get_json(force=True) # may raise 400 Bad Request
|
data = request.get_json(force=True) # may raise 400 Bad Request
|
||||||
modified = False
|
modified = False
|
||||||
partition_name = data.get("partition_name")
|
partition_name = data.get("partition_name")
|
||||||
|
#
|
||||||
if partition_name is not None and partition_name != partition.partition_name:
|
if partition_name is not None and partition_name != partition.partition_name:
|
||||||
|
if partition.is_parcours():
|
||||||
|
return error_response(404, f"can't rename {scu.PARTITION_PARCOURS}")
|
||||||
if not Partition.check_name(
|
if not Partition.check_name(
|
||||||
partition.formsemestre, partition_name, existing=True
|
partition.formsemestre, partition_name, existing=True
|
||||||
):
|
):
|
||||||
@ -502,6 +507,8 @@ def partition_edit(partition_id: int):
|
|||||||
if value is not None and value != getattr(partition, boolean_field):
|
if value is not None and value != getattr(partition, boolean_field):
|
||||||
if not isinstance(value, bool):
|
if not isinstance(value, bool):
|
||||||
return error_response(404, f"invalid type for {boolean_field}")
|
return error_response(404, f"invalid type for {boolean_field}")
|
||||||
|
if boolean_field == "groups_editable" and partition.is_parcours():
|
||||||
|
return error_response(404, f"can't change {scu.PARTITION_PARCOURS}")
|
||||||
setattr(partition, boolean_field, value)
|
setattr(partition, boolean_field, value)
|
||||||
modified = True
|
modified = True
|
||||||
|
|
||||||
|
@ -576,6 +576,7 @@ class FormSemestre(db.Model):
|
|||||||
formsemestre_id=self.id,
|
formsemestre_id=self.id,
|
||||||
partition_name=scu.PARTITION_PARCOURS,
|
partition_name=scu.PARTITION_PARCOURS,
|
||||||
numero=-1,
|
numero=-1,
|
||||||
|
groups_editable=False,
|
||||||
)
|
)
|
||||||
db.session.add(partition)
|
db.session.add(partition)
|
||||||
db.session.flush() # pour avoir un id
|
db.session.flush() # pour avoir un id
|
||||||
|
@ -38,7 +38,7 @@ class Partition(db.Model):
|
|||||||
show_in_lists = db.Column(
|
show_in_lists = db.Column(
|
||||||
db.Boolean(), nullable=False, default=True, server_default="true"
|
db.Boolean(), nullable=False, default=True, server_default="true"
|
||||||
)
|
)
|
||||||
# Editable ? (faux pour les groupes de parcours)
|
# Editable (créer/renommer groupes) ? (faux pour les groupes de parcours)
|
||||||
groups_editable = db.Column(
|
groups_editable = db.Column(
|
||||||
db.Boolean(), nullable=False, default=True, server_default="true"
|
db.Boolean(), nullable=False, default=True, server_default="true"
|
||||||
)
|
)
|
||||||
@ -80,7 +80,7 @@ class Partition(db.Model):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def is_parcours(self) -> bool:
|
def is_parcours(self) -> bool:
|
||||||
"Vrai s'il s'agit de la partitoon de parcours"
|
"Vrai s'il s'agit de la partition de parcours"
|
||||||
return self.partition_name == scu.PARTITION_PARCOURS
|
return self.partition_name == scu.PARTITION_PARCOURS
|
||||||
|
|
||||||
def to_dict(self, with_groups=False) -> dict:
|
def to_dict(self, with_groups=False) -> dict:
|
||||||
|
@ -760,7 +760,7 @@ def setGroups(
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
partition = get_partition(partition_id)
|
partition = get_partition(partition_id)
|
||||||
if not partition["groups_editable"]:
|
if not partition["groups_editable"] and (groupsToCreate or groupsToDelete):
|
||||||
msg = "setGroups: partition non editable"
|
msg = "setGroups: partition non editable"
|
||||||
log(msg)
|
log(msg)
|
||||||
return xml_error(msg, code=403)
|
return xml_error(msg, code=403)
|
||||||
@ -998,36 +998,36 @@ def edit_partition_form(formsemestre_id=None):
|
|||||||
for p in partitions:
|
for p in partitions:
|
||||||
if p["partition_name"] is not None:
|
if p["partition_name"] is not None:
|
||||||
H.append(
|
H.append(
|
||||||
'<tr><td class="epnav"><a class="stdlink" href="partition_delete?partition_id=%s">%s</a> </td><td class="epnav">'
|
f"""<tr><td class="epnav"><a class="stdlink"
|
||||||
% (p["partition_id"], suppricon)
|
href="{url_for("scolar.partition_delete",
|
||||||
|
scodoc_dept=g.scodoc_dept, partition_id=p["partition_id"])
|
||||||
|
}">{suppricon}</a> </td><td class="epnav">"""
|
||||||
)
|
)
|
||||||
if i != 0:
|
if i != 0:
|
||||||
H.append(
|
H.append(
|
||||||
'<a href="partition_move?partition_id=%s&after=0">%s</a>'
|
f"""<a href="{url_for("scolar.partition_move",
|
||||||
% (p["partition_id"], arrow_up)
|
scodoc_dept=g.scodoc_dept, partition_id=p["partition_id"], after=0)
|
||||||
|
}">{arrow_up}</a>"""
|
||||||
)
|
)
|
||||||
H.append('</td><td class="epnav">')
|
H.append('</td><td class="epnav">')
|
||||||
if i < len(partitions) - 2:
|
if i < len(partitions) - 2:
|
||||||
H.append(
|
H.append(
|
||||||
'<a href="partition_move?partition_id=%s&after=1">%s</a>'
|
f"""<a href="{url_for("scolar.partition_move",
|
||||||
% (p["partition_id"], arrow_down)
|
scodoc_dept=g.scodoc_dept, partition_id=p["partition_id"], after=1)
|
||||||
|
}">{arrow_down}</a>"""
|
||||||
)
|
)
|
||||||
i += 1
|
i += 1
|
||||||
H.append("</td>")
|
H.append(
|
||||||
pname = p["partition_name"] or ""
|
f"""</td>
|
||||||
H.append("<td>%s</td>" % pname)
|
<td>{p["partition_name"] or ""}</td>
|
||||||
H.append("<td>")
|
<td>"""
|
||||||
lg = [
|
|
||||||
"%s (%d)"
|
|
||||||
% (
|
|
||||||
group["group_name"],
|
|
||||||
len(get_group_members(group["group_id"])),
|
|
||||||
)
|
)
|
||||||
|
lg = [
|
||||||
|
f"""{group["group_name"]} ({len(get_group_members(group["group_id"]))})"""
|
||||||
for group in get_partition_groups(p)
|
for group in get_partition_groups(p)
|
||||||
]
|
]
|
||||||
H.append(", ".join(lg))
|
H.append(", ".join(lg))
|
||||||
H.append("""</td><td>""")
|
H.append("""</td><td>""")
|
||||||
if p["groups_editable"]:
|
|
||||||
H.append(
|
H.append(
|
||||||
f"""<a class="stdlink" href="{
|
f"""<a class="stdlink" href="{
|
||||||
url_for("scolar.affect_groups",
|
url_for("scolar.affect_groups",
|
||||||
@ -1036,13 +1036,16 @@ def edit_partition_form(formsemestre_id=None):
|
|||||||
}">répartir</a></td>
|
}">répartir</a></td>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
H.append("""non éditable""")
|
|
||||||
H.append("""</td>""")
|
H.append("""</td>""")
|
||||||
|
if p["groups_editable"]:
|
||||||
H.append(
|
H.append(
|
||||||
'<td><a class="stdlink" href="partition_rename?partition_id=%s">renommer</a></td>'
|
f"""<td><a class="stdlink" href="{
|
||||||
% p["partition_id"]
|
url_for("scolar.partition_rename",
|
||||||
|
scodoc_dept=g.scodoc_dept, partition_id=p["partition_id"])
|
||||||
|
}">renommer</a></td>"""
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
H.append("""<td>non éditable</td>""")
|
||||||
# classement:
|
# classement:
|
||||||
H.append('<td width="250px">')
|
H.append('<td width="250px">')
|
||||||
if p["bul_show_rank"]:
|
if p["bul_show_rank"]:
|
||||||
|
@ -16,8 +16,10 @@ href="{{ url_for('scolar.groups_auto_repartition', scodoc_dept=g.scodoc_dept, pa
|
|||||||
<div id="savedinfo"></div>
|
<div id="savedinfo"></div>
|
||||||
<form name="formGroup" id="formGroup" onSubmit="return false;">
|
<form name="formGroup" id="formGroup" onSubmit="return false;">
|
||||||
<input type="hidden" name="partition_id" value="{{ partition.id }}"/>
|
<input type="hidden" name="partition_id" value="{{ partition.id }}"/>
|
||||||
|
{% if partition.groups_editable %}
|
||||||
<input name="groupName" size="6"/>
|
<input name="groupName" size="6"/>
|
||||||
<input type="button" onClick="createGroup();" value="Créer groupe"/>
|
<input type="button" onClick="createGroup();" value="Créer groupe"/>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<input type="button" onClick="submitGroups( target='gmsg' );" value="Enregistrer ces groupes" />
|
<input type="button" onClick="submitGroups( target='gmsg' );" value="Enregistrer ces groupes" />
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user