portal_assignments.xml
<template id="portal_student_submit_assignment_data" name="portal_student_submit_assignment_data">
<t t-call="portal.portal_layout">
<t t-call="portal.portal_searchbar">
<t t-set="title">Submit Assignment</t>
</t>
<t t-if="not student_ids">
<p>There are currently no information for your account!!!</p>
</t>
<t t-if="student_ids">
<div style="background-color:white; padding: 20px 40px 20px 40px;">
<div class="mt16">
<form action="/assignment/submited" method="post" role="form" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<div class="row">
<div class="col-md-6">
<div class="row col-md-12">
<div class="col-md-4">
<label class="col-form-label" for="Name">
<strong>Name:</strong>
</label>
</div>
<div class="col-md-8">
<t t-foreach="student_ids" t-as="student">
<t t-if="student_index == 0">
<!--<input type="hidden" name="Name" t-att-value="student_ids.id"/>-->
<input type="Text" name="Name" t-attf-class="form-control"
t-att-value="student.student_id.name"/>
</t>
</t>
</div>
</div>
<div class="row mt8 col-md-12">
<div class="col-md-4">
<label class="col-form-label" for="Date">
<strong>Submit Date:</strong>
</label>
</div>
<div class="col-md-8">
<input type="text" name="Date" t-attf-class="form-control "
t-att-value="datetime.datetime.now().strftime('%Y-%m-%d')"/>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row col-md-12">
<div class="col-md-4 mt8">
<label for="assignment_id">Assignment:</label>
</div>
<div class=" col-md-8">
<select class="form-control" name="assignment_id" required="1">
<option value="" class="disabled selected">
<lable>Select your option</lable>
</option>
<t t-foreach="student_ids or []" t-as="assignment">
<t t-foreach="assignment.student_id.allocation_ids"
t-as="student">
<t t-if="student.state == 'publish' and assignment_index == 0">
<option t-att-value="assignment_id">
<t t-esc="student.name"/>
</option>
</t>
</t>
</t>
</select>
</div>
</div>
<div class="form-group mt8 row col-md-12">
<div class="col-md-4 mt8">
<label>Attachments:</label>
</div>
<div class="col-md-8 mt8">
<input type="file" multiple="true" name="attachments"
class="inputfile"/>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-4">
<label class="col-form-label" for="Description">
<strong>Description:</strong>
</label>
</div>
<div class="col-md-12">
<textarea class="form-control o_website_form_input" name="Description">
</textarea>
</div>
</div>
<div class="mt8 col-md-12">
<div class="col-md-4">
<label class="col-form-label" for="Note">
<strong>Note:</strong>
</label>
</div>
<div class="col-md-12">
<textarea class="form-control o_website_form_input" name="Note">
</textarea>
</div>
</div>
</div>
<div class="clearfix mt16 mb16 row col-md-12">
<div class="col-md-4">
<button type="submit" class="btn btn-primary">
SUBMIT
<span class="fa fa-long-arrow-right"/>
</button>
</div>
</div>
</form>
</div>
</div>
</t>
</t>
</template>
controllers.py file
class PortalAssignments(http.Controller):
@http.route('/assignment/submit', type='http', auth='public', website=True)
def portal_student_submit_assignment_data(self, **kw):
student_ids = request.env['op.assignment.sub.line'].sudo().search([('user_id', '=', request.session.uid)])
return request.render("portal_assignments.portal_student_submit_assignment_data", {'student_ids': student_ids})