Example #1
0
 def upload(req):
   if req.method == 'POST':
     fname = "{}{}".format(settings.UPLOAD_DIR, req.POST.get('name'))
     with zipfile.ZipFile(req.FILES['images'],"r") as zip_ref:
       zip_ref.extractall(fname)
     return Collect.sort(req, name=fname)
   else:
     return Controller.render(req, {}, 'collect/upload.html')
Example #2
0
 def index(req):
     company = Company.objects.all().exclude(name="Not Set").values(
         'id', 'name')
     section = Section.objects.all().values('id', 'name')
     ctx = {
         "date": datetime.date.today().strftime("%Y-%m-%d"),
         "company": company,
         'section': section
     }
     return Controller.render(req, ctx, 'index/index.html')
Example #3
0
 def read(req):
   if req.method != 'POST':
       return Controller.goto('/collect/index')
   path  = req.POST.get('path')
   data  = {'status':'processing', 'name': os.path.basename(path), 'create_by': req.user.username }
   mkdir, created = Directory.objects.get_or_create(full_path=path, defaults=data,)
   sect  = req.POST.get('section-select')
   loc   = req.POST.get('location-select')
   sect_obj = Section.objects.filter(id=1).values('id', 'name')[0]
   loc_obj  = Location.objects.filter().values('id', 'name')[0]
   ctx = {"path": path, "section_id":sect, "sect_obj":sect_obj, 'loc_id':loc, 'loc_obj':loc_obj, "mkdir": mkdir}
   return Controller.render(req, ctx, 'collect/read.html')
Example #4
0
    def login(req):
        errors = []
        if req.user.is_authenticated:
            return Controller.goto('/collect/index')

        if req.method == "POST":
            username = req.POST.get('username')
            password = req.POST.get('password')
            user = authenticate(req, username=username, password=password)
            if user is not None:
                login(req, user)
                return Controller.goto('/collect/index')
            errors.append("Hmm I cant find that user/password combo")

        ctx = {"errors": errors}
        return Controller.render(req, ctx, 'login/login.html')
Example #5
0
  def index(req):
    """ List the dir. to process """
    current_dir = req.POST.get('current_dir', settings.UPLOAD_DIR)
    dirs = Collect.get_dir_list(current_dir)
    root = Collect.get_dir_list(settings.UPLOAD_ROOT, True)
    dir_list = []
    for d in dirs:
        path = "{}{}".format(current_dir, d)
        is_dir_in_db  = Directory.objects.filter(**{'full_path':path}).values('id', 'name', 'status')

        if len(is_dir_in_db) > 0 and is_dir_in_db[0]['status'] == 'done':
            continue

        status = is_dir_in_db[0]['status'] if len(is_dir_in_db) > 0 else "Not Processed"
        dir_list.append( {'name':d, 'status':status, 'path': path } )

    res = {'dir_list':dir_list, "total_dirs": len(dir_list), "root_path":settings.UPLOAD_ROOT, "root_dir":root, "current_dir":current_dir}
    return Controller.render(req, res, 'collect/index.html')
Example #6
0
 def index(req):
     return Controller.render(req, {}, 'collect/index.html')