Skip to content

Instantly share code, notes, and snippets.

View korgx9's full-sized avatar
🐢

Kishvarsho Pallaev korgx9

🐢
View GitHub Profile
func postImages(_ orderId: String, images: [UIImage]) {
var tmpImages = images
Alamofire.upload(multipartFormData: {
multipartFormData in
multipartFormData.append(orderId.data(using: String.Encoding.utf8, allowLossyConversion: false)!, withName: "order")
multipartFormData.append(UIImageJPEGRepresentation(images[0], 95)!, withName: "image", fileName: orderId + "_picture.jpg", mimeType: "image/jpg")
}, to: UserOrderUploadImageURL, encodingCompletion: {
encodingResult in
switch encodingResult {
func changeViewController(menu: LeftMenu) {
self.controller = MenuNavigationController()
switch menu {
case .Search:
self.controller = MenuNavigationController(rootViewController:searchViewController)
self.slideMenuController()?.changeMainViewController(self.controller, close: true)
break
case .MyAdvertisements:
@korgx9
korgx9 / gist:a51cd5b452f89cb60e960df9571838b0
Created December 12, 2016 12:02
Ошибка на серваке. Просто нужно узнать что я неправильно отправляю
TypeError at /api/v1/users/3/orders
Got a `TypeError` when calling `Order.objects.create()`. This may be because you have a writable field on the serializer class that is not a valid argument to `Order.objects.create()`. You may need to make the field read-only, or override the OrderSerializer.create() method to handle this correctly.
Original exception was:
Traceback (most recent call last):
File \"/usr/local/lib/python2.7/site-packages/rest_framework/serializers.py\", line 902, in create
instance = ModelClass.objects.create(**validated_data)
File \"/usr/local/lib/python2.7/site-packages/django/db/models/manager.py\", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File \"/usr/local/lib/python2.7/site-packages/django/db/models/query.py\", line 399, in create
obj.save(force_insert=True, using=self.db)
static let BodyType: [String: String] = [
"sedan": "Седан",
"touring": "Универсал",
"hatchback": "Хетчбэк",
"compartment": "Купе",
"limousine": "Лимузин",
"minivan": "Минивэн",
"hardtop": "Хардтоп",
"town_car": "Таун-кар",
"combi": "Комби",