diff --git a/core/apps/wherehouse/data/warehouse.json b/core/apps/wherehouse/data/warehouse.json new file mode 100644 index 0000000..94aee19 --- /dev/null +++ b/core/apps/wherehouse/data/warehouse.json @@ -0,0 +1,667 @@ +{ + "data": { + "warehouses": [ + { + "id": 22, + "name": "MAVRID (\u0424\u0410\u0420\u041c)", + "users": [ + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 110, + "full_name": "Imomov Jasurbek", + "image": null + }, + { + "id": 112, + "full_name": "QIYOMOV TEMURBEK", + "image": null + }, + { + "id": 111, + "full_name": "MARDONOVA DILAFRUZ", + "image": null + }, + { + "id": 113, + "full_name": "Durdona", + "image": null + }, + { + "id": 107, + "full_name": "Iskandarov Farrux", + "image": null + }, + { + "id": 108, + "full_name": "Xudjaqulov Abbos", + "image": null + }, + { + "id": 109, + "full_name": "Mirjonov Meronshox", + "image": null + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 23, + "name": "marketing", + "users": [ + { + "id": 113, + "full_name": "Durdona", + "image": null + }, + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 109, + "full_name": "Mirjonov Meronshox", + "image": null + }, + { + "id": 111, + "full_name": "MARDONOVA DILAFRUZ", + "image": null + }, + { + "id": 108, + "full_name": "Xudjaqulov Abbos", + "image": null + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 49, + "name": "Prorab qurilish MAVRID", + "users": [ + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 108, + "full_name": "Xudjaqulov Abbos", + "image": null + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 211, + "full_name": "\u0420\u0443\u0441\u0442\u0430\u043c\u043e\u0432 \u0428\u0435\u0440\u0437\u043e\u0434", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 50, + "name": "Yunusobod ombor", + "users": [ + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 202, + "full_name": "\u0421\u0430\u043c\u0430\u0434\u043e\u0432 \u041c\u0435\u0445\u0440\u0438\u0434\u0434\u0438\u043d", + "image": null + }, + { + "id": 219, + "full_name": "\u0422\u0443\u0445\u0442\u0430\u0435\u0432\u0430 \u0428\u0430\u0445\u0437\u043e\u0434\u0430", + "image": null + }, + { + "id": 107, + "full_name": "Iskandarov Farrux", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 51, + "name": "Yunusobod marketing", + "users": [ + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 113, + "full_name": "Durdona", + "image": null + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 62, + "name": "Yunusobod sklad instrument", + "users": [ + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 219, + "full_name": "\u0422\u0443\u0445\u0442\u0430\u0435\u0432\u0430 \u0428\u0430\u0445\u0437\u043e\u0434\u0430", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 63, + "name": "Yunusobod adminstrativniy xarajatlar", + "users": [ + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 147, + "full_name": "Rajabov Shohruh", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/W2XUDsHUUnr4E3mjfJIx.webp" + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 101, + "name": "\u041e\u0444\u0438\u0441", + "users": [ + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 109, + "full_name": "Mirjonov Meronshox", + "image": null + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 108, + "name": "Mavrid sklad instrument", + "users": [ + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 110, + "full_name": "Imomov Jasurbek", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 109, + "name": "Yunusobod sklad inventar", + "users": [ + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 219, + "full_name": "\u0422\u0443\u0445\u0442\u0430\u0435\u0432\u0430 \u0428\u0430\u0445\u0437\u043e\u0434\u0430", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 110, + "name": "Mavrid sklad inventar", + "users": [ + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 110, + "full_name": "Imomov Jasurbek", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 111, + "name": "Yunusobod Ofis", + "users": [ + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 109, + "full_name": "Mirjonov Meronshox", + "image": null + }, + { + "id": 107, + "full_name": "Iskandarov Farrux", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 112, + "name": "Mavrid Ofis", + "users": [ + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 109, + "full_name": "Mirjonov Meronshox", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 114, + "name": "Prorab Qurilish Yunusobod", + "users": [ + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 211, + "full_name": "\u0420\u0443\u0441\u0442\u0430\u043c\u043e\u0432 \u0428\u0435\u0440\u0437\u043e\u0434", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 120, + "name": "\u041c\u0410\u0412\u0420\u0418\u0414 \u0410\u0414\u041c\u0418\u041d\u0418\u0421\u0422\u0420\u0410\u0422\u0418\u0412\u041d\u042b\u0419 \u0420\u0410\u0421\u0425\u041e\u0414", + "users": [ + { + "id": 147, + "full_name": "Rajabov Shohruh", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/W2XUDsHUUnr4E3mjfJIx.webp" + }, + { + "id": 104, + "full_name": "SuperAdminIskander", + "image": "https:\/\/backend.app.uyqur.uz\/public\/upload\/image\/neDbGZivNlWAz5nHopbl.webp" + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 121, + "name": "\u041c\u0410\u0412\u0420\u0418\u0414 \u041a\u0423\u0425\u041d\u042f", + "users": [ + { + "id": 107, + "full_name": "Iskandarov Farrux", + "image": null + }, + { + "id": 110, + "full_name": "Imomov Jasurbek", + "image": null + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 122, + "name": "\u041c\u0410\u0412\u0420\u0418\u0414 \u0410\u041f\u0422\u0415\u041a\u0410", + "users": [ + { + "id": 107, + "full_name": "Iskandarov Farrux", + "image": null + }, + { + "id": 109, + "full_name": "Mirjonov Meronshox", + "image": null + }, + { + "id": 110, + "full_name": "Imomov Jasurbek", + "image": null + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 123, + "name": "\u041c\u0410\u0412\u0420\u0418\u0414 \u041a\u041e\u041d\u0421 \u0422\u041e\u0412\u0410\u0420", + "users": [ + { + "id": 107, + "full_name": "Iskandarov Farrux", + "image": null + }, + { + "id": 110, + "full_name": "Imomov Jasurbek", + "image": null + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 124, + "name": "\u042e\u041d\u0423\u0421\u041e\u0411\u041e\u0414 \u041a\u0423\u0425\u041d\u042f", + "users": [ + { + "id": 107, + "full_name": "Iskandarov Farrux", + "image": null + }, + { + "id": 219, + "full_name": "\u0422\u0443\u0445\u0442\u0430\u0435\u0432\u0430 \u0428\u0430\u0445\u0437\u043e\u0434\u0430", + "image": null + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 125, + "name": "\u042e\u041d\u0423\u0421\u041e\u0411\u041e\u0414 \u0410\u041f\u0422\u0415\u041a\u0410", + "users": [ + { + "id": 107, + "full_name": "Iskandarov Farrux", + "image": null + }, + { + "id": 219, + "full_name": "\u0422\u0443\u0445\u0442\u0430\u0435\u0432\u0430 \u0428\u0430\u0445\u0437\u043e\u0434\u0430", + "image": null + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 126, + "name": "\u042e\u041d\u0423\u0421\u041e\u0411\u041e\u0414 \u041a\u041e\u041d\u0421 \u0422\u041e\u0412\u0410\u0420", + "users": [ + { + "id": 107, + "full_name": "Iskandarov Farrux", + "image": null + }, + { + "id": 219, + "full_name": "\u0422\u0443\u0445\u0442\u0430\u0435\u0432\u0430 \u0428\u0430\u0445\u0437\u043e\u0434\u0430", + "image": null + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + }, + { + "id": 158, + "name": "\u041c\u0410\u0412\u0420\u0418\u0414 \u0425\u0418\u0417\u041c\u0410\u0422\u041b\u0410\u0420", + "users": [ + { + "id": 110, + "full_name": "Imomov Jasurbek", + "image": null + }, + { + "id": 138, + "full_name": "Baratova Zilola", + "image": null + }, + { + "id": 107, + "full_name": "Iskandarov Farrux", + "image": null + }, + { + "id": 306, + "full_name": "Uyqur Support", + "image": null + } + ], + "status": "active" + } + ], + "warehouse_folders": [] + }, + "message": { + "uz": "Muvaffaqiyatli!", + "ru": "\u0423\u0441\u043f\u0435\u0448\u043d\u043e!", + "en": "Success!", + "tr": "Ba\u015far\u0131l\u0131!" + } +} \ No newline at end of file diff --git a/core/apps/wherehouse/management/commands/import_warehouse.py b/core/apps/wherehouse/management/commands/import_warehouse.py index caf26b9..2627840 100644 --- a/core/apps/wherehouse/management/commands/import_warehouse.py +++ b/core/apps/wherehouse/management/commands/import_warehouse.py @@ -2,6 +2,7 @@ import json from django.core.management import BaseCommand from core.apps.wherehouse.models import WhereHouse +from core.apps.accounts.models import User class Command(BaseCommand): @@ -15,8 +16,12 @@ class Command(BaseCommand): data = json.load(f) for item in data['data']['warehouses']: - WhereHouse.objects.get_or_create( + wherehouse, create = WhereHouse.objects.update_or_create( name=item['name'] ) - + full_names = [] + for user in item['users']: + full_names.append(user['full_name']) + users = User.objects.filter(full_name__in=full_names) + wherehouse.users.set(users) self.stdout.write("Warehouses added") \ No newline at end of file