예제 #1
0
def add_product_variant(request):
    result = simplejson.dumps({
        "html": "Hi",
        "message": "Hi",
    }, cls=LazyEncoder)
    item_uuid = request.GET.get('item_uuid','')
    logging.error(item_uuid)
    item = Item.objects.get(uuid=item_uuid)
    old_products = Product.objects.filter(slug=item.uuid)
    if len(old_products)>0:
        return HttpResponse(result)
    controller = Controller()
    controller.item_to_product(item);
    product = Product.objects.get(ghdefinition=item.definition)
    #props = product.get_properties()
    slug = item_uuid
    sku = item_uuid[:30]
    price = product.price
    name = product.name
    variants_count = product.variants.count()
    variant = Product(name=name, slug=slug, sku=sku, parent=product, price=price, item=item, 
                      active=True, active_images=True, active_sku=True, active_price=True, active_name=False,
                      variant_position=(variants_count + 1), sub_type=VARIANT)  
    
    variant.save()
    return HttpResponse(result)
예제 #2
0
 def save_model(self, request, obj, form, change):
     form.default_material = Material.objects.all()[1]
     obj.default_material = Material.objects.all()[1]
     super(GhDefinitionAdmin, self).save_model(request, obj, form, change)
     if change==False:
         obj.set_defaults()
         p = Product(name=obj.name, slug=uuid.uuid1(), ghdefinition=obj, sub_type=PRODUCT_WITH_VARIANTS, active=False)
         p.save()
         
     if "uploaded_file" in form.changed_data:
         controller = Controller()
         obj.set_file_name()
         controller.process_ghx(obj)
         obj.save()
예제 #3
0
def get_stl(request):
    print "get stl"
    slug = request.GET.get('product', '')#Product.objects.get()
    print slug
    product = Product.objects.get(slug=slug) #queryset[0].get_item()
    item = product.get_item()
    controller = Controller('near', 'Default', 1)
    print item.uuid
    controller.get_stl(item.uuid)
    url = "https://s3.amazonaws.com/deploy_stl_bucket/%s.stl" % item.uuid
    #signed_url = s3_signed_url("deploy_stl_bucket","%s.stl" % item.uuid)
    #print signed_url
    result = simplejson.dumps({
        "url": url
    }, cls=LazyEncoder)
    return HttpResponse(result)  
예제 #4
0
def explore(request):
    param_index = int(request.GET.get('param_index', 0)) 
    explore_type = request.GET.get('explore_type', 'explore')
    material = request.GET.get('material', 'Default')
    text = request.GET.get('text', '')
    text = text.strip()
      
    controller = Controller(material)
    start_product = request.GET.get('start_product', None)
    if (start_product):
        product = Product.objects.get(slug=start_product)
        if product.is_variant() == False:
            gh_def = product.ghdefinition
            if material == 'Available':
                items = controller.render_materials(None, gh_def.id, text)
            else:
                items = controller.get_random_items(product)
               
        else:
            if material == 'Available':
                items = controller.render_materials(start_product, None, text)
            else:
                items = controller.explore(start_product, param_index, explore_type, text)            
    
    else:   
        item_id = request.GET.get('item_id','')
        if material == 'Available':
            items = controller.render_materials(item_id, None, text)
        else:
            items = controller.explore(item_id, param_index, explore_type, text)

    json = simplejson.dumps(items)
    return HttpResponse(json, mimetype='text/javascript')
예제 #5
0
def send_background_items():
    controller = Controller()  
    controller.send_background_items()
예제 #6
0
def send_deep_jobs(items):
    controller = Controller()
    controller._send_deep_jobs(items)
예제 #7
0
def send_missing_jobs(items):
    controller = Controller()
    controller._send_missing_jobs(items)
예제 #8
0
def send_jobs(definition, uuids, root, params, material, explore_type, text, base_models=None, param_index=None):
    #return True
    controller = Controller(material, explore_type)
    controller._send_jobs(definition, uuids, root, params, text, base_models=base_models,param_index=param_index)
예제 #9
0
def send_deep(children, r1, r2):
    controller = Controller(r1, r2)
    controller._send_deep(children)
예제 #10
0
def get_stl(modeladmin, request, queryset):
    #queryset.update(status='p')
    item = queryset[0].get_item()
    controller = Controller('near', 'Default', 1)
    controller.get_stl(item.uuid)
예제 #11
0
def process_ghx(modeladmin, request, queryset):
    definition = queryset[0]
    controller = Controller()
    controller.process_ghx(definition)
예제 #12
0
def send_background_items(modeladmin, request, queryset):
    controller = Controller('Default', 1)
    controller.send_background_items()
예제 #13
0
def preprocess_items(modeladmin, request, queryset):
    definition = queryset[0]
    controller = Controller('Default', 1)
    controller.preprocess_definition(definition)