In the context of the /ad route, should the participant be shown
    the thanks.html page instead of ad.html?
12831
def should_show_thanks_page_to(participant):
    
    if participant is None:
        return False
    status = participant.status
    marked_done = participant.end_time is not None
    ready_for_external_submission = (
        status in ("overrecruited", "working") and marked_done
    )
    assignment_complete = status in ("submitted", "approved")

    return assignment_complete or ready_for_external_submission
605773
function compareUrlRoute(currentURL, currentRoute) {
                var regex = /\{(.*)\}/i;
                var arraySize = currentRoute.length,
                    testValue = false;
                for (var i = 0; i < arraySize; i++) {
                    var dynamic = regex.exec(currentRoute[i]);
                    if (dynamic) {
                        document.routeParams[dynamic[1]] = currentURL[i];
                    } else {
                        if (currentRoute[i] === currentURL[i]) {
                            testValue = true;
                        }
                    }
                }

                return testValue;
            }
423642
def page(self, course):
        
        if not self.webdav_host:
            raise web.notfound()

        url = self.webdav_host + "/" + course.get_id()
        username = self.user_manager.session_username()
        apikey = self.user_manager.session_api_key()
        return self.template_helper.get_renderer().course_admin.webdav(course, url, username, apikey)
1061730
function msg_followers_thanks(){
	
	//move cursor
	_current_index++;

	//if there is no followers OR finished messaging followers stop
	if(_current_index >= _followers_list.length  ){
		_current_index = -1;
		_followe_list = null;
		return;
	}
		//otherwise get user name from twitter 
		twit_cli.get("users/show",{screen_name:_followers_list[_current_index]}, function (err,dt){
			
			//clean up the name
			var dude = filter_name(dt.name);
           		
			//message the user
			 twit_cli.post("direct_messages/new" , {screen_name:_followers_list[_current_index],text:random_msg(dude)}, function (err,dt){
					if(!err) console.log("done...");

					//go for another round
				 	msg_followers_thanks();
			});
           
		});

}
226353
def _RedirectToRemoteHelp(self, path):
    """"""
    allowed_chars = set(string.ascii_letters + string.digits + "._-/")
    if not set(path) <= allowed_chars:
      raise RuntimeError("Unusual chars in path %r - "
                         "possible exploit attempt." % path)

    target_path = os.path.join(config.CONFIG["AdminUI.docs_location"], path)

    # We have to redirect via JavaScript to have access to and to preserve the
    # URL hash. We don't know the hash part of the url on the server.
    return werkzeug_wrappers.Response(
        """
<script>
var friendly_hash = window.location.hash;
window.location = '%s' + friendly_hash;
</script>
""" % target_path,
        mimetype="text/html")
963426
def cookie_accepted

      # Get the visitor's current page URL or, if nil?,  default to the application root. Resue block needed for bots
      visitor_current_url = begin
        cookies.signed[CookieAlert.config.cookie_name.to_sym].split(CookieAlert.config.cookie_value_text_separator)[1]
      rescue
        main_app.root_path
      end

      # Set the Cookie value to 'accepted'
      if CookieAlert.config.cookie_type == 'permanent'
 
        # Set a permanent cookie
        cookies.permanent.signed[CookieAlert.config.cookie_name.to_sym] = 'accepted'
 
      elsif CookieAlert.config.cookie_type == 'fixed_duration'
 
        # Set a fixed duration cookie
        cookies.permanent.signed[CookieAlert.config.cookie_name.to_sym] = { value: 'accepted', expires: CookieAlert.config.num_days_until_cookie_expires.days.from_now }
 
      else
 
        # Set a session cookie
        cookies.signed[CookieAlert.config.cookie_name.to_sym] = 'accepted'
 
      end
      
      # If the request is HTML then redirect the visitor back to their original page
      # If the request is javascript then render the javascript partial
      respond_to do |format|

        format.html { redirect_to(visitor_current_url) }
        format.js { render template: "cookie_alert/cookies/cookie_accepted" }

      end
  
    end
1345854
def as_html(self, path=""):
        
        if path not in self.top_level_links:
            raise StateError("Unknown path")

        header = """
        <html>
            <head>
                <title>VPC-router state</title>
            </head>
            <body>
                <h3>VPC-router state</h3>
                <hr>
                <font face="courier">
        """

        footer = """
                </font>
            </body>
        </html>
        """

        rep = self.get_state_repr(path)

        def make_links(rep):
            # Recursively create clickable links for _href elements
            for e, v in rep.items():
                if e == "_href":
                    v = '<a href=%s>%s</a>' % (v, v)
                    rep[e] = v
                else:
                    if type(v) == dict:
                        make_links(v)

        make_links(rep)

        rep_str_lines = json.dumps(rep, indent=4).split("\n")
        buf = []
        for l in rep_str_lines:
            # Replace leading spaces with '&nbsp;'
            num_spaces = len(l) - len(l.lstrip())
            l = "&nbsp;" * num_spaces + l[num_spaces:]
            buf.append(l)

        return "%s%s%s" % (header, "<br>\n".join(buf), footer)
604360
function ( appRequest, appResponse ) {
    var cacheHtml = null,
        cacheJson = null,
        cacheName = null,
        slugged = slug( appRequest.params[ 0 ].replace( /\//g, "-" ).replace( /-$/g, "" ) ),
        reqSlug = ( slugged === "" ) ? "-homepage" : slugged,
        url = appRequest.params[ 0 ],
        qrs = {};

    cacheName = ("page" + reqSlug);

    // Querystring?
    for ( var i in appRequest.query ) {
        qrs[ i ] = appRequest.query[ i ];

        // Unique cache file name including queries
        if ( i !== "format" && i !== "password" && i !== "nocache" ) {
            cacheName += ("-" + i + "--" + qrs[ i ]);
        }
    }

    cacheHtml = sqsCache.get( (cacheName + ".html") );
    cacheJson = sqsCache.get( (cacheName + ".json") );

    // 404 JSON?
    if ( cacheJson && !pageNotFoundJson ) {
        setPageNotFoundJson( cacheJson );
    }

    // Nocache?
    if ( appRequest.query.nocache !== undefined ) {
        cacheJson = null;
        cacheHtml = null;

        sqsCache.remove( (cacheName + ".html") );
        sqsCache.remove( (cacheName + ".json") );
        sqsCache.remove( (cacheName + "-main-content.html") );
    }

    // Search?
    if ( slugged === "search" ) {
        if ( cacheHtml ) {
            appResponse.status( 200 ).send( cacheHtml );

        } else {
            sqsWare.getHtml( url, qrs, function ( error, data ) {
                if ( !error ) {
                    appResponse.status( 200 ).send( data.html );

                    sqsCache.set( (cacheName + ".html"), data.html );

                } else {
                    // Handle errors
                    nsl.log( "error", ("Error requesting system search page => " + error) );
                }
            });
        }

        return;
    }

    // Cache?
    if ( cacheJson && cacheHtml && !rJson.test( appRequest.query.format ) ) {
        sqsTemplate.renderTemplate( qrs, cacheJson, cacheHtml, function ( tpl ) {
            appResponse.status( 200 ).send( tpl );
        });

        return;
    }

    // JSON?
    // Supports `json` and `json-pretty`
    if ( rJson.test( appRequest.query.format ) ) {
        if ( cacheJson ) {
            cacheJson.nodeServer = true;

            appResponse.status( 200 ).json( cacheJson );

        } else {
            sqsWare.getJson( url, qrs, function ( error, json ) {
                if ( !error ) {
                    json.json.nodeServer = true;

                    sqsCache.set( (cacheName + ".json"), json.json );

                    appResponse.status( 200 ).json( json.json );

                } else {
                    // Handle errors
                    nsl.log( "error", ("Error requesting page json => " + error) );
                }
            });
        }

    // Main-Content
    } else if ( appRequest.query.format === "main-content" ) {
        cacheHtml = sqsCache.get( (cacheName + "-main-content.html") );

        if ( cacheHtml ) {
            appResponse.status( 200 ).send( cacheHtml );

        } else {
            sqsWare.getHtml( url, qrs, function ( error, data ) {
                if ( !error ) {
                    appResponse.status( 200 ).send( data.html );

                    sqsCache.set( (cacheName + "-main-content.html"), data.html );

                } else {
                    // Handle errors
                    nsl.log( "error", ("Error requesting main-content for page => " + error) );
                }
            });
        }

    // Request page?
    } else {
        sqsWare.getJsonAndHtml( url, qrs, function ( error, data ) {
            if ( !error ) {
                sqsCache.set( (cacheName + ".json"), data.json.json );
                sqsCache.set( (cacheName + ".html"), data.html.html );

                // 404 JSON?
                if ( !pageNotFoundJson ) {
                    setPageNotFoundJson( data.json.json );
                }

                sqsTemplate.renderTemplate( qrs, data.json.json, sqsCache.get( (cacheName + ".html") ), function ( tpl ) {
                    appResponse.status( 200 ).send( tpl );
                });

            } else {
                // Handle errors
                nsl.log( "error", ("Error requesting page => " + error) );

                // Could be a 404 though so serve it
                if ( data.html.status === 404 || data.json.status === 404 ) {
                    //appResponse.status( 200 ).send( data.html.html );
                    sqsTemplate.renderTemplate( qrs, pageNotFoundJson, data.html.html, function ( tpl ) {
                        appResponse.status( 404 ).send( tpl );
                    });

                    nsl.log( "warn", ("Request responded with server code 404 for => `" + url + "`") );

                    return;
                }
            }
        });
    }
}
759240
function preBottom(ctx, goToBottomMiddleware) {
      // If no route match or no methods are defined, go to next middleware
      if (node.isGag || !node.methods.size) {
        return next()
      }
      // If there is no one middleware
      // it's a 405 error
      if (!bottom.length) {
        ctx.response.set('Allow', this.methods.toString())
        ctx.response.status = 405
        return
      }

      return goToBottomMiddleware()
    }
581548
private boolean handleRedirect(
            DnsQuestion question, AddressedEnvelope<DnsResponse, InetSocketAddress> envelope,
            final DnsQueryLifecycleObserver queryLifecycleObserver, Promise<List<T>> promise) {
        final DnsResponse res = envelope.content();

        // Check if we have answers, if not this may be an non authority NS and so redirects must be handled.
        if (res.count(DnsSection.ANSWER) == 0) {
            AuthoritativeNameServerList serverNames = extractAuthoritativeNameServers(question.name(), res);
            if (serverNames != null) {
                int additionalCount = res.count(DnsSection.ADDITIONAL);

                AuthoritativeDnsServerCache authoritativeDnsServerCache = authoritativeDnsServerCache();
                for (int i = 0; i < additionalCount; i++) {
                    final DnsRecord r = res.recordAt(DnsSection.ADDITIONAL, i);

                    if (r.type() == DnsRecordType.A && !parent.supportsARecords() ||
                        r.type() == DnsRecordType.AAAA && !parent.supportsAAAARecords()) {
                        continue;
                    }

                    // We may have multiple ADDITIONAL entries for the same nameserver name. For example one AAAA and
                    // one A record.
                    serverNames.handleWithAdditional(parent, r, authoritativeDnsServerCache);
                }

                // Process all unresolved nameservers as well.
                serverNames.handleWithoutAdditionals(parent, resolveCache(), authoritativeDnsServerCache);

                List<InetSocketAddress> addresses = serverNames.addressList();

                // Give the user the chance to sort or filter the used servers for the query.
                DnsServerAddressStream serverStream = parent.newRedirectDnsServerStream(
                        question.name(), addresses);

                if (serverStream != null) {
                    query(serverStream, 0, question,
                          queryLifecycleObserver.queryRedirected(new DnsAddressStreamList(serverStream)),
                          true, promise, null);
                    return true;
                }
            }
        }
        return false;
    }
986380
def present(profile='pagerduty', subdomain=None, api_key=None, **kwargs):
    '''
    
    '''
    return __salt__['pagerduty_util.resource_present']('users',
                                                       ['email', 'name', 'id'],
                                                       None,
                                                       profile,
                                                       subdomain,
                                                       api_key,
                                                       **kwargs)
455809
def routingAreaUpdateRequest(PTmsiSignature_presence=0,
                             GprsTimer_presence=0,
                             DrxParameter_presence=0,
                             TmsiStatus_presence=0):
    """"""
    a = TpPd(pd=0x3)
    b = MessageType(mesType=0x8)  # 00001000
    c = UpdateTypeAndCiphKeySeqNr()
    e = RoutingAreaIdentification()
    f = MsNetworkCapability()
    packet = a / b / c / e / f
    if PTmsiSignature_presence is 1:
        g = PTmsiSignature(ieiPTS=0x19)
        packet = packet / g
    if GprsTimer_presence is 1:
        h = GprsTimer(ieiGT=0x17)
        packet = packet / h
    if DrxParameter_presence is 1:
        i = DrxParameter(ieiDP=0x27)
        packet = packet / i
    if TmsiStatus_presence is 1:
        j = TmsiStatus(ieiTS=0x9)
        packet = packet / j
    return packet
444424
def join_event_view(request, id):
    

    event = get_object_or_404(Event, id=id)

    if request.method == "POST":
        if not event.show_attending:
            return redirect("events")
        if "attending" in request.POST:
            attending = request.POST.get("attending")
            attending = (attending == "true")

            if attending:
                event.attending.add(request.user)
            else:
                event.attending.remove(request.user)

            return redirect("events")

    context = {"event": event, "is_events_admin": request.user.has_admin_permission('events')}
    return render(request, "events/join_event.html", context)
664233
def should_be_visited?(url, with_tracker = true)
      case
      # robots.txt
      when !allowed_by_robot?(url)
        false
      # Check against whitelist pattern matching
      when !@follow_links_like.empty? && @follow_links_like.none? { |p| url.path =~ p }
        false
      # Check against blacklist pattern matching
      when @skip_links_like.any? { |p| url.path =~ p }
        false
      # Page is marked as expired
      when page_expired?(Page.new(url))
        true
      # Check against url tracker
      when with_tracker && url_tracker.visited?(@options[:include_query_string_in_saved_page] ? url.to_s : url.to_s.gsub(/\?.*$/, ''))
        false
      else
        true
      end
    end
309535
def slug(request, url):
    """"""
    page = None

    if url:
        for slug in url.split('/'):
            if not slug:
                continue
            try:
                page = Page.objects.get(slug=slug, parent=page)
            except Page.DoesNotExist:
                raise Http404
    else:
        try:
            page = Page.objects.get(slug='index', parent=None)
        except Page.DoesNotExist:
            return TemplateView.as_view(
                template_name='wafer/index.html')(request)

    if 'edit' in request.GET:
        if not request.user.has_perm('pages.change_page'):
            raise PermissionDenied
        return EditPage.as_view()(request, pk=page.id)

    if 'compare' in request.GET:
        if not request.user.has_perm('pages.change_page'):
            raise PermissionDenied
        return ComparePage.as_view()(request, pk=page.id)

    return ShowPage.as_view()(request, pk=page.id)
319969
def get_ad_url(self, ad_id, sandbox):
        
        if sandbox:
            return self.sandbox_ad_server + '/view/' + str(ad_id)
        else:
            return self.ad_server + '/view/' + str(ad_id)
51874
def __response_url(self, message_id):
        
        if self.from_.pid != 0:
            path = AGENT_RESPONSE_PATH % (self.from_.pid, message_id)

        return "http://%s:%s/%s" % (self.host, self.port, path)