Permalink
Browse files

Email lengths and 404 page support

* Correction to email lengths
* Adds 404 page support
* SES Error handling in digest mailer
  • Loading branch information...
1 parent 4424988 commit 41b91be393df0a173f4dd8b11a954bfd4393a8d2 @cybertoast cybertoast committed Jul 29, 2011
View
@@ -580,7 +580,7 @@ def approveProjectResource(self):
mMessaging.emailResourceApproval(resource.data.contact_email, resource.data.title)
- if (resource.data.owner_email):
+ if (resource.data.owner_email and resource.data.owner_email != resource.data.contact_email):
mMessaging.emailResourceApproval(resource.data.owner_email, resource.data.title)
return True
else:
@@ -620,4 +620,4 @@ def getBadwords(self):
log.error(e)
return words
-
+
@@ -92,11 +92,21 @@ def __init__(self, *a, **kwargs):
def __getattr__(self, name):
# Assuming all templates end with .html
path = name + '.html'
- t = self._lookup.get_template(path)
+ try:
+ t = self._lookup.get_template(path)
+ except Exception, e:
+ path = '404.html'
+ t = self._lookup.get_template(path)
+
return t.render
def __getitem__(self, name): # bh added
- t = self._lookup.get_template(name)
+ try:
+ t = self._lookup.get_template(name)
+ except:
+ name = '404.html'
+ t = self._lookup.get_template(name)
+
return t.render
class render_mako:
View
@@ -24,6 +24,7 @@
from datetime import datetime
from dateutil.relativedelta import relativedelta
from optparse import OptionParser, IndentedHelpFormatter # for command-line menu
+import time # for sleeping
# Assuming we start in the scripts folder, we need
# to traverse up for everything in our project
@@ -118,13 +119,22 @@ def htmlify(self, body):
return "<html><head></head><body>%s</body></html>" % body
def sendEmail(self, to=None, recipients=None, subject=None, body=None):
- return Emailer.send(addresses=to,
- subject=subject,
- text=body,
- html=self.htmlify(body),
- from_name = self.MailerSettings.get('FromName'),
- from_address = self.MailerSettings.get('FromEmail'),
- bcc=recipients)
+ complete = False
+ while not complete:
+ try:
+ retval = Emailer.send(addresses=to,
+ subject=subject,
+ text=body,
+ html=self.htmlify(body),
+ from_name = self.MailerSettings.get('FromName'),
+ from_address = self.MailerSettings.get('FromEmail'),
+ bcc=recipients)
+ complete = True
+ except:
+ # Most probably we got an SES error, which means we should wait and retry
+ time.sleep(1)
+ pass
+
class Configurable():
@@ -698,4 +708,4 @@ def main():
web.webapi.config.debug = True
main()
- exit(0)
+ exit(0)
@@ -819,6 +819,7 @@ table.resources-list td a.close { display: block; position: absolute; top: 10px;
table.resources-list .resource-name { /*width: 120px; float: left;*/ margin-left: 48px; margin-right: 68px; font: 15px/19px "ff-meta-serif-web-pro-1","ff-meta-serif-web-pro-2", Georgia, Times, Times New Roman, serif; margin-top: -3px; font-weight: bold; word-wrap: break-word; }
table.resources-list .resource-name > span { display: table; vertical-align: middle; }
table.resources-list .resource-name > span span { display: table-cell; vertical-align: middle; height: 42px; }
+table.resources-list span.official-resource-alt,
table.resources-list .resource-name > span.official-resource-alt { padding:0 0 2px 30px; background-image: url("../images/nyc_small_green.png");
background-position: left top; color:#52b312; text-transform:uppercase; font-weight:bold !important; margin-bottom: 6px; display: block;
font: 9px/10px "ff-din-web-1","ff-din-web-2", "Franklin Gothic Medium", Helvetica, Arial, sans-serif; min-width: 90px; min-height: 9px;
View
@@ -48,7 +48,7 @@
inputs: {
email: {
selector: "#email-input",
- validators: ["min-3", "max-32", "email"],
+ validators: ["min-6", "max-254", "email"],
hint: (function() {
if (app.app_page.user && app.app_page.user.email) {
return false;
@@ -325,7 +325,7 @@
inputs: {
email: {
selector: "input.login-email",
- validators: ["min-3", "max-180", "email"]
+ validators: ["min-6", "max-254", "email"]
},
password: {
selector: "input.login-pass",
@@ -431,4 +431,4 @@
$(function() {
tc.app(app_page);
});
-}(this, this.jQuery));
+}(this, this.jQuery));
@@ -281,7 +281,7 @@ app_page.features.push(function(app){
},
email:{
selector:'input.email',
- validators:['min-3','max-64','email','required']
+ validators:['min-6','max-254','email','required']
},
password:{
selector:'input.password',
@@ -399,4 +399,4 @@ app_page.features.push(function(app){
tc.jQ('.adminbar li.admin-settings').addClass('active');
-});
+});
@@ -28,12 +28,12 @@ app_page.features.push(function(app){
},
name:{
selector:'input.name',
- validators:['min-3,max-32','required'],
+ validators:['min-3,max-100','required'],
hint:''
},
email:{
selector:'input.email',
- validators:['min-3','max-32','email','required'],
+ validators:['min-6','max-254','email','required'],
hint:''
},
text:{
@@ -90,4 +90,4 @@ app_page.features.push(function(app){
placeholder: '.feedback-type'
});
});
-});
+});
View
@@ -71,7 +71,7 @@ app_page.features.push(function(app){
inputs:{
email:{
selector:'input.email',
- validators:['min-3','max-200','required','email'],
+ validators:['min-6','max-254','required','email'],
hint: (app_page.data.user && app_page.data.user.email ? false : 'Please enter your email address'),
focus_first:true
},
View
@@ -69,7 +69,7 @@ app_page.features.push(function(app){
},
email:{
selector:'input.email',
- validators:['max-128','min-3','email','required'],
+ validators:['max-254','min-6','email','required'],
hint:''
},
password:{
@@ -140,7 +140,7 @@ app_page.features.push(function(app){
},
email:{
selector:'input.email',
- validators:['max-32','min-3','email','required'],
+ validators:['max-254,'min-6','email','required'],
hint:''
},
tos_email:{
@@ -233,7 +233,7 @@ app_page.features.push(function(app){
inputs:{
email:{
selector:'input.email-alt',
- validators:['min-3','max-32','email'],
+ validators:['min-6','max-254','email'],
hint:''
},
tos_email:{
@@ -489,4 +489,4 @@ app_page.features.push(function(app){
}
}
});
-});
+});
@@ -144,7 +144,7 @@
inputs: {
email: {
selector: "input.email",
- validators: ["required", "min-3", "max-32", "email"]
+ validators: ["required", "min-6", "max-254", "email"]
}
},
init: function(merlin, dom) {
@@ -431,7 +431,7 @@
inputs: {
email: {
selector: "input.email",
- validators: ["required", "min-3", "max-180", "email"]
+ validators: ["required", "min-6", "max-254", "email"]
},
password: {
selector: "input.password",
@@ -495,7 +495,7 @@
inputs: {
email: {
selector: "input.email",
- validators: ["required", "min-3", "max-180", "email"]
+ validators: ["required", "min-6", "max-254", "email"]
}
},
init: function(merlin, dom) {
@@ -627,4 +627,4 @@
});
-}(this, this.jQuery));
+}(this, this.jQuery));
@@ -196,7 +196,4 @@ app_page.features.push(function(app){
// random note-card backgrounds
tc.randomNoteCardBg(tc.jQ('.ideas-invite .items'));
- // add 'official resource' tags to resources
- tc.addOfficialResourceTags(tc.jQ('.box.resources .organizations table.resources-list'));
-
- });
+ });
@@ -83,7 +83,7 @@ tc.gam.project_widgets.members = function(project,dom,deps,options){
inputs:{
email_list:{
selector:'.email-list',
- validators:['min-3','max-200','required','csv-email'],
+ validators:['min-6','max-254','required','csv-email'],
hint:'Add emails separated by commas'
},
email_message:{
@@ -215,4 +215,4 @@ tc.gam.project_widgets.members = function(project,dom,deps,options){
}
}
};
-};
+};
@@ -102,7 +102,7 @@ tc.gam.project_widgets.related_resources = function(project,dom,deps,options){
temp += '<img src="/static/images/thumb_genAvatar30.png" width="30" height="30" alt="" /></span>'
};
- temp += '<span class="resource-name" ><span>'+
+ temp += '<span class="resource-name" >' + (resource.is_official ? "<span class='official-resource-alt'>Official Resource</span>" : "") + '<span>'+
'<span class="organization-name tooltip_trigger" rel="#organization,'+ resource.link_id +'">'+
resource.title +
'</span></span></span>';
@@ -159,8 +159,6 @@ tc.gam.project_widgets.related_resources = function(project,dom,deps,options){
}
});
});
-
- tc.addOfficialResourceTags(tc.jQ('.related-resources .resources-list'));
}
function no_resources() {
@@ -103,6 +103,9 @@ tc.gam.project_widgets.resources = function(project,dom,deps,options){
}
temptd = tc.jQ('<td></td>').append(tc.jQ('.template-content.organization-table-cell').clone().children());
temptd.attr('title',d.resources[i].title);
+ if(d.resources[i].is_official == true){
+ temptd.find('.official-resource-alt').css('display','block');
+ }
if(d.resources[i].image_id){
temptd.find('img').attr('src',media_root+'images/'+(d.resources[i].image_id%10)+'/'+d.resources[i].image_id+'.png');
}
@@ -121,7 +124,6 @@ tc.gam.project_widgets.resources = function(project,dom,deps,options){
default:
return;
}
- tc.addOfficialResourceTags(e.data.me.elements.organizations_table);
},
remove_resource:function(e){
e.preventDefault();
@@ -193,4 +195,4 @@ tc.gam.project_widgets.resources = function(project,dom,deps,options){
show:widget.show,
hide:widget.hide
};
-};
+};
@@ -104,7 +104,7 @@ app_page.features.push(function(app){
},
contact:{
selector:'input.contact',
- validators:['min-3','max-50','required','email'],
+ validators:['min-6','max-254','required','email'],
hint:''
},
tos_agree:{
@@ -174,4 +174,4 @@ app_page.features.push(function(app){
}
});
-});
+});
@@ -14,7 +14,7 @@ app_page.features.push(function(app){
inputs:{
email:{
selector:'input.email',
- validators:['min-3','max-50','required','email'],
+ validators:['min-6','max-254','required','email'],
hint:'Your email address'
}
},
@@ -47,4 +47,4 @@ app_page.features.push(function(app){
}
}
});
-});
+});
View
@@ -16,5 +16,5 @@
{% block page_js %}
-<script type='text/javascript' src="/static/js/pages/project.add_link.js"></script>
-{% endblock page_js %}
+<script type='text/javascript' src="/static/js/pages/404.js"></script>
+{% endblock page_js %}
@@ -83,6 +83,7 @@
<tr>
{% endif %}
<td title="{{ org.title }}" {% if org.is_official %}class="official-resource"{% endif %}>
+ {% if org.is_official %}<span class="official-resource-alt">Official Resource</span>{% endif %}
<span class="thumb">
{% if d.template_data and d.template_data.project_user and d.template_data.project_user.data.is_project_admin or d.template_data and d.template_data.user and d.template_data.user.is_admin %}
<a class="close" href="#removeOrganization,{{ org.organization }}"><span>remove</span></a>
@@ -141,6 +142,7 @@
</div>
<div class='template-content organization-table-cell' title=''>
+ <span class="official-resource-alt" style="display:none">Official Resource</span>
<span class="thumb">
<a class="close" href="#removeOrganization,"></a>
<img width='30' src="/static/images/thumb_genAvatar30.png" alt=""/>

0 comments on commit 41b91be

Please sign in to comment.