|
4
|
1 |
from django.conf import settings |
|
|
2 |
from django.contrib.auth.models import User |
|
|
3 |
from django.contrib.auth.decorators import login_required |
|
|
4 |
from django.core.exceptions import ObjectDoesNotExist |
|
|
5 |
from django.core.paginator import Paginator, InvalidPage, EmptyPage |
|
|
6 |
from django.http import HttpResponseNotFound, HttpResponse |
|
|
7 |
from django.shortcuts import redirect |
|
|
8 |
from django.utils.decorators import method_decorator |
|
|
9 |
from django.views.generic.base import View, TemplateResponseMixin |
|
|
10 |
from ldt.ldt_utils.models import Project, Content |
|
|
11 |
#import logging |
|
|
12 |
#import re |
|
|
13 |
|
|
|
14 |
class MashupContextView(View): |
|
|
15 |
|
|
|
16 |
branding = "iri" |
|
|
17 |
|
|
|
18 |
def get_context_dict(self, request): |
|
|
19 |
context = {} |
|
|
20 |
context["branding"] = self.branding |
|
|
21 |
context["top_header_partial"] = "partial/%s_composer_header.html" % self.branding |
|
|
22 |
return context |
|
|
23 |
|
|
|
24 |
|
|
|
25 |
class MetadataComposerHome(TemplateResponseMixin, MashupContextView): |
|
|
26 |
|
|
|
27 |
def get_template_names(self): |
|
|
28 |
return "metadatacomposer_home.html" |
|
|
29 |
|
|
|
30 |
@method_decorator(login_required) |
|
|
31 |
def dispatch(self, *args, **kwargs): |
|
|
32 |
return super(MetadataComposerHome, self).dispatch(*args, **kwargs) |
|
|
33 |
|
|
|
34 |
def get(self, request, branding="iri", **kwargs): |
|
|
35 |
self.branding = branding |
|
|
36 |
|
|
|
37 |
projects = Project.safe_objects.filter(owner=request.user).order_by('-modification_date')[:6] |
|
|
38 |
contents = Content.safe_objects.order_by('-update_date')[:6] |
|
|
39 |
|
|
|
40 |
context = self.get_context_dict(request) |
|
|
41 |
context.update({"projects":projects, "contents": contents}) |
|
|
42 |
return self.render_to_response(context) |
|
|
43 |
|
|
|
44 |
|