Syntax Plain Text Markdown reStructuredText Plain Code ABAP ApacheConf AppleScript ActionScript Bash BBCode C C++ Clojure COBOL CSS CUDA Dart Delphi Diff Django Erlang Fortran Go Groovy Haml Haskell HTML HTTP INI IRC Java JavaScript JSON Lua Makefile Mako Mason Matlab Modula Monkey MySQL NumPy Obj-C OCaml Perl PHP PostScript PowerShell Prolog Properties Puppet Python R Ruby reStructuredText Rust Sass Scala Scheme Scilab SCSS Smalltalk Smarty Solidity SQL Tcl Tcsh TeX VB.net VimL XML XQuery XSLT YAML
Expires One Time Snippet Expire in 1 hour Expire in 24 hours Expire in 7 days
Paste Snippet ⌘+⏎ Ctrl+⏎
Content class Company (models.Model): .... def project_insurance_valid(self, project_pk): insurance_set = self.insurance_set.filter(project=project_pk) expire_within_30_days = False for insurance in insurance_set: if insurance.expired: return False if insurance.expire_within_30_days: expire_within_30_days = True if expire_within_30_days: return "expires within 30 days" else: return True class Insurance(models.Model): project = models.ForeignKey(Project, on_delete=models.CASCADE, null= False, blank= False) company = models.ForeignKey(Company, on_delete=models.CASCADE, null=False, blank=False) @property def expired(self): return self.expiry_date < date.today() @property def expire_within_30_days(self): today = date.today() date_30_days = today + timedelta(days=30) return today <= self.expiry_date <= date_30_days