Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
thesues committed Apr 26, 2011
2 parents 4f1a906 + 5499b0c commit 3f68425
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'zh-CN'
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

Expand Down
2 changes: 1 addition & 1 deletion smthtop10/bookTemplate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#coding:utf8
# coding=utf-8
bookTemplate = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
Expand Down
9 changes: 6 additions & 3 deletions smthtop10/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
from django import forms
from django.utils.translation import ugettext_lazy as _


#this is for registration
class UserRegsiterForm(RegistrationFormUniqueEmail):
kindlemail=forms.EmailField()
kindlemail=forms.EmailField(label=_("kindlemail"))
updatetime=forms.ChoiceField(choices=UPDATE_TIME,label=_("updatetime"))
def clean_kindlemail(self):
if UserProfile.objects.filter(kindlemail=self.cleaned_data['kindlemail']):
raise forms.ValidationError("This email address is already in use. Please supply a different email address.")
raise forms.ValidationError(_("This email address is already in use. Please supply a different email address."))
return self.cleaned_data['kindlemail']

class ProfileForm(forms.ModelForm):
class Meta:
model=UserProfile
exclude=["user"]



10 changes: 8 additions & 2 deletions smthtop10/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self,author="unknow",content="unknow",signature="unknown",reference
self.imagefilenameList=[]
def __str__(self):
return "%s:\n%s" % (self.author.encode("utf8"),self.content.encode("utf8"))

class Feed():
def __init__(self,title="unknown"):
self.list=list()
Expand All @@ -25,9 +25,15 @@ def append(self,post):
def __str__(self):
return self.title.encode("utf8")

class UserProfile(models.Model):
UPDATE_TIME=(
(7,"7:00 AM"),
(13,"13:00 AM"),
(19,"19:00 AM")
)
class UserProfile(models.Model):
kindlemail=models.EmailField(max_length=75)
user=models.ForeignKey(User,unique=True)
updateTime=models.IntegerField(choices=UPDATE_TIME)
def __unicode__(self):
return unicode(self.user.username)

Expand Down
1 change: 1 addition & 0 deletions smthtop10/regbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ def user_created(sender, user, request, **kwargs):
form = UserRegsiterForm(request.POST)
profile=UserProfile(user=user)
profile.kindlemail=form.data['kindlemail']
profile.updateTime=form.data['updateTime']
profile.save()
from registration.signals import user_registered
user_registered.connect(user_created)
5 changes: 4 additions & 1 deletion smthtop10/sendMail.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
from django.core.mail import *
from smthtop10.models import UserProfile
from datetime import date
from datetime import datetime
today=date.today()
hour=datetime.now().hour
archive="./archive/"+today.strftime("%Y%m%d")+"/"

#gernarater mobi files
Expand All @@ -17,7 +19,8 @@
print mobifile
if os.path.isfile(mobifile):
t=EmailMessage()
for i in UserProfile.objects.all():
for i in UserProfile.objects.filter(updateTime__iexact=hour):
t.to.append(i.kindlemail)
t.attach_file(mobifile)
t.send()

2 changes: 1 addition & 1 deletion smthtop10/shell/run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export DJANGO_SETTINGS_MODULE=newsmth.settings
python buildbook.py
python sendMail.py
python sendMail.py
8 changes: 0 additions & 8 deletions smthtop10/templates/registration/registration_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,3 @@ <h2>Register</h2>
</body>
</html>









0 comments on commit 3f68425

Please sign in to comment.