final touches, paypal button, spelling errors, donate & twitter links, etc
This commit is contained in:
1 parent
b4bf7980f4
commit
7c32f4759b
46 files changed
+121
-2415
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,5 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import MailMessage, Subscribers
|
||||
# Register your models here.
|
||||
admin.site.register(MailMessage)
|
||||
admin.site.register(Subscribers)
|
||||
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
Winning_Numbers,Chance
|
||||
0-8-9,2/625
|
||||
0-3-8,33/10000
|
||||
|
@@ -1,2 +1,2 @@
|
||||
Winning_Numbers,Chance
|
||||
3-5-7-8,67/1250
|
||||
3-5-6-8,537/10000
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
Winning_Numbers,SB,Chance
|
||||
1-10-32-46-8,[9],1/265200
|
||||
1-10-32-49-8,[9],1/265200
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
Winning_Numbers,MB,Chance
|
||||
17-26-40-52-7,[24],38/151287675
|
||||
17-3-40-52-7,[24],38/151287675
|
||||
|
@@ -1,2 +1,2 @@
|
||||
Winning_Numbers,PB,Chance
|
||||
21-39-59-61-63,[17],3/8854586
|
||||
21-39-59-61-63,[17],50/146100669
|
||||
|
@@ -1,11 +1,12 @@
|
||||
from django.db import models
|
||||
from django.core.mail import send_mail
|
||||
import os, csv
|
||||
|
||||
# Create your models here.
|
||||
class Lotto():
|
||||
module_dir = os.path.dirname(__file__)
|
||||
names = list(["pb", "mm", "la", "d3", "d4", "c25"])
|
||||
files = list()
|
||||
files = []
|
||||
for i in names:
|
||||
files.append(os.path.join(module_dir,"lottopy_web_edition",i+"_ans.csv"))
|
||||
files = [i for i in files if os.path.isfile(i)]
|
||||
@@ -13,4 +14,39 @@ class Lotto():
|
||||
def get_ans(f):
|
||||
ans = csv.DictReader(open(f), delimiter=',')
|
||||
fmt = [str(k)[1:-1].replace("'"," ").replace("_"," ") for k in ans]
|
||||
return str(fmt).replace(",","\n").replace("[","").replace("]","").replace("'","")
|
||||
return str(fmt).replace(",","\n").replace("[","").replace("]","").replace("'","")
|
||||
|
||||
class Subscribers(models.Model):
|
||||
email = models.EmailField()
|
||||
date = models.DateTimeField(auto_now_add=True)
|
||||
def __str__(self):
|
||||
return self.email
|
||||
class Meta:
|
||||
verbose_name_plural = "Subscribers"
|
||||
|
||||
class MailMessage(models.Model):
|
||||
subject = models.CharField(max_length=100)
|
||||
body = models.TextField(null=True)
|
||||
attachment = models.FileField(default=None, null=True, blank=True)
|
||||
users = models.ManyToManyField(Subscribers)
|
||||
send_it = models.BooleanField(default=False) # check to send email
|
||||
|
||||
def save(self):
|
||||
if self.send_it:
|
||||
user_list = []
|
||||
for user in self.users.all():
|
||||
user.email_user(self.subject, self.body, self.attachment)
|
||||
send_mail(str(self.subject),
|
||||
str(self.body),
|
||||
'from@admin.com',
|
||||
user_list,
|
||||
fail_sliently=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.subject
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Emails to send"
|
||||
verbose_name_plural = "Emails to send"
|
||||
|
||||
|
||||
@@ -27,4 +27,5 @@ class data_task():
|
||||
data_task.all_nums.append(pb_file_path, mm_file_path, la_file_path, d3_file_path, d4_file_path, c25_file_path)
|
||||
|
||||
return get_ans(all_nums)
|
||||
#return pbnumbers, mmnumbers, lanumbers, d3numbers, d4numbers, c25numbers
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
# Create your views here.
|
||||
from django.http import HttpResponse
|
||||
from django.views.decorators.http import require_GET
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import render, redirect
|
||||
from django.contrib import messages
|
||||
from django.conf import settings
|
||||
from django.core.cache.backends.base import DEFAULT_TIMEOUT
|
||||
from django.views.decorators.cache import cache_page
|
||||
from .forms import SubscribersForm
|
||||
from .models import Lotto
|
||||
import logging
|
||||
|
||||
@@ -19,11 +21,11 @@ CACHE_TTL = getattr(settings, 'CACHE_TTL', DEFAULT_TIMEOUT)
|
||||
# {'nbar': 'home'})
|
||||
logger = logging.getLogger(__file__)
|
||||
|
||||
|
||||
@cache_page(CACHE_TTL)
|
||||
def home(request):
|
||||
context = {
|
||||
'nbar': 'home',
|
||||
'title': 'Home',
|
||||
'pbnumbers': Lotto.get_ans(Lotto.files[0]),
|
||||
'mmnumbers': Lotto.get_ans(Lotto.files[1]),
|
||||
'lanumbers': Lotto.get_ans(Lotto.files[2]),
|
||||
@@ -36,8 +38,17 @@ def home(request):
|
||||
|
||||
@cache_page(CACHE_TTL)
|
||||
def about(request):
|
||||
form = SubscribersForm(request.POST)
|
||||
if request.method == 'POST':
|
||||
form = SubscribersForm(request.POST)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
messages.success(request, 'Subscribed successfully')
|
||||
return redirect('/about')
|
||||
else:
|
||||
form = SubscribersForm()
|
||||
return render(request, 'about.html',
|
||||
{'nbar': 'about', 'title': 'About'})
|
||||
{'nbar': 'about', 'title': 'About', 'form': form})
|
||||
|
||||
@cache_page(CACHE_TTL)
|
||||
@require_GET
|
||||
|
||||
Reference in new issue
Block a user