This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ref, uploadBytesResumable, getDownloadURL } from "firebase/storage"; | |
| import storage from "../firebase.config"; | |
| export async function uploadFiles(files) { | |
| const concurrentUploads = []; | |
| for (let file of files) { | |
| const upload = () => { | |
| return new Promise((resolve, reject) => { | |
| const storageRef = ref(storage, `/files/${file.name}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ListingNode(DjangoObjectType): | |
| class Meta: | |
| model = Listing | |
| interfaces = (graphene.relay.Node, ) | |
| class ListingQuery(graphene.ObjectType): | |
| category = Category.objects.all() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| 'details': [ | |
| ['bedrooms', 'number', 'contains'], ['building_size', 'number', 'gte'], | |
| ['built_year', 'number', 'gte'], ['city', 'string', 'contains'], | |
| ['country', 'string', 'contains'], ['floors', 'number', 'gte'], | |
| ['max_price', 'number', 'lte'], ['plot_size', 'number', 'gte'], | |
| ['min_price', 'number', 'gte'], ['renovated_year', 'number', 'gte'], | |
| ['state', 'string', 'contains'], ['street_address', 'string', 'contains'], | |
| ['title', 'string', 'contains'], ['zip', 'string', 'contains'] | |
| ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import django_filters | |
| from graphene.types.generic import GenericScalar | |
| def FilterFactory( model_class, class_name, nested_key_qs): | |
| class_vars = { | |
| 'Meta': type( 'Meta', (object, ), { | |
| "model": model_class, | |
| "fields": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ListingFilter(django_filters.FilterSet): | |
| def __init_subclass__(cls, **kwargs): | |
| super().__init_subclass__(**kwargs) | |
| for field in Listing._meta.get_fields(): | |
| field_name = (field.__str__().split('.'))[-1] | |
| if field_name == 'details': | |
| cls.get_declared_filters['min_price'] = \ | |
| django_filters.NumberFilter( | |
| field_name='details__price', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import graphene | |
| from product.models import Ad | |
| from graphene_django.filter import DjangoFilterConnectionField | |
| import django_filters | |
| from graphene_django import DjangoObjectType | |
| class ListingFilter(django_filters.FilterSet): | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import django_filters | |
| class ListingFilter(django_filters.FilterSet): | |
| class Meta: | |
| model = Listing | |
| fields = { | |
| 'user__id': ['contains'], | |
| 'sub_category__sub_category_name': ['contains'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import django_filters | |
| class ListingFilter(django_filters.FilterSet): | |
| class Meta: | |
| model = Listing | |
| fields = { | |
| 'sub_category__sub_category_name': ['contains'], | |
| 'is_active': ['exact'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Listing(models.Model): | |
| id = models.CharField(primary_key=True, unique=True, editable=False, default=get_str, max_length=40) | |
| user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="user_listing") | |
| sub_category = models.ForeignKey(SubCategory, on_delete=models.SET_NULL, related_name="sub_category") | |
| is_active = models.BooleanField(default=True) | |
| published_date = models.DateTimeField(auto_now_add=True) | |
| details = models.JSONField(default=dict) | |
| facilities = models.JSONField(default=dict) | |
| nearby = models.JSONField(default=dict) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SHELL := /bin/zsh | |
| ENV := . env/bin/activate | |
| PY := $(ENV) && python manage.py | |
| help: | |
| @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | |
| venv: | |
| python3.9 -m venv env && $(ENV) && python -m pip install --upgrade pip |