Browse Source

July 25: [FIX] Bug Fixed 'education_university_management'

pull/331/head
Cybrosys Technologies 11 months ago
parent
commit
7b6eb57803
  1. 2
      education_university_management/__manifest__.py
  2. 17
      education_university_management/controllers/education_online_application.py
  3. 2
      education_university_management/models/university_department.py
  4. 48
      education_university_management/static/src/js/online_application.js
  5. 84
      education_university_management/views/online_application_templates.xml

2
education_university_management/__manifest__.py

@ -21,7 +21,7 @@
############################################################################### ###############################################################################
{ {
'name': ' University Education Management', 'name': ' University Education Management',
'version': '17.0.1.0.0', 'version': '17.0.1.0.1',
'category': 'Industries', 'category': 'Industries',
'summary': """This modules helps to manage the university 'summary': """This modules helps to manage the university
education system""", education system""",

17
education_university_management/controllers/education_online_application.py

@ -38,7 +38,7 @@ class OnlineAdmission(http.Controller):
to the website registration form.""" to the website registration form."""
vals = { vals = {
'department': request.env['university.department'].sudo().search( 'department': request.env['university.department'].sudo().search(
[]), [('semester_ids', '!=', False)]),
'course': request.env['university.course'].sudo().search([]), 'course': request.env['university.course'].sudo().search([]),
'semester': request.env['university.semester'].sudo().search([]), 'semester': request.env['university.semester'].sudo().search([]),
'year': request.env['university.academic.year'].sudo().search([]), 'year': request.env['university.academic.year'].sudo().search([]),
@ -58,7 +58,7 @@ class OnlineAdmission(http.Controller):
'name': post.get('father'), 'name': post.get('father'),
'is_parent': True 'is_parent': True
}) })
request.env['university.application'].sudo().create({ application = request.env['university.application'].sudo().create({
'name': post.get('first_name'), 'name': post.get('first_name'),
'last_name': post.get('last_name'), 'last_name': post.get('last_name'),
'mother_name': post.get('mother'), 'mother_name': post.get('mother'),
@ -74,7 +74,18 @@ class OnlineAdmission(http.Controller):
'street': post.get('communication_address'), 'street': post.get('communication_address'),
'per_street': post.get('communication_address'), 'per_street': post.get('communication_address'),
'guardian_id': guardian.id, 'guardian_id': guardian.id,
'image': base64.b64encode(post.get('image').encode('utf-8')) 'image': base64.b64encode((post.get('image')).read())
})
doc_attachment = request.env['ir.attachment'].sudo().create({
'name': post.get('att').filename,
'res_name': 'Document',
'type': 'binary',
'datas': base64.encodebytes((post.get('att')).read()),
})
request.env['university.document'].sudo().create({
'document_type_id': post.get('doc_type'),
'attachment_ids': doc_attachment,
'application_ref_id': application.id
}) })
return request.render( return request.render(
"education_university_management.submit_admission", "education_university_management.submit_admission",

2
education_university_management/models/university_department.py

@ -35,5 +35,5 @@ class UniversityDepartment(models.Model):
help="In what course the department belongs") help="In what course the department belongs")
semester_ids = fields.One2many('university.semester', semester_ids = fields.One2many('university.semester',
'department_id', 'department_id',
string="Semester", readonly=True, string="Semester", required=1,
help="List of semesters under every course") help="List of semesters under every course")

48
education_university_management/static/src/js/online_application.js

@ -6,7 +6,8 @@ publicWidget.registry.OnlineApplication = publicWidget.Widget.extend({
selector: '#online_appl_form', selector: '#online_appl_form',
events: { events: {
'change select[name="course"]': '_onCourseChange', 'change select[name="course"]': '_onCourseChange',
'change select[name="department"]': '_onDepartmentChange', 'change select[name="semester"]': '_onSemesterChange',
'submit form': '_onFormSubmit',
}, },
init() { init() {
this._super(...arguments); this._super(...arguments);
@ -16,27 +17,46 @@ publicWidget.registry.OnlineApplication = publicWidget.Widget.extend({
ev.preventDefault(); ev.preventDefault();
var self = this var self = this
var course = ev.currentTarget.value; var course = ev.currentTarget.value;
self.$el.find('select[name="department"]').find('option').remove() self.$el.find('select[name="semester"]').find('option').remove()
self.$el.find('select[name="department"]').append("<option value=0></option>"); self.$el.find('select[name="semester"]').append("<option value=0></option>");
self.$el.find('select[name="department"]').append("<option value=0></option>");
const result = await this.orm.searchRead( const result = await this.orm.searchRead(
'university.department', 'university.semester',
[['course_id', '=', parseInt(course)]],['name'] [['department_id.course_id', '=', parseInt(course)]],['name']
) )
result.forEach(function(item){ result.forEach(function(item){
self.$el.find('select[name="department"]').append("<option value=" + item['id'] + ">" +item['name'] + "</option>"); self.$el.find('select[name="semester"]').append("<option value=" + item['id'] + ">" +item['name'] + "</option>");
}) })
}, },
async _onDepartmentChange(ev){ async _onSemesterChange(ev){
var self = this var self = this
var department = ev.currentTarget.value; var semester = ev.currentTarget.value;
self.$el.find('select[name="semester"]').find('option').remove() self.$el.find('select[name="department"]').find('option').remove()
self.$el.find('select[name="semester"]').append("<option value=0></option>"); self.$el.find('select[name="department"]').append("<option value=0></option>");
const result = await this.orm.searchRead( const result = await this.orm.searchRead(
'university.semester', 'university.department',
[['department_id', '=', parseInt(department)]],['name'] [['semester_ids', 'in', [parseInt(semester)]]],['name']
) )
result.forEach(function(item){ result.forEach(function(item){
self.$el.find('select[name="semester"]').append("<option value=" + item['id'] + ">" +item['name'] + "</option>"); self.$el.find('select[name="department"]').append("<option value=" + item['id'] + ">" +item['name'] + "</option>");
}) })
} },
_onFormSubmit(ev) {
ev.preventDefault();
// Validate fields
const course = this.$('select[name="course"]').val();
const semester = this.$('select[name="semester"]').val();
const department = this.$('select[name="department"]').val();
if (!course || !semester || department==0) {
// If any required field is empty, show validation error
this._displayErrorMessage('Some Fields are Empty!');
return;
}
ev.currentTarget.submit();
},
_displayErrorMessage(message) {
// Display error message near the submit button or form
const errorMessage = `<div class="alert alert-danger" role="alert">${message}</div>`;
this.$('.form-error-message').html(errorMessage);
},
}) })

84
education_university_management/views/online_application_templates.xml

@ -39,10 +39,11 @@
</div> </div>
</section> </section>
<div id="wrap" class="wrap student-booking-widget"> <div id="wrap" class="wrap student-booking-widget">
<div class="container" id="online_appl_form" t-ref="body"> <div class="container" id="online_appl_form">
<form action="/admission/submit"> <form action="/admission/submit" method="POST"
<!-- <input type="hidden" name="csrf_token"--> enctype="multipart/form-data">
<!-- t-att-value="request.csrf_token()"/>--> <input type="hidden" name="csrf_token"
t-att-value="request.csrf_token()"/>
<div class="card" style="width:75%;border:none;"> <div class="card" style="width:75%;border:none;">
<br/> <br/>
<br/> <br/>
@ -139,7 +140,7 @@
</label> </label>
<div class="col"> <div class="col">
<input id="mother" type="text" <input id="mother" type="text"
class="form-control s_website_form_input" class="form-control s_website_form_input"
name="mother" required="1"/> name="mother" required="1"/>
</div> </div>
</div> </div>
@ -206,41 +207,35 @@
<div class="col"> <div class="col">
<label for="studio1"> <label for="studio1">
<span class="s_website_form_label_content"> <span class="s_website_form_label_content">
Department Semester
</span> </span>
</label> </label>
<div class="col"> <div class="col">
<select name="department" <select name="semester"
class="form-control"> class="form-control">
<option></option> <!-- <t t-foreach="semester"-->
<!-- <t t-foreach="department"--> <!-- t-as="rec">-->
<!-- t-as="rec">--> <!-- <option t-att-value="rec.id">-->
<!-- <option t-att-value="rec.id">--> <!-- <t t-esc="rec.name"/>-->
<!-- <t t-esc="rec.name"/>--> <!-- </option>-->
<!-- </option>--> <!-- </t>-->
<!-- </t>-->
</select> </select>
</div> </div>
</div> </div>
<div class="col"> <div class="col">
<label for="studio1"> <label for="studio1">
<span class="s_website_form_label_content"> <span class="s_website_form_label_content">
Semester Department
</span> </span>
</label> </label>
<div class="col"> <div class="col">
<select name="semester" <select name="department" required="1"
class="form-control"> class="form-control">
<option></option> <option></option>
<!-- <t t-foreach="semester"-->
<!-- t-as="rec">-->
<!-- <option t-att-value="rec.id">-->
<!-- <t t-esc="rec.name"/>-->
<!-- </option>-->
<!-- </t>-->
</select> </select>
</div> </div>
</div> </div>
<div class="col"> <div class="col">
<label for="studio1"> <label for="studio1">
<span class="s_website_form_label_content"> <span class="s_website_form_label_content">
@ -259,25 +254,46 @@
<div class="col"> <div class="col">
<label for="studio1"> <label for="studio1">
<span class="s_website_form_label_content"> <span class="s_website_form_label_content">
Student Image Document Type
</span>
</label>
<div class="col">
<select name="doc_type"
class="form-control">
<t t-foreach="doc_type"
t-as="rec">
<option t-att-value="rec.id">
<t t-esc="rec.name"/>
</option>
</t>
</select>
</div>
</div>
<div class="col">
<label for="studio1">
<span class="s_website_form_label_content">
Upload Document
</span>
</label>
<div class="col">
<input type="file" name="att"
accept="image/*,application/pdf,video/*"/>
</div>
</div>
<div class="col">
<label for="studio1">
<span class="s_website_form_label_content">
Upload Your Photo
</span> </span>
</label> </label>
<div class="col"> <div class="col">
<input id="image" type="file" <input id="image" type="file"
class="form-control s_website_form_input" accept="image/png,image/jpeg"
name="image" name="image" required="1"/>
accept="image/png,image/jpeg" />
<small class="text-muted">Upload a
passport-sized photo
</small>
</div> </div>
</div> </div>
</div> </div>
<br/> <div class="form-error-message"/>
<br/>
<br/>
<br/>
<div> <div>
<div style="width: 400px;" <div style="width: 400px;"
class="s_website_form_label"/> class="s_website_form_label"/>

Loading…
Cancel
Save