Ejemplo n.º 1
0
 def new_context_processor():
     
     # this sucks because there is not a way (that i know of) to 
     # dynamically register data/messages; and saving the message
     # into a text file is the same as saving it here. As far as I 
     # can tell, there is no permanent storage available to 
     # blueprints (yes, exactly, this is the argument in the discussion
     # between Django and Flask)
     msg = ''
     cat = 'html'
     if msg and not is_message_dismissed(msg, cat):
         
         set_global_messages(
             """
             $(document).ready(function() {
                   $('div#globalmsg').find('button.close').click(
                  function(){
                     $.get('./buggyme/',{msg: $(this).parent().find('span').html(), });
                  });
             });""", 'javascript');
             
         safe_to_add = True
         # this results in messages be displayed every other request:
         #for existing_category, existing_msg in get_flashed_messages(with_categories=True):
         #    if existing_msg == msg:
         #         safe_to_add = False
         #         break
         if safe_to_add:
             #flash(msg, cat)
             set_global_messages(msg, cat)
         
         
     return {}
Ejemplo n.º 2
0
    def new_context_processor():

        # this sucks because there is now way (that i know off) to
        # dynamically register data/messages; and saving the message
        # into a text file is the same as saving it here. As far as I
        # can tell, there is no permanent storage available to
        # blueprints (yes, exactly, this is the argument in the discussion
        # between Django and Flask)
        msg = 'ADS is looking for a new web developer to make this site even better! <a href="http://careers.stackoverflow.com/jobs/42394/software-developer-it-specialist-smithsonian-astrophysical" target="_blank">Help us spread the news!</a>'
        cat = "html"
        if not is_message_dismissed(msg, cat):

            set_global_messages(
                """
                $(document).ready(function() {
                      $('div#globalmsg').find('button.close').click(
                     function(){
                        $.get('./buggyme/',{msg: $(this).parent().find('span').html(), });
                     });
                });""",
                "javascript",
            )

            safe_to_add = True
            # this results in messages be displayed every other request:
            # for existing_category, existing_msg in get_flashed_messages(with_categories=True):
            #    if existing_msg == msg:
            #         safe_to_add = False
            #         break
            if safe_to_add:
                # flash(msg, cat)
                set_global_messages(msg, cat)

        return {}
Ejemplo n.º 3
0
 def new_context_processor():
     
     # this sucks because there is not a way (that i know of) to 
     # dynamically register data/messages; and saving the message
     # into a text file is the same as saving it here. As far as I 
     # can tell, there is no permanent storage available to 
     # blueprints (yes, exactly, this is the argument in the discussion
     # between Django and Flask)
     msg = 'Want to change your affiliation? The ADS has a developer position open. <a href="https://careers.stackoverflow.com/jobs/65250/it-specialist-application-software-smithsonian-astrophysical?a=5iAe6hJ9D2" target="_blank">Apply! Spread the word!</a>'
     cat = 'html'
     if msg and not is_message_dismissed(msg, cat):
         
         set_global_messages(
             """
             $(document).ready(function() {
                   $('div#globalmsg').find('button.close').click(
                  function(){
                     $.get('./buggyme/',{msg: $(this).parent().find('span').html(), });
                  });
             });""", 'javascript');
             
         safe_to_add = True
         # this results in messages be displayed every other request:
         #for existing_category, existing_msg in get_flashed_messages(with_categories=True):
         #    if existing_msg == msg:
         #         safe_to_add = False
         #         break
         if safe_to_add:
             #flash(msg, cat)
             set_global_messages(msg, cat)
         
         
     return {}