Skip to content

Commit 707b33f

Browse files
committed
make video url optional
1 parent b78a6d0 commit 707b33f

File tree

4 files changed

+163
-102
lines changed

4 files changed

+163
-102
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,5 @@ dmypy.json
136136
# static
137137

138138
/static/
139+
140+
.DS_Store
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.0.6 on 2025-10-10 22:17
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("grantpicks", "0009_round_minimum_deposit"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="project",
15+
name="video_url",
16+
field=models.URLField(blank=True, null=True),
17+
),
18+
]

grantpicks/models.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ class ProjectContact(models.Model):
2626
name = models.CharField(max_length=255)
2727
value = models.CharField(max_length=255)
2828

29+
2930
class ProjectContract(models.Model):
3031
id = models.AutoField(primary_key=True)
3132
name = models.CharField(max_length=255)
3233
contract_address = models.CharField(max_length=255)
3334

35+
3436
class ProjectRepository(models.Model):
3537
id = models.AutoField(primary_key=True)
3638
label = models.CharField(max_length=255)
@@ -44,21 +46,23 @@ class ProjectFundingHistory(models.Model):
4446
denomination = models.CharField(max_length=255)
4547
description = models.TextField()
4648
timestamp = models.DateTimeField(auto_now_add=True)
47-
49+
4850

4951
class Project(models.Model):
5052
id = models.AutoField(primary_key=True)
51-
on_chain_id =models.IntegerField(
53+
on_chain_id = models.IntegerField(
5254
_("contract project id"),
5355
null=False,
5456
unique=True,
5557
help_text=_("Project id in contract"),
5658
)
5759
image_url = models.URLField(max_length=200)
58-
video_url = models.URLField(max_length=200)
60+
video_url = models.URLField(max_length=200, null=True, blank=True)
5961
name = models.CharField(max_length=255)
6062
overview = models.TextField()
61-
owner = models.ForeignKey(Account, related_name='owned_projects', on_delete=models.CASCADE)
63+
owner = models.ForeignKey(
64+
Account, related_name="owned_projects", on_delete=models.CASCADE
65+
)
6266
contacts = models.ManyToManyField(
6367
ProjectContact,
6468
related_name="contact_lists",
@@ -89,8 +93,6 @@ class Project(models.Model):
8993
)
9094

9195

92-
93-
9496
class Round(models.Model):
9597
id = models.AutoField(
9698
_("round id"),
@@ -155,7 +157,7 @@ class Round(models.Model):
155157
null=False,
156158
help_text=_("Expected amount."),
157159
)
158-
160+
159161
base_currency = models.CharField(
160162
_("base currency"),
161163
max_length=64,
@@ -345,10 +347,7 @@ class Round(models.Model):
345347
)
346348

347349
class Meta:
348-
unique_together = ('chain', 'on_chain_id')
349-
350-
351-
350+
unique_together = ("chain", "on_chain_id")
352351

353352
def update_vault_usd_equivalent(self):
354353
# first, see if there is a TokenHistoricalPrice within 1 day (or HISTORICAL_PRICE_QUERY_HOURS) of self.paid_at
@@ -360,16 +359,17 @@ def update_vault_usd_equivalent(self):
360359
f"No USD price found for token {token.symbol} at {datetime.now()}"
361360
)
362361
return
363-
self.vault_total_deposits_usd = token.format_price(self.vault_total_deposits) * price_usd
364-
self.current_vault_balance_usd = token.format_price(self.current_vault_balance) * price_usd
365-
self.save()
366-
logger.info(
367-
f"Saved USD prices for round vault for round id: {self.id}"
362+
self.vault_total_deposits_usd = (
363+
token.format_price(self.vault_total_deposits) * price_usd
368364
)
365+
self.current_vault_balance_usd = (
366+
token.format_price(self.current_vault_balance) * price_usd
367+
)
368+
self.save()
369+
logger.info(f"Saved USD prices for round vault for round id: {self.id}")
369370
except Exception as e:
370371
logger.error(f"Failed to calculate and stellar vault USD prices: {e}")
371-
372-
372+
373373
def save(self, *args, **kwargs):
374374
if self._state.adding: # If the account is being created (not updated)
375375
if not self.chain_id:
@@ -456,11 +456,12 @@ class RoundDeposit(models.Model):
456456
)
457457

458458
class Meta:
459-
unique_together = ('round', 'on_chain_id')
459+
unique_together = ("round", "on_chain_id")
460+
460461

461462
class Vote(models.Model):
462-
round = models.ForeignKey(Round, on_delete=models.CASCADE, related_name='votes')
463-
voter = models.ForeignKey(Account, on_delete=models.CASCADE, related_name='votes')
463+
round = models.ForeignKey(Round, on_delete=models.CASCADE, related_name="votes")
464+
voter = models.ForeignKey(Account, on_delete=models.CASCADE, related_name="votes")
464465
tx_hash = models.CharField(
465466
_("transaction hash"),
466467
null=True,
@@ -470,25 +471,24 @@ class Vote(models.Model):
470471
voted_at = models.DateTimeField()
471472

472473
class Meta:
473-
unique_together = ('round', 'voter', 'voted_at')
474-
474+
unique_together = ("round", "voter", "voted_at")
475475

476476

477477
class VotePair(models.Model):
478-
vote = models.ForeignKey(Vote, on_delete=models.CASCADE, related_name='pairs')
478+
vote = models.ForeignKey(Vote, on_delete=models.CASCADE, related_name="pairs")
479479
pair_id = models.PositiveIntegerField()
480-
projects = models.ManyToManyField(Account, related_name='vote_pairs_included_in')
480+
projects = models.ManyToManyField(Account, related_name="vote_pairs_included_in")
481481
voted_project = models.ForeignKey(
482482
Account,
483-
on_delete=models.CASCADE,
484-
related_name='vote_pairs_voted_for_in',
483+
on_delete=models.CASCADE,
484+
related_name="vote_pairs_voted_for_in",
485485
null=True,
486-
blank=True
486+
blank=True,
487487
)
488-
#old_project = models.ForeignKey(Account, on_delete=models.CASCADE, related_name='vote_pairs')
488+
# old_project = models.ForeignKey(Account, on_delete=models.CASCADE, related_name='vote_pairs')
489489

490490
class Meta:
491-
unique_together = ('vote', 'pair_id')
491+
unique_together = ("vote", "pair_id")
492492

493493

494494
class StellarEvent(models.Model):
@@ -504,4 +504,4 @@ class StellarEvent(models.Model):
504504
blank=True,
505505
help_text=_("Transaction hash."),
506506
)
507-
processed = models.BooleanField(default=False)
507+
processed = models.BooleanField(default=False)

0 commit comments

Comments
 (0)