Пример #1
0
def index(request, pk):
    
    """bleh blebh bhel bleh, IM GOING INSANE.... I mean; user profile display stuff."""
    #I hate this vampire head ~alex
    """THE VAMPIRE HEAD FIXES ALL OF YOUR BROKEN CODE!!!, that is to say, as long as you never look at this code, it could be anything. We guarantee that whatever you imaging is better written then what actually is written."""

    # userdata is the user data who's page we are viewing.
    userdata=User.objects.filter(pk = pk).get()

    profile = userProfile.objects.filter(user=userdata)[0]

    projects=Project.objects.filter(author=userdata).order_by("-created") #'''~this needs to get the users projects.... not just you know, all the projects.... and now it does!''' YAY!  And now it gets no projects? wtf.. ok, so it is getting the list.. it is just not getting displayed...

    #  paginator is neat!
    # It takes the list of projects and breaks them up into different pages.
    # Kinda obvious huh?
    paginator = Paginator(projects, 3*3)

    try: page = int(request.GET.get("page", '1'))
    except ValueError: page = 1

    try:
        projects = paginator.page(page)
    except (InvalidPage, EmptyPage):
        projects = paginator.page(paginator.num_pages)

    listdata = project_list_get(projects)

    try:
        thumbpic = [profile.userpic.get_thumb(512,512)]
    except:
        thumbpic = False

    c = RequestContext(request, dict(thumbpic=thumbpic, user=request.user, owner=userdata, listdata = listdata))
    return render(request, "userProfile/index.html", c)
Пример #2
0
def draftview(RequestContext, scraperMessage=False):
    request = RequestContext
    projects = Project.objects.filter(author=int(request.user.id), draft=True)
    toomanydrafts = False

    github = githubAccount.objects.filter(user=request.user)
    accounts = {}
    #    for i in github:
    #        apicall = json.loads(urllib.urlopen("https://api.github.com/users/{user}/repos".format(user=i.gitUser)).read())
    #        accounts.update({item['id']: item for item in apicall})

    if projects.count() >= 8:
        toomanydrafts = True
    listdata = project_list_get(projects, purge=False)
    importForm = ImportForm()
    c = {
        "toomanydrafts": toomanydrafts,
        "listdata": listdata,
        "user": request.user,
        "active": "home",
        "importerForm": importForm,
        "scraperMessage": scraperMessage,
        "accounts": accounts,
    }
    c.update(csrf(request))
    return render_to_response("drafts.html", c)
Пример #3
0
def draftview(request):
   
    projects =Project.objects.filter(author=request.user, draft=True)
    paginator = Paginator(projects, 8)
    try: page = int(request.GET.get("page", '1'))
    except ValueError: page = 1

    try:
        #only get thumbnails for projects on the current page.
        listdata = project_list_get(paginator.page(page))
    except (InvalidPage, EmptyPage):
        listdata = paginator.page(paginator.num_pages)
    return render_to_response("front.html", dict(listdata=listdata, user=request.user, active="home"))
Пример #4
0
    def extra_context(self):
        projects = []
        for i in self.results:
            projects += [i.object]
        data = project_list_get(projects)

        ##I've heard tell of worse code. The big problem here is we don't know what variables we're going to have, and we don't just the content anyway.
        #Would probably be a lot cleaner if I threw in a fre try statements...
        ##Set up the sort options, and current
        sortoptions = list(objectSearchForm.sortOPTIONS)
        if self.request.GET.get("sort", False):
            success = False
            for i in objectSearchForm.sortOPTIONS:
                if i[0] == self.request.GET["sort"]:
                    ordersortCurrent = i
                    sortoptions.remove(i)
                    success = True
                    break
            if success == False:
                ordersortCurrent = objectSearchForm.sortOPTIONS[0]
                sortoptions.remove(objectSearchForm.sortOPTIONS[0])
        else:
            ordersortCurrent = objectSearchForm.sortOPTIONS[0]
            sortoptions.remove(objectSearchForm.sortOPTIONS[0])

        ##Set up the time options, and current
        timeoptions = list(objectSearchForm.timeOPTIONS)
        if self.request.GET.get("From", False):
            success = False
            for i in objectSearchForm.timeOPTIONS:
                if i[0] == self.request.GET["From"]:
                    timesortCurrent = i
                    timeoptions.remove(i)
                    success = True
                    break
            if success == False:
                timesortCurrent = objectSearchForm.timeOPTIONS[0]
                timeoptions.remove(objectSearchForm.timeOPTIONS[0])
        else:
            timesortCurrent = objectSearchForm.timeOPTIONS[0]
            timeoptions.remove(objectSearchForm.timeOPTIONS[0])

        clean_url_dict = self.request.GET.copy()
        try:
            del clean_url_dict["sort"]
        except:
            pass
        try:
            del clean_url_dict["From"]
        except:
            pass
        cleaned_url = clean_url_dict.urlencode()
        return {
            "cleaned_url": cleaned_url,
            'listdata': data,
            "ordersort": {
                "current": ordersortCurrent,
                "options": sortoptions
            },
            "fromtime": {
                "current": timesortCurrent,
                "options": timeoptions
            }
        }