예제 #1
0
def password_reset():
    form = passwordReset()
    if form.validate_on_submit():
        username = form.data['username']
        print(username)
        guide = Guide.query.filter_by(username=username)
        if guide:
            hashed_password = bcrypt.generate_password_hash(
                form.password.data).decode('utf-8')
            guide[0].password = hashed_password
            db.session.commit()
            template = email_header + f"""
            Respected <b>{guide[0].name}</b>,
            <br/><br/>You have successfully reset your password.<br/><br/>
            <b>Not you? </b>If it was not you, please <b>immediately report us</b> by replying the issue on this email.<br/><br/>
            """ + email_footer
            msg = Message(
                subject=
                '[ALERT!] Password Reset Done | Department of CSE | MGM\'s College of Engineering',
                sender='*****@*****.**',
                recipients=[guide[0].email],
                html=template)
            mail.send(msg)
            flash('Password Reset Successful!', 'success')
        else:
            flash(
                'The entered username doesnot exist. Please register as a Guide.',
                'danger')
        return redirect(url_for('guideLogin'))
    return render_template('password-reset.html',
                           title="Reset Password",
                           form=form)
예제 #2
0
def GuideRegistration():
    form = guideRegister()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        guide = Guide(name=form.guideName.data,
                      username=form.username.data,
                      password=hashed_password,
                      email=form.guideEmail.data,
                      interest=form.guideInterest.data)
        db.session.add(guide)
        db.session.commit()
        flash('Your account has been created. You can now login as a guide.',
              'success')
        template = f"Hi {guide.name}! You have been successfully registerd as a Guide. Your Interests: {guide.interest}. You will be informed via mail, when students will be are assigned to you."
        msg = Message(
            subject=
            'Guide Registration Successful | Department of CSE | MGM College of Engineering | Nanded',
            sender='*****@*****.**',
            recipients=[guide.email],
            body=template)
        mail.send(msg)
        return redirect(url_for('guide'))
    return render_template('GuideRegistration.html',
                           title='Guide Registration',
                           form=form)
예제 #3
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = f'''To reset your password, visit the following link:
{url_for('users.reset_token', token=token, _external=True)}

If you did not make this request then simply ignore this email and no changes will be made.
'''
    mail.send(msg)
예제 #4
0
def ProjectRegistration():
    global status
    status = 0
    form = projectRegister()
    if form.validate_on_submit():
        entries = form.members.data
        membersList = []
        # entries.pop(2)
        flash(form.members.data)
        membersList = validate_on_submit_members(entries)
        status = membersList.pop()
        flash(membersList)
        flash(status)
        if len(membersList) >= 1 and status == 1:
            flash("check", 'success')
            project = Project(title=form.projectTitle.data,
                              desc=form.projectDescription.data,
                              techUsed=form.technologyUsed.data,
                              reason=form.reason.data)
            db.session.add(project)
            db.session.flush()
            project.code = str(
                "{0:03}".format(project.id)) + '-' + project.title[:4].replace(
                    " ", "").upper() + '-' + "omk".upper()
            team = Team(name=form.teamName.data)
            db.session.add(team)
            db.session.flush()
            project.team_id = team.id
            for index, entry in enumerate(membersList):
                student = Student(team_id=project.team_id,
                                  name=entry['memberName'],
                                  email=entry['memberEmail'],
                                  phone=entry['memberPhone'],
                                  cls=entry['memberClass'])
                db.session.add(student)
            db.session.flush()
            db.session.commit()
            template = f"<b>Hi {project.team.members[0].name}!</b><br /> &nbsp;&nbsp;&nbsp;&nbsp;You have successfully registerd your Project - {project.title}. Please note this ID: <b>{project.code}</b> to track your Project status. You will be soon assigned with a guide!"
            msg = Message(
                subject=
                'Project Registration Successful | Department of CSE | MGM College of Engineering | Nanded',
                sender='*****@*****.**',
                recipients=[project.team.members[0].email],
                html=template)
            mail.send(msg)
            flash(
                'You have successfully registered your Project! Please note this ID: '
                + project.code + ' to track your Project status.', 'success')
            return redirect(url_for('home'))
    return render_template('ProjectRegistration.html',
                           title='Project Registration',
                           form=form)
예제 #5
0
def guidelines():
    form = doubtForm()
    # if request.method=="POST":
    #     print(request.form.get('name'))
    if form.validate_on_submit():
        print("We are here")
        name = form.name.data
        email = form.Email.data
        query = form.Query.data
        template = f"Name: {name} <br/> Email: {email} <br/> Query: {query}"
        msg = Message(subject='Form submission - MGM Projects',
                      sender='*****@*****.**',
                      recipients=['*****@*****.**'],
                      html=template)
        mail.send(msg)
        flash(
            'Your Query has been received. We will soon get in touch with you!',
            'success')
        return redirect(url_for('guidelines'))
    return render_template('guidelines.html', title='Guidelines', form=form)
예제 #6
0
def deleteProject(id):
    project = Project.query.filter_by(code=id).first()
    student_emails = []
    student_email_ids = Student.query.filter_by(
        team_id=project.team_id).with_entities(Student.email).all()
    for email in student_email_ids:
        student_emails.append(email[0])
    template_student_body = f"""
     Hi <b>{project.team.members[0].name}!</b><br/><br/>
     You project - <b>{project.title}</b> has been rejected by Admin/Project-Incharge.</b><br/><br/>
     Please contact the Project Incharge or consider submitting another Project Application.<br/><br/>
     All the very best!<br/><br/>
     <div style=\"background: rgb(255,255,204); padding:5px;\">
     <small><b>Need Help for your project?</b> You may find projects similar to your project on our <a href="http://mgmprojects.pythonanywhere.com">website</a>. They may have come with the same issue as you are facing now, and together you can figure out a solution! We encourage you to also help other teams in need! Afterall, sharing our knowledge is a great way to grow!</small>
     </div><br/>
    """
    template = email_header + template_student_body + email_footer
    msg = Message(
        subject=
        '[Project-Rejected] | Department of CSE | MGM\'s College of Engineering | Nanded',
        sender='*****@*****.**',
        recipients=student_emails,
        html=template)
    mail.send(msg)

    team_id = project.team.id
    Student.query.filter_by(team_id=team_id).delete()
    # db.session.delete(students) doesnot take effect
    db.session.delete(project)
    team = Team.query.filter_by(id=team_id).delete()
    db.session.delete(project)
    db.session.commit()

    projects = Project.query.filter_by(status=0)
    count = Project.query.filter_by(status=0).count()
    flash('Project Deleted Successfully', 'danger')
    return render_template('temporary.html',
                           title="ConfirmProjects",
                           projects=projects,
                           count=count)
예제 #7
0
def GuideRegistration():
    form = guideRegister()
    if form.validate_on_submit():
        # hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8')
        guide = Guide(name=form.guideName.data,
                      username=form.username.data,
                      password=form.password.data,
                      email=form.guideEmail.data)
        db.session.add(guide)
        db.session.commit()
        flash(
            Markup(
                'Your account has been created. You can now login as a guide <a href="/guideLogin" class="alert-link" style="color:blue"> here</a>.'
            ), 'success')
        template = email_header + f"""
        Respected <b>{guide.name},<br/><br/></b> You are successfully registered as a Guide on our <b>Project Management System</b> Portal. <br/><br/>
        We will inform you (via e-mail) when students are assigned to you.<br/><br/>
        The following are your credentials:<br/>
        <b>Username</b>:{guide.username}<br/>
        <b>Password</b>:{guide.password}<br/><br/>
        Please <a href=mgmprojects.pythonanywhere.com/password_reset>Click Here</a> to Reset your Password using the temporary Username and Password provided above.<br/>
        <small>(If the above link doesn't work, please copy this link - mgmprojects.pythonanywhere.com/password_reset and paste it in the address field of your browser.)</small><br/><br/>
        Please <a href=mgmprojects.pythonanywhere.com/guideLogin>Click Here</a> to Login to the website.<br/>
        <small>(If the above link doesn't work, please copy this link - mgmprojects.pythonanywhere.com/guideLogin and paste it in the address field of your browser.)</small><br/>
        """ + email_footer
        msg = Message(
            subject=
            'Guide Registration Successful | Department of CSE | MGM\'s College of Engineering | Nanded',
            sender='*****@*****.**',
            recipients=[guide.email],
            html=template)
        mail.send(msg)
        return redirect(url_for('guide'))
    return render_template('GuideRegistration.html',
                           title='Guide Registration',
                           form=form)
예제 #8
0
def confirmedProject(id):
    project = Project.query.filter_by(code=id).first()
    project.status = 1
    db.session.commit()
    student_emails = []
    student_email_ids = Student.query.filter_by(
        team_id=project.team_id).with_entities(Student.email).all()
    for email in student_email_ids:
        student_emails.append(email[0])
    template_guide_body = f"""
    We have received a project that has been assigned under your guidance:<br/>
    &emsp;<b>Project Name</b>:{project.title}<br/>
    &emsp;<b>Project Leader</b>: {project.team.members[0].name}<br/>
    &emsp;<b>Technologies used</b>: {project.techUsed}<br/>
    &emsp;<b>Project Internal Guide</b>: {project.int_relation.name}<br/>
    &emsp;<b>Project External Guide</b>: {project.ext_relation.name}<br/>
    <br/>
    We will keep informing you as we get other projects from students.<br/><br/>
    To view more details of your projects and to conduct demos or assign marks to these projects, please login to our portal at mgmprojects.pythonanywhere.com/guideLogin<br/><br/>
    """

    template_int_body = email_header + f"""
    Respected <b>{project.int_relation.name}</b>,<br/><br/>
    """ + template_guide_body + email_footer
    msg = Message(
        subject=
        '[Project Assigned] Internal Guide | Department of CSE | MGM\'s College of Engineering | Nanded',
        sender='*****@*****.**',
        recipients=[project.int_relation.email],
        html=template_int_body)
    mail.send(msg)

    template_ext_body = email_header + f"""
    Respected <b>{project.ext_relation.name}</b>,<br/><br/>
    """ + template_guide_body + email_footer
    msg = Message(
        subject=
        '[Project Assigned] External Guide | Department of CSE | MGM\'s College of Engineering | Nanded',
        sender='*****@*****.**',
        recipients=[project.ext_relation.email],
        html=template_ext_body)
    mail.send(msg)

    template_student_body = f"""
     Hey <b>{project.team.members[0].name}!</b><br/><br/>
     We are glad to inform you that your project - <b>{project.title}</b> has been accepted by Admin/Project-Incharge.</b><br/><br/>
     Note the following details for future references:<br/>
     &emsp;<b>Project-Code:</b> {project.code}<br/>
     &emsp;<b>Internal Guide:</b> {project.int_relation.name} ({project.int_relation.email})<br/>
     &emsp;<b>External Guide:</b> {project.ext_relation.name} ({project.ext_relation.email})<br/>
     (<small>If you find the above guide details incorrect, please immediately report us at [email protected]</small>)<br/><br/>
         That's it for now! We are delighted to see your project taking every step of its success with the dedicated efforts of your team and guides!<br/><br/>
     All the very best!<br/><br/>
     <div style=\"background: rgb(255,255,204); padding:5px;\">
     <small><b>Need Help for your project?</b> You may find projects similar to your project on our <a href="http://mgmprojects.pythonanywhere.com">website</a>. They may have come with the same issue as you are facing now, and together you can figure out a solution! We encourage you to also help other teams in need! Afterall, sharing our knowledge is a great way to grow!</small>
     </div><br/>
    """
    template = email_header + template_student_body + email_footer
    msg = Message(
        subject=
        '[Project-Accepted] Congratulations! | Department of CSE | MGM\'s College of Engineering | Nanded',
        sender='*****@*****.**',
        recipients=student_emails,
        html=template)
    mail.send(msg)

    projects = Project.query.filter_by(status=0)
    count = Project.query.filter_by(status=0).count()
    flash('Project Confirmed Successfully!', 'success')
    return render_template('temporary.html',
                           title="ConfirmProjects",
                           projects=projects,
                           count=count)
예제 #9
0
def ProjectRegistration():
    global status
    status = 0
    guides = Guide.query.all()
    guide_list = [(i.id, i.name) for i in guides]
    form = projectRegister()
    form.internalGuides.choices = form.externalGuides.choices = guide_list
    if form.validate_on_submit():
        entries = form.members.data
        # print(form.internalGuides.data)
        membersList = []
        membersList = validate_on_submit_members(entries)
        status = membersList.pop()
        if len(membersList) >= 1 and status == 1:
            project = Project(
                title=form.projectTitle.data,
                desc=form.projectDescription.data,
                techUsed=form.technologyUsed.data,
                guide_id=form.internalGuides.data,
                external_id=form.externalGuides.data,
            )
            db.session.add(project)
            db.session.flush()
            team = Team(name=form.teamName.data)
            db.session.add(team)
            db.session.flush()
            project.team_id = team.id
            student_emails = []
            for index, entry in enumerate(membersList):
                student = Student(team_id=project.team_id,
                                  name=entry['memberName'].title(),
                                  email=entry['memberEmail'],
                                  phone=entry['memberPhone'],
                                  cls=entry['memberClass'])
                student_emails.append(entry['memberEmail'])
                db.session.add(student)
            project.code = str("{0:03}".format(
                project.id)) + '-' + project.title[:4].replace(" ", "").upper(
                ) + '-' + project.team.members[0].name[:3].upper()
            db.session.flush()
            db.session.commit()
            template_student_body = f"""
             Hey <b>{project.team.members[0].name}!</b><br/><br/>
             We are super-excited to have you, your team and your amazing project - <b>{project.title}</b> on board in our <b>Project Management System.</b><br/><br/>
             Your project will be verified by Project Incharges. Once verified, it will be accepted for further stages. <br/><br/>
             We will email you once your project has been accepted. Meanwhile stay rest assured and explore new projects on our portal!<br/><br/>
             &emsp;<b>Project-Code:</b> {project.code}<br/>
             &emsp;<b>Internal Guide:</b> {project.int_relation.name} ({project.int_relation.email})<br/>
             &emsp;<b>External Guide:</b> {project.ext_relation.name} ({project.ext_relation.email})<br/>
             (<small>If you find the above guide details incorrect, please immediately report us at [email protected]</small>)<br/><br/>
             All the very best!<br/><br/>
             <div style=\"background: rgb(255,255,204); padding:5px;\">
             <small><b>Need Help for your project?</b> You may find projects similar to your project on our <a href="http://mgmprojects.pythonanywhere.com">website</a>. They may have come with the same issue as you are facing now, and together you can figure out a solution! We encourage you to also help other teams in need! Afterall, sharing our knowledge is a great way to grow!</small>
             </div><br/>
            """
            template = email_header + template_student_body + email_footer
            msg = Message(
                subject=
                'Project Registration Successful | Department of CSE | MGM\'s College of Engineering | Nanded',
                sender='*****@*****.**',
                recipients=student_emails,
                html=template)
            mail.send(msg)
            flash(
                'You have successfully registered your Project! Please note this ID: '
                + project.code +
                ' to track your Project status. Also check your Registered Email Id for more details.',
                'success')
            return redirect(url_for('home'))
    return render_template('ProjectRegistration.html',
                           title='Project Registration',
                           form=form)