예제 #1
0
파일: task.py 프로젝트: rcdigital/overtiny
def start_timer(request):
    if request.is_ajax():
    	try:
           company = Company.objects.get(name = request.POST['client'].title() )
        except Company.DoesNotExist:
            company = Company( name = request.POST['client'].title(), created = datetime.now(), user_id = request.user.id)
            company.save()

        task = Task(user_id = request.user.id, company_id = company.id, task_name = request.POST['taskName'], time_spent = '00:00:00')
        task.save()
        to_json = { "task_id" : task.id}
        return HttpResponse( simplejson.dumps(to_json), mimetype = 'application/json')
예제 #2
0
 def post(self):
     data = api.payload
     company = Company(fc_id=data['fc_id'], company_name=data['company_name'], email=data['email'])
     data['company_id'] = time.time()
     company.company_id = int(data['company_id'])
     company.set_password(data['password'])
     company.save() 
     return jsonify(Company.objects(company_id=company.company_id))
예제 #3
0
 def post(self):
     data = api.payload
     van = Van(company_name=data['company_name'], vin=data['vin'])
     data['van_id'] = time.time()
     van.van_id = int(data['van_id'])
     if Company.objects(company_name=van.company_name).first():
         van.save() 
         return jsonify(Van.objects(van_id=van.van_id))
     else:
         return jsonify(message="This company does not exist or you misspelled company name"), 400
예제 #4
0
    def post(self):

        data = api.payload
        email = data['email']
        password = data['password']
        
        company = Company.objects(email=email).first()
        if company and company.get_password(password):
            return {
                'jwt': create_jwt(identity=email),
                'company_id': company.company_id,
                'company_name': company.company_name
            }, 200
        else:
            return jsonify({ "message": "Bad companyname or password" }), 401
예제 #5
0
def index():
    form = LoginForm()
    if form.validate_on_submit():
        email = form.email.data
        password = form.password.data
        
        company = Company.objects(email=email).first()
        if company and company.get_password(password):
            flash(f'{company.company_name}, you are successfully logged in!', 'success')
            session['company_id'] = company.company_id
            session['company'] = company.company_name
            return redirect(url_for('index'))
        else:
            flash('Wrong Company Name or Password', 'danger')
            
    return render_template('index.html', index=True, form=form)
예제 #6
0
 def delete(self, idx):
     Company.objects(company_id=idx).delete()
     return jsonify( message='User was deleted successfully!')
예제 #7
0
 def put(self, idx: int):
     data = api.payload
     company = Company(fc_id=data['fc_id'], company_name=data['company_name'], email=data['email'])
     company.set_password(data['password'])
     Company.objects(company_id=idx).update(company_name=company.company_name, email=company.email, fc_id=company.fc_id, password=company.password)
     return jsonify(Company.objects(company_id=idx))
예제 #8
0
 def get(self, idx: int):
     return jsonify(Company.objects(company_id=idx))
예제 #9
0
 def put(self, idx: int):
     data = api.payload
     fc = Company(fc_name=data['fc_name'], fc_address=data['fc_address'], fc_city=data['fc_city'], fc_zip=data['fc_zip'])
     Fullfilment_center.objects(fc_id=idx).update(fc_name=fc.fc_name, fc_address=fc.fc_address, fc_city=fc.fc_city, fc_zip=fc.fc_zip)
     return jsonify(Fullfilment_center.objects(fc_id=idx))