Exemple #1
0
def toolbar_done(flowgram, creater):
    subject = "A link to your Flowgram \"" + flowgram.title + "\""
    embed_code_array = ['<object width="400" height="300"><param name="movie" value="',
                URL_BASE, 
                'widget/flexwidget.swf?id=',
                str(flowgram.id),
                '&hasLinks=',
                'false',
                '"><param name="flashVars" value="id=',
                str(flowgram.id),
                '"><param name="allowScriptAccess" value="always"><param name="allowNetworking" value="all"><embed src="',
                URL_BASE, 
                'widget/flexwidget.swf?id=',
                str(flowgram.id),
                '&hasLinks=',
                'false',
                '" width="400" height="300" FlashVars="id=',
                str(flowgram.id),
                '" allowScriptAccess="always" allowNetworking="all"></embed></object>']
    
    embed_code = "".join(embed_code_array)
    t = loader.get_template('emails/toolbar_done.html')
    c = Context({
        'recipient': creater.username,
        'flowgram_url': URL_BASE + 'p/' + str(flowgram.id),
        'embed_code': embed_code,
        'edit_link': URL_BASE + 'fg/' + str(flowgram.id),
        'contact_us': URL_BASE + 'about_us/contact_us/',
    })
    html = t.render(c)
    try:
        email_user_html(creater, subject, html, '*****@*****.**')
    except:
        log.error("toobar_done failed to email creater " + creater.username)
Exemple #2
0
    def process_request(self, request):
        if excluded(request):
            return None
        
        session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)

        session_key = request.POST.get(settings.SESSION_COOKIE_NAME, session_key)
        session_key = request.GET.get(settings.SESSION_COOKIE_NAME, session_key)
                
        if session_key != None:
            request.COOKIES[settings.SESSION_COOKIE_NAME] = session_key
        
        request_csrf_token = request.POST.get('csrfmiddlewaretoken', None)
        if request_csrf_token == None:
            request_csrf_token = request.GET.get('csrfmiddlewaretoken', None)
            
            if request_csrf_token != None:
                request.POST['csrfmiddlewaretoken'] = request_csrf_token
        
        response = super(CustomCsrfMiddleware, self).process_request(request)
        if response:
            log.error("403 error on " + request.path)
            r = render_to_response('500.html')
            r.status_code = 500
            return r
Exemple #3
0
def post_queue_add_page(request, addpagerequest_id, html, url):
    """Called by the server-side renderer to finish adding a page."""

    addPageRequest = models.AddPageRequest.objects.get(id=addpagerequest_id)

    # If this page was already completed, don't add it again -- there's a possibility that multiple
    # threads are working on the same page at once.
    if addPageRequest.status_code == models.StatusCode.DONE:
        log.error("Multiple threads processed APR %s" % addPageRequest.id)
        return

    flowgram = addPageRequest.flowgram
    user = flowgram.owner
    title = helpers.get_title(request)

    # Modify the HTML to add base tag etc.
    (html, url) = fix.process_page(html, url)
        
    # Create and save the page:
    page = addPageRequest.page
    page.title = title
    page.save()
    html = helpers.cache_css_files(page, html)
    page = controller.create_page_to_flowgram(flowgram, page, html, do_make_thumbnail=False,
                                                  set_position=False)
    
    # Updating the status code and page
    addPageRequest.status_code = models.StatusCode.DONE
    
    controller.set_page_hl_contents(page, html)
    
    addPageRequest.save()
        
    log.action('post_queue_add_page %s to %s for %s' % (page.id, flowgram.id, user.username))
Exemple #4
0
 def publish(self, public):
     if self.published:
         log.error("Tried publish already-published flowgram %s" % (self.id))
     self.published = True
     self.public = public
     if public:
         self.published_at = datetime.now()
     self.save()
Exemple #5
0
def announce_feedback(feedback):
    sender = DEFAULT_SENDER
    recipients = [FEEDBACK_RECIPIENT]
    subject = ""
    text = "URL: %s\nEmail: %s\nSystem info:\n%s\nComments: %s\n" % (feedback.url, feedback.email, feedback.sys_info, feedback.comments)
    try:
        log.debug("send_mail from announce_feedback to " + FEEDBACK_RECIPIENT)
        for recipient in recipients:
            add_to_mail_queue(sender, recipient, subject, text)
    except:
        log.error("Failure in announce_feedback:")
        log.trace()
Exemple #6
0
def announce_flag(request, flowgram):
    flagger = request.user.username or request.META['REMOTE_ADDR']
    subect = "%s FLAGGED by %s" % (flowgram.title, flagger)
    sender = DEFAULT_SENDER
    text = "See the flagged flowgram at %s" % flowgram.url()
    recipients = ['*****@*****.**']
    try:
        log.debug("send_mail from announce_flag to " + '*****@*****.**')
        for recipient in recipients:
            add_to_mail_queue(sender, recipient, subject, text)
    except:
        log.error("Failure in announce_flag:")
        log.trace()
Exemple #7
0
def welcome_user(user):
    subject = "Welcome to Flowgram.com!"
    t = loader.get_template('emails/welcome_user.txt')
    c = Context({
        'recipient' : user,
        'homepage_url' : URL_BASE,
        'make_url': URL_BASE + 'create/',
        'browse_url': URL_BASE + 'browse/featured/',
        'profile_url': URL_BASE + str(user),
    })
    text = t.render(c)
    try:
        email_user(user, subject, text)
    except:
        log.error("welcome_user failed to email user " + user.username)
Exemple #8
0
def announce_new_flowgram(flowgram):
    creator = flowgram.owner
    url = flowgram.full_url()
    log.debug("announce_new_flowgram")    
    for profile in creator.subscribers.all():
        subject = "%s (Flowgram.com)" % (flowgram)
        text = "%s's latest Flowgram was published to the web at %s." % (creator, url)
        try:
            email_user(profile.user, subject, text)
        except:
            log.error("announce_feed_message failed to email user " + profile.username)
    if creator.get_profile().subscribed_to_self:
        subject = "\"%s\" -- your latest Flowgram has been posted!" % (flowgram.title)
        text = "Your latest Flowgram, %s, was published to the web at %s." %(flowgram.title, url)
        try:
            email_user(creator, subject, text)
        except:
            log.error("announce_feed_message failed to email user " + profile.username)
Exemple #9
0
def announce_new_comment(comment):
    flowgram = comment.flowgram
    url = flowgram.full_url()
    subscribers = []#list(flowgram.subscribers.all())
    p = flowgram.owner.get_profile()
    if p.subscribed_to_own_fgs:
        subscribers.append(p)
    
    # new code in this block -- chris
    # for profile in subscribers:
    #         if profile == comment.owner:
    #             continue
    #         subject = "%s has a new comment (Flowgram.com)" % (flowgram)
    #         text = "The user \"%s\" added a comment to %s. Check it out at %s" % (comment.owner, flowgram.title, url)
    #         try:
    #             if profile == flowgram.owner and profile.user.get_profile().subscribed_to_own_fgs == True:
    #                 email_user(profile.user, subject, text)
    #             elif profile.user.get_profile().subscribe_fg_on_comment == True:
    #                 email_user(profile.user, subject, text)
    #         except:
    #             log.error("announce_new_comment failed to email user " + profile.user.username)
    
    # original code in this block -- chris        
    # for profile in subscribers:
    #         if profile == comment.owner:
    #             continue
    #         subject = "%s has a new comment (Flowgram.com)" % (flowgram)
    #         text = "The user \"%s\" added a comment to %s. Check it out at %s" % (comment.owner, flowgram.title, url)
    #         try:
    #             email_user(profile.user, subject, text)
    #         except:
    #             log.error("announce_new_comment failed to email user " + profile.user.username)        
    
    # this is sending an email to everyone who comments on any flowgram, but there is currently no opt-out which is highly irritating.  for now i am setting it to only email the flowgram owner, below is the fix -- chris 07/07/08
    # david has turned off flowgram_subscriptions in models.py because it was breaking the admin view.  However, this will now break any of the above code.  we will need to find another way to send emails to users who comment on Flowgrams they do not own. -- chris 07/08/08
    subject = "%s has a new comment (Flowgram.com)" % (flowgram)
    text = "The user \"%s\" added a comment to %s. Check it out at %s" % (comment.owner, flowgram.title, url)
    try:
        email_user(flowgram.owner, subject, text)
    except:
        log.error("announce_new_comment failed to email user " + flowgram.owner.username)
Exemple #10
0
def log_error(request, error_message):
    log.error('[web] ' + error_message, request)