def studentship(request, slug): studentship = Studentship.objects.get(slug=slug) entity = studentship.hosted_by template = getattr(entity, "__get_template__", getattr(settings, "CMS_DEFAULT_TEMPLATE", "base.html")) links = object_links(studentship) return shortcuts.render_to_response( "vacancies_and_studentships/studentship.html", {"studentship":studentship, "template": template, "entity": entity, "links": links, }, RequestContext(request), )
def vacancy(request, slug): """ Responsible for publishing vacancy """ print " -------- views.vacancy --------" vacancy = Vacancy.objects.get(slug=slug) entity = vacancy.hosted_by template = getattr(entity, "__get_template__", getattr(settings, "CMS_DEFAULT_TEMPLATE", "base.html")) links = object_links(vacancy) return shortcuts.render_to_response( "vacancies_and_studentships/vacancy.html", {"vacancy":vacancy, "template": template, "entity": entity, "links": links, }, RequestContext(request), )
def event(request, slug): """ Responsible for publishing an event """ print " -------- views.event --------" event = Event.objects.get(slug=slug) speakers = event.get_speakers() entity = event.hosted_by template = getattr(entity, "__get_template__", getattr(settings, "CMS_DEFAULT_TEMPLATE", "base.html")) links = object_links(event) request.current_page = default_entity.get_website() return shortcuts.render_to_response( "news_and_events/event.html", {"event": event, "content_object": event, "speakers": speakers, "template": template, "entity" : entity, "links": links, }, RequestContext(request), )
def newsarticle(request, slug): """ Responsible for publishing news article """ print " -------- views.newsarticle --------" newsarticle = NewsArticle.objects.get(slug=slug) print newsarticle.date - datetime.now() entity = newsarticle.hosted_by links = object_links(newsarticle) print links request.current_page = default_entity.get_website() template = getattr(entity, "__get_template__", getattr(settings, "CMS_DEFAULT_TEMPLATE", "base.html")) return shortcuts.render_to_response( "news_and_events/newsarticle.html", {"newsarticle":newsarticle, "template": template, "content_object": newsarticle, "entity": entity, "links": links, }, RequestContext(request), )
def vacancy_and_studentship(item): item.links = object_links(item) # not needed if using get_links templatetag item.hosted_by = item.hosted_by or default_entity item.link_to_vacancies_and_studentships_page = item.hosted_by.get_related_info_page_url("vacancies-and-studentships") item.template = item.hosted_by.get_template() return item
def person(request, slug, active_tab=""): """ Responsible for the person pages """ # does this Person even exist? person = get_object_or_404(Person, slug=slug, active=True) meta = {} tabs = PERSON_TABS(person, active_tab) if active_tab: if active_tab not in tabs.live_tabs: raise Http404 active_tab = "_" + tabs.live_tabs[active_tab]["tab"] meta = {"description": tabs.description} person.links = object_links(person) # we have a home_role, but we should also provide a role, even where it's # good enough to give us an address home_role = person.get_role if home_role: entity = home_role.entity # don't rely on home_role.entity - could be None or overridden entity = person.get_entity building = person.get_building email = person.get_email() phone = person.get_phone_contacts() # contact = person.get_please_contact() if person.please_contact: precise_location = None else: precise_location = person.precise_location access_note = person.access_note if home_role: description = ", ".join( (home_role.__unicode__(), entity.__unicode__()) ) request.current_page = entity.get_website else: description = Entity.objects.base_entity().__unicode__() request.current_page = Entity.objects.base_entity().get_website # if we don't have an active_tab, meta["description"] is "" meta.setdefault( "description", " ".join((person.__unicode__(), description)) ) if entity: template = entity.get_template() # no memberships, no useful information else: template = Entity.objects.base_entity().get_template() if tabs.tabs: if not active_tab: # find out what to add to the url for this tab active_tab = tabs.tabs[0]["address"] # mark the tab as active for the template tabs.tabs[0]["active"] = True # fewer than 2? not worth having tabs! if len(tabs.tabs) == 1: tabs.tabs = [] # there's a problem here - pages such as Cardiff's # /person/dr-kathrine-jane-craig/ don't get the menu right - why? # print "****", request.auto_page_url, request.path, request.current_page, # entity.get_website return render_to_response( "contacts_and_people/person%s.html" % active_tab, { "person": person, # personal information "home_role": home_role, # entity and position "entity": entity, "template": template, # from entity "building": building, "email": email, # from person or please_contact "precise_location": precise_location, # from person, or None "phone": phone, "full_address": person.get_full_address, "access_note": access_note, # from person "tabs": tabs.tabs, "tab_object": person, "active_tab": active_tab, "meta": meta, }, RequestContext(request), )
def person(request, slug, active_tab=""): """ Responsible for the person pages """ person = get_object_or_404(Person, slug=slug) links = object_links(person) # we have a home_role, but we should also provide a role, even where it's good enough to give us an address home_role = person.get_role() if home_role: entity = home_role.entity entity = person.get_entity() # don't rely on home_role.entity - could be None or overridden # address = person.get_address() contact = person.get_please_contact() email = contact.email phone = contact.phone_contacts if person.override_entity or person.please_contact: location = None else: location = person.precise_location access_note = person.access_note if home_role: description = ", ".join((home_role.__unicode__(), entity.__unicode__())) request.current_page = entity.get_website() else: description = default_entity.__unicode__() request.current_page = default_entity.get_website() meta = {"description": ": ".join((person.__unicode__(), description))} if entity: template = entity.get_template() else: # no memberships, no useful information print "no memberships, no useful information" template = default_entity.get_template() tabs = [] if "publications" in applications: try: if person.researcher and person.researcher.publishes: tabs.extend(("research", "publications")) except Researcher.DoesNotExist: pass return render_to_response( "contacts_and_people/persondetails" + str(active_tab) + ".html", { "person": person, # personal information "home_role": home_role, # entity and position "entity": entity, "template": template, # from entity # "address": address, # from entity "email": email, # from person or please_contact "location": location, # from person, or None "contact": contact, # from person or please_contact "phone": phone, "access_note": access_note, # from person "tabs": tabs, "active_tab": active_tab, "meta": meta, "links": links, }, RequestContext(request), )
def person(request, slug, active_tab=""): """ Responsible for the person pages """ person = get_object_or_404(Person,slug=slug) person.links = object_links(person) # we have a home_role, but we should also provide a role, even where it's good enough to give us an address home_role = person.get_role() if home_role: entity = home_role.entity entity = person.get_entity # don't rely on home_role.entity - could be None or overridden address = person.get_address() contact = person.get_please_contact() email = contact.email phone = contact.phone_contacts.all() if person.override_entity or person.please_contact: location = None else: location = person.precise_location access_note = person.access_note if home_role: description = ", ".join((home_role.__unicode__(), entity.__unicode__())) request.current_page = entity.get_website else: description = default_entity.__unicode__() request.current_page = default_entity.get_website meta = { "description": ": ".join((person.__unicode__(), description)) } if entity: template = entity.get_template() else: # no memberships, no useful information # print "no memberships, no useful information" template = default_entity.get_template() tabs_dict = { # information for each kind of person tab "default": { "tab": "contact", "title": "Contact information", "address": "", "meta_description_content": person, }, "research": { "tab": "research", "title": "Research", "address": "research", "meta_description_content": unicode(person) + "- research interests", }, "publications": { "tab": "publications", "title": "Publications", "address": "publications", "meta_description_content": unicode(person) + "- publications", }, } # mark the active tab, if there is one if active_tab: tabs_dict[active_tab]["active"] = True # add tabs to the list of tabs tabs = [] tabs.append(tabs_dict["default"]) if 'publications' in applications: try: if person.researcher and person.researcher.publishes: tabs.append(tabs_dict["research"]) tabs.append(tabs_dict["publications"]) except Researcher.DoesNotExist: pass # were there any tabs created? if tabs: if not active_tab: # find out what to add to the url for this tab # print tabs[0] active_tab=tabs[0]["address"] # mark the tab as active for the template tabs[0]["active"]=True # fewer than 2? not worth having tabs! if len(tabs)==1: tabs=[] meta_description_content = tabs_dict[active_tab or "default"]["meta_description_content"] if active_tab: active_tab = "_" + active_tab meta = { "description": meta_description_content, } # there's a problem here - pages such as Cardiff's /person/dr-kathrine-jane-craig/ don't # get the menu right - why? # print "****", request.auto_page_url, request.path, request.current_page, entity.get_website return render_to_response( "contacts_and_people/person%s.html" % active_tab, { "person":person, # personal information "home_role": home_role, # entity and position "entity": entity, "template": template, # from entity "address": address, # from entity "email": email, # from person or please_contact "location": location, # from person, or None "contact": contact, # from person or please_contact "phone": phone, "access_note": access_note, # from person "tabs": tabs, "tab_object": person, "active_tab": active_tab, "meta": meta, # "links": links, }, RequestContext(request), )
def newsarticle_and_event(item): item.links = object_links(item) # not needed if using get_links templatetag item.hosted_by = item.hosted_by or default_entity item.link_to_news_and_events_page = item.hosted_by.get_related_info_page_url("news-and-events") item.template = item.hosted_by.get_template() return item
def links(self): return object_links(self)