Browse Source

July 25: [FIX] Bug Fixed 'education_university_management'

pull/331/head
Cybrosys Technologies 10 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',
'version': '17.0.1.0.0',
'version': '17.0.1.0.1',
'category': 'Industries',
'summary': """This modules helps to manage the university
education system""",

17
education_university_management/controllers/education_online_application.py

@ -38,7 +38,7 @@ class OnlineAdmission(http.Controller):
to the website registration form."""
vals = {
'department': request.env['university.department'].sudo().search(
[]),
[('semester_ids', '!=', False)]),
'course': request.env['university.course'].sudo().search([]),
'semester': request.env['university.semester'].sudo().search([]),
'year': request.env['university.academic.year'].sudo().search([]),
@ -58,7 +58,7 @@ class OnlineAdmission(http.Controller):
'name': post.get('father'),
'is_parent': True
})
request.env['university.application'].sudo().create({
application = request.env['university.application'].sudo().create({
'name': post.get('first_name'),
'last_name': post.get('last_name'),
'mother_name': post.get('mother'),
@ -74,7 +74,18 @@ class OnlineAdmission(http.Controller):
'street': post.get('communication_address'),
'per_street': post.get('communication_address'),
'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(
"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")
semester_ids = fields.One2many('university.semester',
'department_id',
string="Semester", readonly=True,
string="Semester", required=1,
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',
events: {
'change select[name="course"]': '_onCourseChange',
'change select[name="department"]': '_onDepartmentChange',
'change select[name="semester"]': '_onSemesterChange',
'submit form': '_onFormSubmit',
},
init() {
this._super(...arguments);
@ -16,27 +17,46 @@ publicWidget.registry.OnlineApplication = publicWidget.Widget.extend({
ev.preventDefault();
var self = this
var course = ev.currentTarget.value;
self.$el.find('select[name="department"]').find('option').remove()
self.$el.find('select[name="department"]').append("<option value=0></option>");
self.$el.find('select[name="semester"]').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(
'university.department',
[['course_id', '=', parseInt(course)]],['name']
'university.semester',
[['department_id.course_id', '=', parseInt(course)]],['name']
)
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 department = ev.currentTarget.value;
self.$el.find('select[name="semester"]').find('option').remove()
self.$el.find('select[name="semester"]').append("<option value=0></option>");
var semester = ev.currentTarget.value;
self.$el.find('select[name="department"]').find('option').remove()
self.$el.find('select[name="department"]').append("<option value=0></option>");
const result = await this.orm.searchRead(
'university.semester',
[['department_id', '=', parseInt(department)]],['name']
'university.department',
[['semester_ids', 'in', [parseInt(semester)]]],['name']
)
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>
</section>
<div id="wrap" class="wrap student-booking-widget">
<div class="container" id="online_appl_form" t-ref="body">
<form action="/admission/submit">
<!-- <input type="hidden" name="csrf_token"-->
<!-- t-att-value="request.csrf_token()"/>-->
<div class="container" id="online_appl_form">
<form action="/admission/submit" method="POST"
enctype="multipart/form-data">
<input type="hidden" name="csrf_token"
t-att-value="request.csrf_token()"/>
<div class="card" style="width:75%;border:none;">
<br/>
<br/>
@ -139,7 +140,7 @@
</label>
<div class="col">
<input id="mother" type="text"
class="form-control s_website_form_input"
class="form-control s_website_form_input"
name="mother" required="1"/>
</div>
</div>
@ -206,41 +207,35 @@
<div class="col">
<label for="studio1">
<span class="s_website_form_label_content">
Department
Semester
</span>
</label>
<div class="col">
<select name="department"
<select name="semester"
class="form-control">
<option></option>
<!-- <t t-foreach="department"-->
<!-- t-as="rec">-->
<!-- <option t-att-value="rec.id">-->
<!-- <t t-esc="rec.name"/>-->
<!-- </option>-->
<!-- </t>-->
<!-- <t t-foreach="semester"-->
<!-- 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">
Semester
Department
</span>
</label>
<div class="col">
<select name="semester"
<select name="department" required="1"
class="form-control">
<option></option>
<!-- <t t-foreach="semester"-->
<!-- 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">
@ -259,25 +254,46 @@
<div class="col">
<label for="studio1">
<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>
</label>
<div class="col">
<input id="image" type="file"
class="form-control s_website_form_input"
name="image"
accept="image/png,image/jpeg" />
<small class="text-muted">Upload a
passport-sized photo
</small>
accept="image/png,image/jpeg"
name="image" required="1"/>
</div>
</div>
</div>
<br/>
<br/>
<br/>
<br/>
<div class="form-error-message"/>
<div>
<div style="width: 400px;"
class="s_website_form_label"/>

Loading…
Cancel
Save