Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:pydanny/isthisfor

  • Loading branch information...
commit 5fe2587a5eeaf4539d6b22a1fb2b689644f91228 2 parents 3f8309a + 7e9b31a
@pydanny authored
Showing with 13 additions and 28 deletions.
  1. +13 −28 project/pitch/models.py
View
41 project/pitch/models.py
@@ -34,7 +34,7 @@ class Pitch(models.Model):
pitch = models.TextField()
slug = models.SlugField()
pub_date = models.DateField(_('Date Published'), default=datetime.date.today)
- related_pitch = models.CharField(_("Related concepts"), help_text=_("Provide up to three companies with a similiar concept"), max_length=255, blank=True, null=True)
+ related_pitch = models.CharField(_("Related Email"), help_text=_("Provide up to three companies with a similiar concept"), max_length=255, blank=True, null=True)
related_pitch_1 = models.TextField(blank=True, null=True)
related_pitch_2 = models.TextField(blank=True, null=True)
related_pitch_3 = models.TextField(blank=True, null=True)
@@ -61,27 +61,6 @@ def negative_comments(self):
def positive_comments(self):
return Comment.objects.filter(pitch=self, vote=1)
-
- @property
- def related_pitch_title_1(self):
- try:
- return self.related_pitch.split(",")[0]
- except:
- return ""
-
- @property
- def related_pitch_title_2(self):
- try:
- return self.related_pitch.split(",")[1]
- except:
- return ""
-
- @property
- def related_pitch_title_3(self):
- try:
- return self.related_pitch.split(",")[2]
- except:
- return ""
class CommentManager(models.Manager):
@@ -124,9 +103,15 @@ def pitch_pre_save(sender, instance, *args, **kwargs):
pass
else:
for i, rp in enumerate(pitches[:3]):
- url = "http://api.crunchbase.com/v/1/company/{0}.js".format(slugify(rp))
- print url
- resp = requests.get(url)
- if resp.status_code == 200:
- resp = json.loads(resp.content)
- setattr(instance, "related_pitch_{0}".format(i + 1), resp['overview'])
+ resp = requests.get("http://api.crunchbase.com/v/1/company/{0}.js".format(slugify(rp.strip())))
+ try:
+ resp = json.loads(resp.text)
+ except:
+ pass
+ else:
+ try:
+ setattr(instance, "related_pitch_{0}".format(i + 1), resp['overview'])
+ except:
+ pass
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.