Esempio n. 1
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')
Esempio n. 2
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')
Esempio n. 3
0
 def index(req):
     """ List the all companies  """
     companies = Company.objects.all().values()
     return Controller.render_json({
         'companies': list(companies),
         "total_companies": len(companies)
     })
Esempio n. 4
0
 def search_sequance(req):
   f = {'date':req.GET.get('date', datetime.datetime.now()),
        'section_id': req.GET.get('section_id'),
        'company_id': req.GET.get('company_id'),
        'import_status': 'sequence'}
   sequences = Manifest.objects.filter(**f).distinct('sequence').values('sequence');
   return Controller.render_json({'results':list(sequences), "total": len(sequences)})
Esempio n. 5
0
 def index(req):
     """ List the all UIs by type  """
     type = req.GET.get('type')
     uis = UI.objects.filter(**{'type': type}).order_by('name').values()
     return Controller.render_json({
         'results': list(uis),
         "total": len(uis)
     })
Esempio n. 6
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')
Esempio n. 7
0
 def search(req):
     """ List search results """
     f = {'name__icontains': req.GET.get('keyword', '')}
     companies = Company.objects.filter(**f).order_by('name').values(
         'id', 'name')[:100]
     return Controller.render_json({
         'companies': list(companies),
         "total_companies": len(companies)
     })
Esempio n. 8
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')
Esempio n. 9
0
  def create(req):
    post = req.POST;
    dir  = post.get('dir')
    img_dir   = "{}{}/*.jpg".format(settings.UPLOAD_DIR, dir)
    out_dir   = "{}{}/thumbs/".format(settings.UPLOAD_DIR, dir)
    meta_data = thumb_nail(glob.glob(img_dir), out_dir, (700, 700))

    for key, val in meta_data.items():
        img = Manifest._format(post, val, 'init')
        obj, created = Manifest.objects.get_or_create(directory_id=img['directory_id'], name=img['name'], defaults=img)

    count = Manifest.objects.filter(directory_id=img['directory_id']).count()

    return Controller.render_json({'success':True, 'count':count, 'directory_id':img['directory_id']})
Esempio n. 10
0
    def rotate(req):
        _dir = req.GET.get('dir')
        _file = req.GET.get('file_name')
        _path = "{}{}/{}".format(settings.UPLOAD_DIR, _dir, _file)
        _thumb = "{}{}/thumbs/".format(settings.UPLOAD_DIR, _dir)
        img = Image.open(_path)
        img = img.rotate(90)
        img.save(_path)
        thumb_nail([_path], _thumb, (500, 500))

        return Controller.render_json({
            'dir': _dir,
            'file_name': _file,
            'path': _path
        })
Esempio n. 11
0
 def create(req):
     id = False
     if req.method == 'POST':
         nw = UI.objects.create(
             **{
                 'name': req.POST.get('name'),
                 'type': req.POST.get('type'),
                 'markup': req.POST.get('markup'),
                 'group': req.POST.get('group'),
             })
         id = nw.id
         nw.markup = nw.markup.format(nw.id)
         nw.save()
     return Controller.render_json({
         'success': True,
         'id': id,
     })
Esempio n. 12
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')
Esempio n. 13
0
 def update(req):
   """
   Update an a indexed image from the sort route.
   """
   if req.method == "POST":
       p = req.POST
       m = Manifest.objects.get(id=p.get('id'))
       m.subject       = p.get('subject')
       m.company_id    = p.get('company_id')
       m.location_id   = p.get('location_id')
       m.section_id    = p.get('section_id')
       m.date          = p.get('date')
       m.lat           = p.get('lat')
       m.lng           = p.get('lng')
       m.sequence      = p.get('sequence')
       m.import_status = 'sequence'
       m.save()
   return Controller.render_json({'success': True, 'params':req.POST})
Esempio n. 14
0
 def index(req):
   return Controller.goto('index/index.html')
Esempio n. 15
0
 def router(req, **kwargs):
     return Controller.route(CompanyController, CompanyController.actions,
                             req, kwargs)
Esempio n. 16
0
 def router(req, **kwargs):
   return Controller.route(SectionController, SectionController.actions, req, kwargs)
Esempio n. 17
0
 def delete_all(req):
     UI.objects.filter(**{}).delete()
     return Controller.render_json({'action': 'delete_all'})
Esempio n. 18
0
 def index(req):
   """ List the all locations  """
   v = ('id', 'name', 'section_id', 'section__name', 'lat', 'lng')
   locs = Location.objects.filter(**{}).values(*v)
   return Controller.render_json({'locations':list(locs), "total": len(locs)})
Esempio n. 19
0
 def index(req):
   """ List the all Sections  """
   secs = Section.objects.all().values()
   return Controller.render_json({'sections':list(secs), "total": len(secs)})
Esempio n. 20
0
 def logout(req):
     logout(req)
     return Controller.goto('index')
Esempio n. 21
0
 def index(req):
     return Controller.render(req, {}, 'collect/index.html')
Esempio n. 22
0
 def router(req, **kwargs):
     return Controller.route(ImgEditor, ImgEditor.actions, req, kwargs)
Esempio n. 23
0
 def get_sequence(req):
     f = {'sequence': req.GET.get('sequence')}
     sequence = Manifest.objects.filter(**f).values(*Manifest.default_fields());
     return Controller.render_json({'results':list(sequence), "total": len(sequence)})
Esempio n. 24
0
 def router(req, **kwargs):
   return Controller.route(ImageController, ImageController.actions, req, kwargs)
Esempio n. 25
0
 def manifest(req):
     imgs = Manifest.objects.filter(directory_id=req.GET.get('directory_id')).values(*Manifest.default_fields())
     return Controller.render_json({'results':list(imgs)})
Esempio n. 26
0
 def router(req, **kwargs):
   return Controller.route(Collect, Collect.actions, req, kwargs)