def handle(self, *args, **options):
        directory = os.path.join(settings.MEDIA_ROOT, 'sitemaps')
        if not os.path.exists(directory):
            os.mkdir(directory)

        # make fake request
        r = HttpRequest()

        # do the sitemap index
        response = index(r, sitemaps)
        f = open(os.path.join(directory, 'sitemap.xml'), 'w')
        f.write(response.content)
        f.close()

        # do all of the individual sitemaps
        maps = re.findall(r'<loc>(.*?)</loc>', response.content)
        for map in maps:
            url = urlparse.urlparse(map)
            r.GET = dict(urlparse.parse_qsl(url.query))
            section = url.path.split("-").pop().split(".").pop(0)

            filename = os.path.join(directory, url.path[1:])
            if ('p' in r.GET):
                filename += "_p_%s" % r.GET['p']

            response = sitemap(r, sitemaps, section)
            f = open(filename, 'w')
            f.write(response.content)
            f.close()
Exemple #2
0
 def handle(self, *args, **options):
     directory = os.path.join(settings.MEDIA_ROOT, 'sitemaps')
     if not os.path.exists(directory):
         os.mkdir(directory)
     
     # make fake request
     r = HttpRequest()
     
     # do the sitemap index
     response = index(r, sitemaps)
     f = open(os.path.join(directory, 'sitemap.xml'), 'w')
     f.write(response.content)
     f.close()
     
     # do all of the individual sitemaps
     maps = re.findall(r'<loc>(.*?)</loc>', response.content)
     for map in maps:
         url = urlparse.urlparse(map)
         r.GET = dict(urlparse.parse_qsl(url.query))
         section = url.path.split("-").pop().split(".").pop(0)
         
         filename = os.path.join(directory, url.path[1:])
         if ('p' in r.GET):
             filename += "_p_%s" % r.GET['p']
         
         response = sitemap(r, sitemaps, section)
         f = open(filename, 'w')
         f.write(response.content)
         f.close()
Exemple #3
0
 def sitemap_index(
     self,
     request,
     node=None,
     competition=None,
     season=None,
     division=None,
     *args,
     **kwargs,
 ):
     # We need to "pop" the node keyword argument
     return sitemaps_views.index(request, *args, **kwargs)
Exemple #4
0
def enroll(request):
    # get the context from the request
    """context = RequestContext(request)"""

    if request.method == 'POST':
        form = EnrollmentForm(request.POST)

        # is the form valid
        if form.is_valid():

            # save  the new category to the database
            form.save(commit=True)

            # Now call the index() view.The user will be shown the homepage.
            return index(request)
        else:
            print('error form invalid')
    # If the request was not a POST, display the form to enter details.
    else:
        form = EnrollmentForm
    return render(request, 'enrollment.html', {'form': form})
Exemple #5
0
def subdomain_index(request, username, sitemaps):
    return index(request, sitemaps)
def index_wrapper(request, sitemaps):
    path = os.path.join(settings.MEDIA_ROOT, "sitemaps", "sitemap.xml")
    if os.path.exists(path):
        return HttpResponse(open(path), mimetype='application/xml')
    else:
        return index(request, sitemaps)
Exemple #7
0
def index(request, sitemaps, **kwargs):
    sitemaps = prepare_sitemaps(request, sitemaps)
    return sitemap_views.index(request, sitemaps, **kwargs)
Exemple #8
0
def subdomain_index(request, username, sitemaps):
    return index(request, sitemaps)
Exemple #9
0
def sitemap_index_view(request):
    return views.index(request, sitemaps)
Exemple #10
0
def index(request, sitemaps, **kwargs):
    sitemaps = prepare_sitemaps(request, sitemaps)
    return sitemap_views.index(request, sitemaps, **kwargs)
Exemple #11
0
def index_wrapper(request, sitemaps):
    path = os.path.join(settings.MEDIA_ROOT, "sitemaps", "sitemap.xml")
    if os.path.exists(path):
        return HttpResponse(open(path), mimetype='application/xml')
    else:
        return index(request, sitemaps)