Revision 09e7393c snf-astakos-app/astakos/im/models.py

b/snf-astakos-app/astakos/im/models.py
181 181
        q = q.filter(is_active = self.is_active)
182 182
        if q.count() != 0:
183 183
            raise ValidationError({'__all__':[_('Another account with the same email & is_active combination found.')]})
184
        
184
    
185
    def signed_terms(self):
186
        term = get_latest_terms()
187
        if not term:
188
            return True
189
        if not self.has_signed_terms:
190
            return False
191
        if not self.date_signed_terms:
192
            return False
193
        if self.date_signed_terms < term.date:
194
            self.has_signed_terms = False
195
            self.save()
196
            return False
197
        return True
198

  
185 199
class ApprovalTerms(models.Model):
186 200
    """
187 201
    Model for approval terms
......
254 268
            Invitation.objects.get(code=code)
255 269
            # An invitation with this code already exists, try again
256 270
        except Invitation.DoesNotExist:
257
            return code
271
            return code
272

  
273
def get_latest_terms():
274
    try:
275
        term = ApprovalTerms.objects.order_by('-id')[0]
276
        return term
277
    except IndexError:
278
        pass
279
    return None

Also available in: Unified diff