예제 #1
0
def jobExperienceEdit():
    user = savvy_collection.find_one({ EMAIL: current_user.get_id()[EMAIL] })

    if user:
        if request.method == 'POST':
            print (request.data)
            print (request.form)
            print (request.json)
            print("Edited")

            jobExperienceId = request.json['jobExperienceId']
            returnString = '#jobExperience'+jobExperienceId

            entry = {
                'position'      : request.json['position'],
                'company'       : request.json['company'],
                'period'        : request.json['period'],
                'description'   : request.json['description']
            }

            old = user['jobExperience']
            print (old)
            old[str(jobExperienceId)] = entry
            print (old)
            savvy_collection.update({EMAIL:user[EMAIL]}, {"$set": {JOBEXPERIENCE: old}})

            # return information to frontend
            return jsonify(returnString = returnString)
예제 #2
0
    def update(self, email):
        user = {
            BUSINESS: self.businessName.data,
            CONTACT: self.contactName.data,
            PHONE: self.phoneNumber.data,
            WEBSITE: self.website.data.rstrip(),
            ADDRESS: self.streetAddress.data,
            ABOUT: self.about.data
        }

        savvy_collection.update({EMAIL: email}, {"$set": user})
예제 #3
0
    def update(self, email):
        availability = {
            MON[TEXT]: self.monday.data,
            TUE[TEXT]: self.tuesday.data,
            WED[TEXT]: self.wednesday.data,
            THU[TEXT]: self.thursday.data,
            FRI[TEXT]: self.friday.data,
            SAT[TEXT]: self.saturday.data,
            SUN[TEXT]: self.sunday.data,
            HOL[TEXT]: self.holiday.data,
        }

        tmp = (self.skills.data.rstrip()).split(',')
        skills = []
        for skill in tmp:
            if skill != '' and skill != ' ' and skill != None:
                if len(skills
                       ) < 5:  # top 5 skills # Ad havoc method. need to change
                    skills.append(skill.lstrip())
                else:
                    break

        complete = True
        if self.firstName.data.rstrip()     == '' or \
           self.lastName.data.rstrip()      == '' or  \
           self.about.data.rstrip()         == '' or \
           self.location.data.rstrip        == '' or \
           len(skills)                      == 0:
            complete = False

        user = {
            FNAME: self.firstName.data.rstrip(),
            LNAME: self.lastName.data.rstrip(),
            PHONE: self.phoneNumber.data.rstrip(),
            GENDER: self.gender.data,
            BIRTHDAY: str(self.birthday.data),
            RESIDENCY: self.residency.data,
            ABOUT: self.about.data.rstrip(),
            EDUCATION: self.education.data,
            AVAILABILITY: availability,
            SKILLS: skills,
            LOCATION: self.location.data.rstrip(),
            COMPLETE: complete
        }

        savvy_collection.update({EMAIL: email}, {"$set": user})

        if complete:
            flash('Successfully updated your profile', 'success')
        else:
            flash('Your profile is not visible until it\'s completed',
                  'warning')

        return True
예제 #4
0
    def update(self, email):
        availability = {
            MON[TEXT]: self.monday.data,
            TUE[TEXT]: self.tuesday.data,
            WED[TEXT]: self.wednesday.data,
            THU[TEXT]: self.thursday.data,
            FRI[TEXT]: self.friday.data,
            SAT[TEXT]: self.saturday.data,
            SUN[TEXT]: self.sunday.data,
            HOL[TEXT]: self.holiday.data,
        }

        tmp = (self.skills.data.rstrip()).split(",")
        skills = []
        for skill in tmp:
            if skill != "" and skill != " " and skill != None:
                if len(skills) < 5:  # top 5 skills # Ad havoc method. need to change
                    skills.append(skill.lstrip())
                else:
                    break

        complete = True
        if (
            self.firstName.data.rstrip() == ""
            or self.lastName.data.rstrip() == ""
            or self.about.data.rstrip() == ""
            or self.location.data.rstrip == ""
            or len(skills) == 0
        ):
            complete = False

        user = {
            FNAME: self.firstName.data.rstrip(),
            LNAME: self.lastName.data.rstrip(),
            PHONE: self.phoneNumber.data.rstrip(),
            GENDER: self.gender.data,
            BIRTHDAY: str(self.birthday.data),
            RESIDENCY: self.residency.data,
            ABOUT: self.about.data.rstrip(),
            EDUCATION: self.education.data,
            AVAILABILITY: availability,
            SKILLS: skills,
            LOCATION: self.location.data.rstrip(),
            COMPLETE: complete,
        }

        savvy_collection.update({EMAIL: email}, {"$set": user})

        if complete:
            flash("Successfully updated your profile", "success")
        else:
            flash("Your profile is not visible until it's completed", "warning")

        return True
예제 #5
0
    def update(self, email):
        user = {
            BUSINESS: self.businessName.data,
            CONTACT: self.contactName.data,
            PHONE: self.phoneNumber.data,
            WEBSITE: self.website.data.rstrip(),
            ADDRESS: self.streetAddress.data,
            ABOUT: self.about.data,
        }

        savvy_collection.update({EMAIL: email}, {"$set": user})
예제 #6
0
 def validate(self):
     rv = Form.validate(self)
     if not rv:
         message = ''
         for fieldName, errorMessages in self.errors.items():
             for err in errorMessages:
                 message = message + fieldName + ': ' + err + '\n'
         flash(message, 'error')
         return False
     else:
         savvy_collection.update({EMAIL: self.user[EMAIL]},
                                 {"$set": {PASSWORD: md5(self.password.data.rstrip().encode('utf-8')).hexdigest()}})
         return True
예제 #7
0
def jobExperience():
    user = savvy_collection.find_one({EMAIL: current_user.get_id()[EMAIL]})
    if user:
        if request.method == 'POST':
            print(request.data)
            print(request.form)
            print(request.json)
            print("Deleted")

            returnString = request.json
            company = request.json['company']
            period = request.json['period']
            position = request.json['position']
            description = request.json['description']

            if position and company and period and description:

                entry = {
                    'position': position,
                    'company': company,
                    'period': period,
                    'description': description
                }

                oldDic = user.get('jobExperience')
                if oldDic:
                    newIndex = int(max(oldDic.keys()))
                    newDic = OrderedDict()
                    newDic = oldDic
                    newDic[str(newIndex + 1)] = entry
                    savvy_collection.update(
                        {EMAIL: user[EMAIL]},
                        {"$set": {
                            'jobExperience': newDic
                        }})

                else:
                    oldDic = OrderedDict()
                    oldDic['1'] = entry
                    savvy_collection.update(
                        {EMAIL: user[EMAIL]},
                        {"$set": {
                            'jobExperience': oldDic
                        }})

            # return information to frontend
            return jsonify(returnString=returnString)
예제 #8
0
파일: jobs.py 프로젝트: SavvySupport/wolves
    def validate(self,user):
        # insert into database
        job = {
            "title"         : self.title.data,
            "availability"  : self.availability.data,
            "jobType"       : self.jobType.data,
            "description"   : self.description.data.rstrip(),
            "timeStamp"     : self.timeStamp,
        }

        employerId = user['_id']
        jobs_collection.update({'employerId': employerId},
                               {"$set": {self.timeStamp: job}})
        savvy_collection.update({EMAIL: self.email},
                                {"$addToSet": {"jobs":self.timeStamp}})

        return True
예제 #9
0
 def validate(self):
     rv = Form.validate(self)
     if not rv:
         message = ''
         for fieldName, errorMessages in self.errors.items():
             for err in errorMessages:
                 message = message + fieldName + ': ' + err + '\n'
         flash(message, 'error')
         return False
     else:
         savvy_collection.update({EMAIL: self.user[EMAIL]}, {
             "$set": {
                 PASSWORD:
                 md5(self.password.data.rstrip().encode(
                     'utf-8')).hexdigest()
             }
         })
         return True
예제 #10
0
def jobExperienceRemove():
    user = savvy_collection.find_one({ EMAIL: current_user.get_id()[EMAIL] })
    if user:
        if request.method == 'POST':
            print (request.data)
            print (request.form)
            print (request.json)
            print("Deleted")

            jobExperienceId = request.json['jobExperienceId']
            returnString = '#jobExperience'+jobExperienceId

            old = user['jobExperience']
            del old[jobExperienceId]

            savvy_collection.update({EMAIL: user[EMAIL]}, {"$set": {JOBEXPERIENCE: old}})

            # return information to frontend
            return jsonify(returnString = returnString)
예제 #11
0
def deleteJobPost():
    user = savvy_collection.find_one({ EMAIL: current_user.get_id()[EMAIL] })
    if user:
        if request.method == 'POST':
            jobId = request.json['jobId']
            listId = request.json['listId']
            returnString = "#jobajax" + str(listId)
            employerId = user['_id']

            # Update savvy collection
            savvy_collection.update({EMAIL: user[EMAIL]},
                                    {"$pull": {'jobs': jobId}})

            # Delete job from job collection
            jobs_collection.update({EMPLOYERID: employerId},
                                   {"$unset": {jobId: ''}})

            # return information to frontend
            return jsonify(returnString = returnString)
예제 #12
0
def dpupload():
    if request.method == 'POST':
        file = request.files['attachmentName']
        if file and allowed_file(file.filename):
            # Set up upload folder
            updir = os.path.join(app.config['basedir'], 'static/images/user/')

            # Delete old file
            delete_file = current_user.get_id().get(DP, None)
            if delete_file:
                delete_file = delete_file.split('/', -1)[-1]
                delete_file = os.path.join(updir, delete_file)
                if os.path.exists(delete_file):
                    os.remove(delete_file)

            # Get filename
            filename = secure_filename(file.filename)
            filename = md5((
                filename +
                current_user.get_id().get(EMAIL)).encode('utf-8')).hexdigest()

            # Check if user folder exists
            if not os.path.exists(updir):
                os.makedirs(updir)

            path = os.path.join(updir, filename)
            # Upload file to server
            file.save(path)

            # Resize image
            # install PIL with pip

            # Save path to database
            relative_path = os.path.join(
                url_for('static', filename='images/user/'), filename)
            print(relative_path)
            user = {DP: relative_path}
            savvy_collection.update({EMAIL: current_user.get_id().get(EMAIL)},
                                    {"$set": user})

            # return information to frontend
            return jsonify(path=relative_path)
예제 #13
0
def dpupload():
    if request.method == 'POST':
        file = request.files['attachmentName']
        if file and allowed_file(file.filename):
            # Set up upload folder
            updir = os.path.join(app.config['basedir'], 'static/images/user/')

            # Delete old file
            delete_file = current_user.get_id().get(DP, None)
            if delete_file:
                delete_file = delete_file.split('/', -1)[-1]
                delete_file = os.path.join(updir, delete_file)
                if os.path.exists(delete_file):
                    os.remove(delete_file)

            # Get filename
            filename = secure_filename(file.filename)
            filename = md5((filename + current_user.get_id().get(EMAIL)).encode('utf-8')).hexdigest()

            # Check if user folder exists
            if not os.path.exists(updir):
                os.makedirs(updir)

            path = os.path.join(updir, filename)
            # Upload file to server
            file.save(path)

            # Resize image
            # install PIL with pip

            # Save path to database
            relative_path = os.path.join(url_for('static', filename='images/user/'), filename)
            print (relative_path)
            user = { DP: relative_path }
            savvy_collection.update( {EMAIL: current_user.get_id().get(EMAIL)},
                                     {"$set": user} )

            # return information to frontend
            return jsonify(path=relative_path)
예제 #14
0
def jobExperienceRemove():
    user = savvy_collection.find_one({EMAIL: current_user.get_id()[EMAIL]})
    if user:
        if request.method == 'POST':
            print(request.data)
            print(request.form)
            print(request.json)
            print("Deleted")

            jobExperienceId = request.json['jobExperienceId']
            returnString = '#jobExperience' + jobExperienceId

            old = user['jobExperience']
            del old[jobExperienceId]

            savvy_collection.update({EMAIL: user[EMAIL]},
                                    {"$set": {
                                        JOBEXPERIENCE: old
                                    }})

            # return information to frontend
            return jsonify(returnString=returnString)
예제 #15
0
파일: job.py 프로젝트: SavvySupport/wolves
    def update(self, user):
        id = user['_id']
        job = {
            TITLE         : self.title.data,
            AVAILABILITY  : self.availability.data,
            DESCR         : self.description.data.rstrip(),
            EMPLOYERID    : id,
            TYPE          : JOB,
            RESIDENCY     : self.residency.data,
            LOCATION      : self.location.data,
            BUSINESS      : user.get(BUSINESS,''),
            WEBSITE       : user.get(WEBSITE,''),
            ABOUT         : user.get(ABOUT,'')

        }

        timeStamp = datetime.now().strftime('%Y/%m/%d %H:%M:%S')
        jobs_collection.update({EMPLOYERID: id},
                               {"$set": {timeStamp: job}})

        savvy_collection.update({EMAIL: user[EMAIL]},
                                {"$addToSet": {"jobs": timeStamp}})
예제 #16
0
파일: job.py 프로젝트: SavvySupport/wolves
    def update(self, user):
        id = user['_id']
        job = {
            TITLE: self.title.data,
            AVAILABILITY: self.availability.data,
            DESCR: self.description.data.rstrip(),
            EMPLOYERID: id,
            TYPE: JOB,
            RESIDENCY: self.residency.data,
            LOCATION: self.location.data,
            BUSINESS: user.get(BUSINESS, ''),
            WEBSITE: user.get(WEBSITE, ''),
            ABOUT: user.get(ABOUT, '')
        }

        timeStamp = datetime.now().strftime('%Y/%m/%d %H:%M:%S')
        jobs_collection.update({EMPLOYERID: id}, {"$set": {timeStamp: job}})

        savvy_collection.update({EMAIL: user[EMAIL]},
                                {"$addToSet": {
                                    "jobs": timeStamp
                                }})
예제 #17
0
def jobExperience():
    user = savvy_collection.find_one({ EMAIL: current_user.get_id()[EMAIL] })
    if user:
        if request.method == 'POST':
            print(request.data)
            print(request.form)
            print(request.json)
            print("Deleted")

            returnString = request.json
            company = request.json['company']
            period = request.json['period']
            position = request.json['position']
            description = request.json['description']

            if position and company and period and description:

                entry = {
                    'position'      : position,
                    'company'       : company,
                    'period'        : period,
                    'description'   : description
                }

                oldDic = user.get('jobExperience')
                if oldDic:
                    newIndex = int(max(oldDic.keys()))
                    newDic = OrderedDict()
                    newDic = oldDic
                    newDic[str(newIndex + 1)] = entry
                    savvy_collection.update({EMAIL:user[EMAIL]}, {"$set": {'jobExperience': newDic}})

                else:
                    oldDic = OrderedDict()
                    oldDic['1'] = entry
                    savvy_collection.update({EMAIL: user[EMAIL]}, {"$set": {'jobExperience': oldDic}})

            # return information to frontend
            return jsonify(returnString = returnString)
예제 #18
0
def deleteJobPost():
    user = savvy_collection.find_one({EMAIL: current_user.get_id()[EMAIL]})
    if user:
        if request.method == 'POST':
            jobId = request.json['jobId']
            listId = request.json['listId']
            returnString = "#jobajax" + str(listId)
            employerId = user['_id']

            # Update savvy collection
            savvy_collection.update({EMAIL: user[EMAIL]},
                                    {"$pull": {
                                        'jobs': jobId
                                    }})

            # Delete job from job collection
            jobs_collection.update({EMPLOYERID: employerId},
                                   {"$unset": {
                                       jobId: ''
                                   }})

            # return information to frontend
            return jsonify(returnString=returnString)