Ejemplo n.º 1
0
def staffEvaluate():
  if checkSession(session,["Admin"]):
    global newSponsors
    newUsers = userDB.get_new_users()
    # global newUsers
    return render_template("staff/evaluate.html",evaluateUsers=newUsers,newUsers=newUsers,profile="ssg-goku.jpg",newSponsors=newSponsors)
  else:
    return redirect(url_for("user.staffHome"))
Ejemplo n.º 2
0
def staffHome():
  if checkSession(session,["Admin","Manager","Staff"]):
    global newSponsors
    latest = insertAnimal.getLastAdded()
    animal_count = insertAnimal.getAllCount()
    return render_template('staff/staff.html',total=randint(1,100),newUsers=userDB.get_new_users(),latest=latest,animal_count=animal_count,newSponsors=newSponsors)
  else:
    return redirect(url_for("home.index"))
Ejemplo n.º 3
0
def assignHealth():
  if checkSession(session,["Admin","Staff","Manager"]):
    global newUsers
    global newSponsors
    global severity
    animals = insertAnimal.get_animals("total")
    return render_template("staff/sickAnimal.html",newUsers=newUsers,newSponsors=newSponsors,animals=animals,severity=severity)
  else:
    return redirect(url_for(""))
Ejemplo n.º 4
0
def displayCategory(category):
  if checkSession(session,["Admin","Manager","Staff"]):
    category = escape(category)
    global newUsers
    # newUsers = userDB.get_new_users()
    if category.lower() == "sick":
      animals = insertAnimal.get_animals("total",{'status':{'$exists':'true'}})
    else:
      animals = insertAnimal.get_animals(category)
    return render_template("staff/animalinfo.html",category=category,newUsers=newUsers,animals=animals)
  return redirect(url_for("animals.zooAnimals"))
Ejemplo n.º 5
0
def sponsorHome():
    if checkSession(session, ["Sponsor"]):
        currentUser = getCurrentUser(session)
        anims = insertAnimal.get_animals(
            'total', {'_id': {
                '$in': currentUser['animal_sponsor']
            }})
        return render_template("sponsorDetail.html",
                               animals=anims,
                               sponsor=currentUser)
    else:
        return render_template("sponsorDeals.html")
Ejemplo n.º 6
0
def updateSignage():
    if checkSession(session, ["Sponsor"]):
        file = request.files['signage']
        currentSponsor = getCurrentUser(session)
        file.save(
            os.path.join(app.root_path, 'static', 'images', 'signage',
                         file.filename))
        contract.update_one({'sponsor_id': currentSponsor['sponsor_id']},
                            {'$set': {
                                'signage': file.filename
                            }})
        return redirect(url_for("sponsor.sponsorHome"))
Ejemplo n.º 7
0
def updateHealth(category,_id,status):
  if checkSession(session,["Admin","Manager"]):
    global severity
    if status.lower() in severity:
      anim = insertAnimal.dbs.get(category)
      if anim:
        if anim.find_and_update({'_id':ObjectId(_id)},{'status':status}):
          return redirect(url_for("user.assignHealth"))
      else:
        return "Animal Not found"
    else:
      return "Invalid Status"
  else:
    return redirect(url_for("user.staff"))
Ejemplo n.º 8
0
def updateStaff(email):
  if checkSession(session,["Admin"]):
    global newUsers
    global newSponsors
    user = userDB.find_by_email(email)
    _id = user['_id']
    currVis = User({'email':user['email'],'username':user['username']})
    editForm = StaffForm()
    if editForm.validate_on_submit():
      currVis = assignRole(editForm.role.data,currVis.__dict__,{'username': editForm.username.data,'role':editForm.role.data,'checked':True})
      if currVis.saveToDb(userDB):
        return redirect(url_for("user.staffEvaluate"))
    return render_template("staff/editStaff.html",profile="ssg-goku.jpg",form=editForm,user=currVis,newUsers=newUsers,newSponsors=newSponsors)
  else:
    return render_template("staff/staff.html")
Ejemplo n.º 9
0
def archiveAnimal(category,animalID):
  if checkSession(session,["Admin","Manager"]):
    _id = insertAnimal.archive(category,animalID) 
    if _id:
      flash("Animal Archived Succesfully")
      log.insert_one({
        "inserted_by": session['current_user']['username'],
        "animal": _id,
        'category':category,
        'operation':'archive',
        "date_added":datetime.now()
      })
    else:
      flash("Archive failed")
    return redirect(f"/staff/{category}")
  else:
    return redirect(url_for("home.index"))
Ejemplo n.º 10
0
def staffLog():
  if checkSession(session,["Admin"]):
    global newUsers
    global newSponsors
    userLogs = logs.getProp({}).sort([('date_added',ASCENDING)])
    orderd = {}
    for i in userLogs:
      datekey = str(i['date_added']).split(' ')[0]
      if datekey == str(datetime.now()).split(' ')[0]:
        k = "Today"
      else:
        k = datekey
      curr = orderd.get(k,None)
      if not curr:
        orderd[k] = []
      orderd[k].append(i)
    return render_template("staff/activityLog.html",newUsers=newUsers,newSponsors=newSponsors,log=orderd)
Ejemplo n.º 11
0
def approveRole():
  if checkSession(session,["Admin"]):
    criteria = request.get_json()
    print(criteria)
    if userDB.find_and_update({'email':criteria['email']},{"checked":True,"role":criteria['role']}):
      return json.dumps({'approve':True})
Ejemplo n.º 12
0
def applySponsor():
    try:
        currentUser = user.find_by_email(
            session.get('current_user', None)['email'])
    except BaseException as e:
        return redirect(url_for('user.loginUser'))
    if checkSession(session, ['Visitor']):
        form = ApplyForm()
        form.animal_sponsor.choices = get_all_animals()
        if request.method == "POST":
            if form.signage.data == None:
                flash('Signage Required', 'notification is-warning')
            else:
                signagePath = uploadImage(form.signage.data, 'signage')
                _sponsor = Sponsor({
                    'sponsor_id':
                    currentUser['_id'],
                    'company_name':
                    escape(form.client_name.data),
                    'signage':
                    escape(signagePath),
                    'address':
                    escape(form.client_address.data),
                    'country':
                    escape(form.client_country.data),
                    'city':
                    escape(form.client_city.data),
                    'estate':
                    escape(form.client_estate.data),
                    'band':
                    escape(form.sponsor_band.data),
                    'animal_sponsor':
                    [ObjectId(i) for i in form.animal_sponsor.data],
                    'approved':
                    False
                })
                if contract.insert_one(_sponsor.__dict__):
                    flash("Your Sponsorship agreement has been submitted!",
                          category="notification is-success")
                    return redirect(url_for('home.index'))
                else:
                    flash("Failed to submit form", "notification is-danger")
        return render_template('apply.html', form=form)
    elif checkSession(session, ['Sponsor']):
        sponsorUser = contract.find_one({'sponsor_id': currentUser['_id']})
        form = ApplyForm()
        form.client_name.data = sponsorUser['company_name']
        form.client_address.data = sponsorUser['address']
        form.client_estate.data = sponsorUser['estate']
        form.client_country.data = sponsorUser['country']
        form.client_address.data = sponsorUser['address']
        form.client_city.data = sponsorUser['city']
        form.sponsor_band.data = sponsorUser['band']
        animals_to_sponsor = [
            i for i in get_all_animals()
            if i[0] not in sponsorUser['animal_sponsor']
        ]
        form.animal_sponsor.choices = animals_to_sponsor if len(
            animals_to_sponsor) > 0 else []
        # return str(animals_to_sponsor)

        # redirect(url_for("sponsor.sponsorHome"))
        return render_template('apply.html', form=form)
    else:
        return redirect(url_for("user.loginUser"))