Beispiel #1
0
 def save_model(self, request, obj, form, change):
     if request.POST.get('urlname').strip() == "" and obj.id:
         obj.urlname = str(obj.id) + '_' + escape.escape_to_folder( request.POST.get('title') )
         obj.save()
     elif request.POST.get('urlname').strip() == "" and not obj.id:
         obj.urlname = 'temporary'
         obj.save()
         obj.urlname = str(obj.id) + '_' + escape.escape_to_folder( request.POST.get('title') )
         obj.save()
     else:
         obj.save()
Beispiel #2
0
def insert_parts():
    from tools.fullparts import allparts
    for i in allparts:
        r = create_description( i['title'] )
        p = Parts( title = i['title'],
                    code = None,
                    short_title = i['title'],
                    description = r['description'], 
                    place_name = r['place_name'],
                    phone = r['phone'],
                    buyer_name = r['buyer_name'],
                    body = i['template'],
                    preview_picture = 'internal/nophoto.png', 
                    status = APUBLISHED, 
                    pagetype = PAGE_CONTENT, 
                    used_price_min = i['used_price_min'],
                    used_price_max = i['used_price_max'],
                    manufacture = Manufacture.objects.get( pk=2 ),
                    carmodel = CarModel.objects.get(pk = icarmodel[ i['carmodel'] ])
                    )
        rmodifications = [ imodifications[x] for x in i['modifications'] ]
        rgroups = [ igroups[x]  for x in i['groups'] ]
        p.save()
        p.urlname = str(p.id) + '_' + escape.escape_to_folder( i['title'].decode('utf-8') )
        p.modification.add( *rmodifications )
        p.group.add( *rgroups )
        p.save()
        DBOUT( p.title )
        for a in i['alias']:
            pa = PartsAlias( title=a, parts=p )
            pa.save()