mirror of
https://github.com/spbleadersofdigtal/backend.git
synced 2024-11-21 11:06:33 +03:00
final updates and fixes
This commit is contained in:
parent
8a000dc1e3
commit
18e43129fe
|
@ -112,8 +112,8 @@ def create_hints(description: str, stage: int):
|
|||
].group()
|
||||
if not len(filtered_content):
|
||||
raise ValueError(f"answer doesnt pass validation, {filtered_content}")
|
||||
except:
|
||||
raise ValueError(f"answer doesnt pass validation, {filtered_content}")
|
||||
except Exception:
|
||||
print(f"answer doesnt pass validation")
|
||||
content = literal_eval(filtered_content)
|
||||
for assertion_statement in assertions[stage]:
|
||||
assert assertion_statement(content)
|
||||
|
|
|
@ -17,11 +17,12 @@
|
|||
class BasePitchDeckSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = PitchDeck
|
||||
fields = ["id", "name", "description", "logo", "created", "updated"]
|
||||
fields = ["id", "name", "description", "logo", "created", "images", "updated"]
|
||||
extra_kwargs = {
|
||||
"id": {"read_only": True},
|
||||
"logo": {"read_only": True},
|
||||
"name": {"read_only": True},
|
||||
"images": {"read_only": True},
|
||||
"created": {"read_only": True},
|
||||
"updated": {"read_only": True},
|
||||
}
|
||||
|
@ -138,8 +139,8 @@ def validate(self, data):
|
|||
raise serializers.ValidationError("Value to found")
|
||||
if not isinstance(answer[slug], (int, float)):
|
||||
raise serializers.ValidationError("Incorrect type")
|
||||
if not (params["min_value"] <= answer[slug] <= params["max_value"]):
|
||||
raise serializers.ValidationError("Number is too big or too small")
|
||||
# if not (params["min_value"] <= answer[slug] <= params["max_value"]):
|
||||
# raise serializers.ValidationError("Number is too big or too small")
|
||||
case "multiple_range":
|
||||
scrollbars = {}
|
||||
for el in params["scrollbars"]:
|
||||
|
@ -149,14 +150,14 @@ def validate(self, data):
|
|||
raise serializers.ValidationError(f"Value {slug} to found")
|
||||
if not isinstance(answer[slug], (int, float)):
|
||||
raise serializers.ValidationError(f"Incorrect {slug} type")
|
||||
if not (
|
||||
scrollbars[slug]["min_value"]
|
||||
<= answer[slug]
|
||||
<= scrollbars[slug]["max_value"]
|
||||
):
|
||||
raise serializers.ValidationError(
|
||||
f"Number is too big or too small for {slug}"
|
||||
)
|
||||
# if not (
|
||||
# scrollbars[slug]["min_value"]
|
||||
# <= answer[slug]
|
||||
# <= scrollbars[slug]["max_value"]
|
||||
# ):
|
||||
# raise serializers.ValidationError(
|
||||
# f"Number is too big or too small for {slug}"
|
||||
# )
|
||||
case "select":
|
||||
if answer not in params["options"]:
|
||||
raise serializers.ValidationError("No such option")
|
||||
|
|
|
@ -91,7 +91,7 @@ class GetDeckPresentationDataApiView(generics.GenericAPIView):
|
|||
10: ["how_much_investments", "time_to_spend", "investments_sold"],
|
||||
11: ["company_value", "future_value", "time_to_spend"],
|
||||
12: ["aims"],
|
||||
13: ["images"],
|
||||
13: ["images", "links"],
|
||||
}
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 4.2.4 on 2023-08-26 23:06
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("decks", "0008_pdftopptxstorage_alter_question_type"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="pitchdeck",
|
||||
name="images",
|
||||
field=models.JSONField(null=True),
|
||||
),
|
||||
]
|
|
@ -11,6 +11,7 @@ class PitchDeck(models.Model):
|
|||
|
||||
# generated info
|
||||
logo = models.ImageField(upload_to="logos/", null=True, blank=True)
|
||||
images = models.JSONField(null=True)
|
||||
styles = models.FileField(upload_to="styles/", null=True, blank=True)
|
||||
presentation = models.FileField(upload_to="logos/", null=True, blank=True)
|
||||
meta_info = models.JSONField(default=dict, null=True, blank=True)
|
||||
|
|
|
@ -15,7 +15,7 @@ def get_image_mokeup(image_path):
|
|||
)
|
||||
else:
|
||||
q = mockup.generate(
|
||||
template_id=mockup.templates[0].id,
|
||||
template_id="d95345535d98fcc6f4030e1d3ca62052",
|
||||
screenshot_path=image_path,
|
||||
color=mockup.templates[0].colors[0].color,
|
||||
)
|
||||
|
|
|
@ -34,7 +34,7 @@ def question_answer_create(sender, instance: QuestionAnswer, created, **kwargs):
|
|||
kwargs={"pk": instance.deck.pk}, countdown=1
|
||||
)
|
||||
elif instance.question.inner_tag == "names":
|
||||
instance.deck.name = instance.answer
|
||||
instance.deck.name = instance.answer if instance.answer else None
|
||||
instance.deck.save()
|
||||
elif instance.question.inner_tag in ["finance_model"]:
|
||||
qenerate_answer_qr.apply_async(kwargs={"pk": instance.pk}, countdown=5)
|
||||
|
@ -50,6 +50,9 @@ def question_answer_update(sender, instance: QuestionAnswer, **kwargs):
|
|||
generate_numeric_values.apply_async(
|
||||
kwargs={"pk": instance.deck.pk}, countdown=1
|
||||
)
|
||||
elif instance.question.inner_tag == "names":
|
||||
instance.deck.name = instance.answer if instance.answer else None
|
||||
instance.deck.save()
|
||||
elif instance.question.inner_tag in ["finance_model"]:
|
||||
qenerate_answer_qr.apply_async(kwargs={"pk": instance.pk}, countdown=5)
|
||||
elif instance.question.inner_tag == "images":
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
)
|
||||
from pitch_deck_generator.decks.services import get_image_mokeup
|
||||
|
||||
ML_HOST = "https://forty-eggs-slide.loca.lt/"
|
||||
ML_HOST = "https://small-teeth-own.loca.lt/"
|
||||
|
||||
data_types = {
|
||||
"names": ("text", 1),
|
||||
|
@ -56,10 +56,11 @@
|
|||
|
||||
@shared_task
|
||||
def run_pitch_deck_calculation(pk: int):
|
||||
generate_pitch_deck_name.apply_async(kwargs={"pk": pk})
|
||||
generate_known_values.apply_async(kwargs={"pk": pk})
|
||||
generate_pitch_deck_name.apply_async(kwargs={"pk": pk}, countdown=1)
|
||||
generate_known_values.apply_async(kwargs={"pk": pk}, countdown=1)
|
||||
for i in range(3):
|
||||
generate_batch_hints.apply_async(kwargs={"pk": pk, "num": i}, delay=1)
|
||||
generate_batch_hints.apply_async(kwargs={"pk": pk, "num": i}, countdown=1)
|
||||
generate_pitch_deck_images.apply_async(kwargs={"pk": pk}, countdown=1)
|
||||
|
||||
|
||||
@shared_task
|
||||
|
@ -74,6 +75,19 @@ def generate_pitch_deck_name(pk: int):
|
|||
)
|
||||
|
||||
|
||||
@shared_task
|
||||
def generate_pitch_deck_images(pk: int):
|
||||
pitch_deck = PitchDeck.objects.get(pk=pk)
|
||||
req = requests.post(
|
||||
ML_HOST + "img-search",
|
||||
json={"body": pitch_deck.description},
|
||||
)
|
||||
print(req.text)
|
||||
data = req.json()
|
||||
pitch_deck.images = data
|
||||
pitch_deck.save()
|
||||
|
||||
|
||||
@shared_task
|
||||
def generate_known_values(pk: int):
|
||||
pitch_deck = PitchDeck.objects.get(pk=pk)
|
||||
|
@ -81,6 +95,7 @@ def generate_known_values(pk: int):
|
|||
ML_HOST + "search",
|
||||
json={"body": pitch_deck.description},
|
||||
)
|
||||
print(req.text)
|
||||
data = req.json()
|
||||
_, question_id = data_types["competitors"]
|
||||
QuestionDeckHint.objects.create(
|
||||
|
@ -134,6 +149,7 @@ def generate_numeric_values(pk: int):
|
|||
"type": type,
|
||||
},
|
||||
)
|
||||
print(req.text)
|
||||
data = req.json()
|
||||
for el in data:
|
||||
question_type, question_id = data_types[el["type"]]
|
||||
|
|
Loading…
Reference in New Issue
Block a user