def get(self, request): ref = db.collection('stfq-market').document('Tenants').collection( 'items').stream() tenants = [] categories = [] stuffes = [] cities = City.objects.filter(province__contains='Jawa') for item in ref: tenant = item.to_dict() tenant['id'] = item.id tenants.append(tenant) ref_categories = db.collection('stfq-market').document( 'Categories').collection('items').stream() for item in ref_categories: category = item.to_dict() category['id'] = item.id categories.append(category) ref_stuffes = db.collection('stfq-market').document( 'Products').collection('items').stream() for item in ref_stuffes: stuff = item.to_dict() stuff['id'] = item.id stuffes.append(stuff) return render( request, self.template, { 'title': 'Market', 'tenants': tenants, 'cities': cities, 'categories': categories, 'stuffes': stuffes })
def post(self, request): type_p = '' try: type_p = request.POST['type'] except: type_p = 'insert' if type_p == 'insert': title = request.POST['title'] subtitle = request.POST['subtitle'] link = request.POST['link'] position = request.POST['position'] image = request.POST['carousel_image'] data = { 'title': title, 'subtitle': subtitle, 'link': link, 'position': position, 'image': image } db.collection('stfq').document('page').collection( 'carousel').document().set(data) return redirect('stfq:carousel') else: c_id = request.POST['id'] ref = db.collection('stfq').document('page').collection( 'carousel').stream() for item in ref: if item.id == c_id: item.reference.delete() return HttpResponse('OK')
def post(self, request): title = request.POST['title'] start = request.POST['start'] end = request.POST['end'] target = request.POST['target'] photo = request.POST['photo'] kind = request.POST.get('type') detail = request.POST['detail'] photos = request.POST['photos'] photos = photos.split(",") while ("" in photos): photos.remove("") data = { 'title': title, 'start': start, 'end': end, 'target': target, 'photo': photo, 'type': kind, 'detail': detail, 'photos': photos, 'report': '-', 'collected': ['0'] } db.collection('Missions').document().set(data) return redirect('mission:list')
def post(self, request): status = '' try: status = request.POST['type'] except: status = 'insert' if status == 'insert': arrs = [] temp = '' product_name = request.POST['product_name'] for i in product_name: temp += i arrs.append(temp) product_price = request.POST['product_price'] product_weight = request.POST['product_weight'] product_date = request.POST['product_date'] product_image = request.POST['product_image'] product_detail = request.POST['product_detail'] categories = request.POST['categories'] a_categories = categories.split(',') f_categories = [] for item in a_categories: ref = db.collection('stfq-market').document( 'Categories').collection('items').document(item).get() print(ref.to_dict()) data = { 'category_id': ref.id, 'category_name': ref.to_dict()['category_name'] } f_categories.append(data) tenant_id = request.POST['tenant_id'] image_collections = request.POST['image_collections'] image_collections = image_collections.split(',') data = { 'product_name': product_name, 'product_price': product_price, 'product_weight': product_weight, 'product_date': product_date, 'product_image': product_image, 'product_detail': product_detail, 'categories': f_categories, 'tenant_id': tenant_id, 'product_query': arrs, 'image_collections': image_collections } print(data) ref = db.collection('stfq-market').document('Products').collection( 'items').document().set(data) return HttpResponse('OK') elif status == 'delete': c_id = request.POST['id'] ref = db.collection('stfq-market').document('Products').collection( 'items').stream() for item in ref: if item.id == c_id: item.reference.delete() return HttpResponse('OK')
def post(self, request): if request.POST['type'] == 'P': link_photo = request.POST.get('path') ref = db.collection('stfq').document('page') ref.update({"image": ArrayRemove([link_photo])}) elif request.POST['type'] == 'V': video_id = request.POST['id'] ref = db.collection('stfq').document('page').collection( 'video').stream() for item in ref: if item.id == video_id: item.reference.delete() return HttpResponse('OK')
def get(self, request): ref = db.collection('s-transactions').where('mis_id','==','12345678') data = ref.stream() list_ = [] for item in data: dict_ = item.to_dict() dict_ ['id']= item.id data = db.collection('User').document(item.to_dict()['p_uid']).get().to_dict() dict_['name'] = data['full_name'] dict_['email'] = data['email'] dict_['phone'] = data['phone'] list_.append(dict_) print(list_) return render(request,self.template,{'title':'List Transaction', 'data':list_})
def post(self, request): if request.POST['type'] == 'P': photos = request.POST['path'] photos = photos.split(',') ref = db.collection('stfq').document('page') ref.update({"image": ArrayUnion(photos)}) elif request.POST['type'] == 'V': video = request.POST['path'] title = request.POST['title'] data = {'link': video, 'title': title, 'status': True} ref = db.collection('stfq').document('page').collection( 'video').document() ref.set(data) return HttpResponse('OK')
def get(self, request, id_structure): ref_carousel = db.collection('Team') doc_carousel= ref_carousel.stream() for carousel in doc_carousel: if carousel.id == id_structure: carousel.reference.delete() return redirect('structure:list')
def get(self, request, id_contact): contact_ref = db.collection('Contact') contact_doc = contact_ref.stream() for contact in contact_doc: if contact.id == id_contact: contact.reference.delete() return redirect('contact:list')
def post(self, request): misi = request.POST['misi'] print(misi) id_profil = request.POST['id'] data_ref = db.collection('Profil').document(id_profil) data_ref.update({'profil_mission': ArrayRemove([misi])}) return HttpResponse('OK')
def get(self, request, id_carousel): ref_carousel = db.collection('Carousel') doc_carousel = ref_carousel.stream() for carousel in doc_carousel: if carousel.id == id_carousel: carousel.reference.delete() return redirect('carousel:list')
def post(self, request): path = request.POST['path'] id_profil = request.POST['id'] path = path.split(',') data_ref = db.collection('Profil').document(id_profil) data_ref.update({'photo_collection': ArrayUnion(path)}) return HttpResponse('OK')
def get(self, request, id_platform): ref_platform = db.collection('Article') doc_platform = ref_platform.stream() for platform in doc_platform: if platform.id == id_platform: platform.reference.delete() return redirect('platform:list')
def get(self, request, id_donation): donation_ref = db.collection('Donation') donation_doc = donation_ref.stream() for donation in donation_doc: if donation.id == id_donation: donation.reference.delete() return redirect('donation:list')
def post(self, request): id_mission = request.POST['id'] link_photo = request.POST['path'] link_photo = link_photo.split(',') ref = db.collection('Missions').document(id_mission) ref.update({"photos": ArrayUnion(link_photo)}) return HttpResponse('OK')
def get(self, request, id_mission): ref_mission = db.collection('Missions') doc_mission = ref_mission.stream() for mission in doc_mission: if mission.id == id_mission: mission.reference.delete() return redirect('mission:list')
def get(self, request): data = db.collection('Pengaduan').stream() list_ = [] for item in data: dict_ = item.to_dict() dict_['id'] = item.id list_.append(dict_) return render(request, self.template, {'title':'Pengaduan', 'data':list_})
def get(self, request): profil_ref = db.collection('Profil') data_profil = profil_ref.stream() list_ = [] for profil in data_profil: for url in profil.to_dict()['photo_collection']: list_.append({'url': url}) return render(request, self.template, {'data': list_, 'id': profil.id})
def get(self, request, id_platform): ref_platform = db.collection('Article').document(id_platform) collection = ref_platform.get() return render( request, self.template, { 'title': 'Update Platform', 'data': collection.to_dict(), 'id': id_platform })
def get(self, request, id_contact): ref_contact = db.collection('Contact').document(id_contact) collection = ref_contact.get() return render( request, self.template, { 'title': 'Update Contact', 'data': collection.to_dict(), 'id': id_contact })
def getData(request): date = request.POST['date'] donatur = request.POST['donatur'] mission = request.POST['mission'] value = request.POST['value'] ref_user = db.collection('User').document(donatur) donatur_name = ref_user.get().to_dict()['full_name'] ref_mission = db.collection('Missions').document(mission) mission_name = ref_mission.get().to_dict()['mission_name'] data = { 'date': date, 'donatur': donatur, 'mission_id': mission, 'mission_name': mission_name, 'donatur_name': donatur_name, 'value': value } return data
def post(self, request): order_id = request.POST['order_id'] resi = request.POST['resi_order'] service_type = request.POST['service_type'] ref = db.collection('stfq-market').document('Carts').collection( 'items').document(order_id) ref.update({'resi_order': resi, 'service_type': service_type}) print(order_id) return redirect('stfq:market-cart')
def get(self, request): try: data = db.collection('stfq').document('page').get() data_video = db.collection('stfq').document('page').collection( 'video').stream() videos = [] images = data.to_dict()['image'] for item in data_video: member = item.to_dict() member['id'] = item.id videos.append(member) return render(request, self.template, { 'images': images, 'videos': videos }) except: print('empty') return render(request, self.template, {})
def get(self, request): data_carousel = db.collection('stfq').document('page').collection( 'carousel').stream() carousels = [] for item in data_carousel: carousel = item.to_dict() carousel['id'] = item.id carousels.append(carousel) return render(request, self.template, {'c': carousels})
def get(self, request): ref = db.collection('Proposal') data = ref.stream() list_proposal = [] for item in data : dict_ = item.to_dict() dict_['id'] = item.id list_proposal.append(dict_) return render(request, self.template, {'title':'Proposal','data':list_proposal})
def get(self, request, id_carousel): ref_carousel = db.collection('Carousel').document(id_carousel) collection = ref_carousel.get() return render( request, self.template, { 'title': 'Update Carousel', 'id': id_carousel, 'data': collection.to_dict(), })
def get(self, request): ref_user = db.collection('User') data_user = ref_user.stream() list_user = [] for user in data_user: dict_member = user.to_dict() dict_member['id'] = user.id list_user.append(dict_member) return JsonResponse(list_user, safe=False)
def get(self, request): ref_mission = db.collection('Missions') data_mission = ref_mission.stream() list_mission = [] for mission in data_mission: dict_member = mission.to_dict() dict_member['id'] = mission.id list_mission.append(dict_member) return JsonResponse(list_mission, safe=False)
def get(self, request, id_mission): ref_mission = db.collection('Missions').document(id_mission) collection = ref_mission.get() return render( request, self.template, { 'title': 'Update Mission', 'data': collection.to_dict(), 'id': id_mission })
def get(self, request, id_donation): ref_donation = db.collection('Donation').document(id_donation) collection = ref_donation.get() return render( request, self.template, { 'title': 'Update Donation', 'data': collection.to_dict(), 'id': id_donation, })