forked from Avtech04/Robotics_Club_Website
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
42 additions
and
15 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
import datetime | ||
from django.db import models | ||
from django.utils import timezone | ||
from django.utils.timezone import utc | ||
from django.urls import reverse | ||
# Create your models here. | ||
|
||
class News(models.Model): | ||
|
||
title = models.CharField(blank=False,unique=False,max_length=256) | ||
content =models.TextField() | ||
content = models.TextField() | ||
link = models.URLField(blank=True,null=True) | ||
date = models.DateField(blank=True,unique=False) | ||
is_open = models.BooleanField(default=False) | ||
broadcast = models.DateTimeField(auto_now_add=timezone.now(),blank=True) | ||
|
||
def __str__(self): | ||
return f'{self.title}' | ||
|
||
def save(self, *args,**kwargs): | ||
self.date=timezone.now() | ||
super().save(args,kwargs) | ||
|
||
def allow_broadcast(self): | ||
# return True | ||
now = datetime.datetime.utcnow().replace(tzinfo=utc) | ||
time_difference = now-self.broadcast | ||
if time_difference.total_seconds() > 300: | ||
return True | ||
else: | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters