npm install -g .$ sudo -E xfwd| class Payments(models.Model): | |
| STATES = { | |
| 'started': 'Started', | |
| 'captured': 'Captured', | |
| 'completed': 'Completed', | |
| 'incomplete': 'Incomplete', # new incomplete state for us | |
| } | |
| def __init__(self, *args, **kwargs): | |
| super(Payments, self).__init__(*args, **kwargs) |
| class Payments(models.Model): | |
| STATES = { | |
| 'started': 'Started', | |
| 'captured': 'Captured', | |
| 'completed': 'Completed', | |
| } | |
| state = models.CharField(default='started', choices=STATES.items(), max_length=16) | |
| def __init__(self, *args, **kwargs): |
| class Payment(models.Model): | |
| STATE_CHOICES = ( | |
| ('started', 'Started'), | |
| ('captured', 'Captured'), | |
| ('completed', 'Completed'), | |
| # we introduce a new "incomplete" state | |
| ('incomplete', 'Incomplete'), | |
| ) | |
| def can_complete(self): |
| class Payment(models.Model): | |
| STATE_CHOICES = ( | |
| ('started', 'Started'), | |
| ('captured', 'Captured'), | |
| ('completed', 'Completed'), | |
| ) | |
| state = models.CharField(choices=STATE_CHOICES, default='started', max_length=16) | |
| def can_capture(self): |
| class Payment(models.Model): | |
| is_started = models.BooleanField(default=True) | |
| is_captured = models.BooleanField(default=False) | |
| is_completed = models.BooleanField(default=False) | |
| def can_capture(self): | |
| return self.is_started and not self.is_captured and not self.is_completed | |
| def can_complete(self): | |
| return self.is_captured |
| from transitions import Machine | |
| class Payments(models.Model): | |
| STATES = { | |
| 'started': 'Started', | |
| 'captured': 'Captured', | |
| 'completed': 'Completed', | |
| } |
| ### Keybase proof | |
| I hereby claim: | |
| * I am dhruvbaldawa on github. | |
| * I am dhruvbaldawa (https://keybase.io/dhruvbaldawa) on keybase. | |
| * I have a public key whose fingerprint is 7C20 B07E 23F3 2875 0BD1 FC85 3825 385A 7C27 34C1 | |
| To claim this, I am signing this object: |
| import urllib2 | |
| import time | |
| import os | |
| msg_string = 'Result for %s %s declared.' | |
| url = 'http://results.mu.ac.in/choose_nob.php?exam_id=%s&exam_year=2012&exam_month=MAY' | |
| # some exam_id to start looking from | |
| id_start = 2765 |
| def foo(): | |
| try: | |
| return True | |
| except: | |
| pass | |
| else: | |
| return False |