def get_sites(): siteManager = SiteManager(client_json=settings.PPCLIENT) sites = siteManager.all() choices = [] for site in sites: choices.append((site.label, site.name)) return choices
def show(request, site_id, participant_id, session_id, component_id, basename, template='browse/items/show.html'): siteManager = SiteManager(client_json=request.session.get('client', None)) itemManager = ItemManager(client_json=request.session.get('client', None)) site = siteManager.get(site_id) item = itemManager.get(participant_id, basename) breadcrumbs = generate_breadcrumbs(request, site) if item is None: return Http404("Item not found %s" % basename) return render( request, 'browse/items/show.html', { 'site_id': site_id, 'site': site, 'participant_id': participant_id, 'component_id': component_id, 'session_id': session_id, 'item': item, 'breadcrumbs': breadcrumbs, })
def index(request, site_id, participant_id, session_id, component_id, template='browse/items/index.html'): siteManager = SiteManager(client_json=request.session.get('client', None)) itemManager = ItemManager(client_json=request.session.get('client', None)) site = siteManager.get(site_id) items = itemManager.filter_by_component(participant_id, session_id, component_id) item_ids = [item.identifier for item in items] breadcrumbs = generate_breadcrumbs(request, site) return render( request, template, { 'site_id': site_id, 'site': site, 'participant_id': participant_id, 'session_id': session_id, 'component_id': component_id, 'items': items, 'item_ids': item_ids, 'zipname': participant_id + "-" + component_id, 'breadcrumbs': breadcrumbs })
def index (request, site_id, participant_id, session_id, template = 'browse/components/index.html'): siteManager = SiteManager(client_json=request.session.get('client',None)) site = siteManager.get (site_id) componentManager = ComponentManager(client_json=request.session.get('client',None)) components = componentManager.filter_by_session (site_id, participant_id, session_id) component_ids = [ component.identifier for component in components ] breadcrumbs = generate_breadcrumbs(request,site) return render (request, template, {'site_id' : site_id, 'site': site, 'participant_id' : participant_id, 'session_id' : session_id, 'components': components, 'item_ids' : component_ids, 'breadcrumbs' : breadcrumbs })
def index(request, site_id): siteManager = SiteManager(client_json=request.session.get('client',None)) participantManager = ParticipantManager(client_json=request.session.get('client',None)) site = siteManager.get(site_id) if site is None: search_form = SearchForm(request.GET) participants = participantManager.filter(search_form.generate_predicates()) else: participants = participantManager.with_data(site) breadcrumbs = generate_breadcrumbs(request,site) return render(request, 'browse/participants/index.html', { 'request' : request, 'site' : site, 'participants' : participants, 'breadcrumbs' : breadcrumbs })
def index(request): siteManager = SiteManager(client_json=request.session.get('client', None)) sessionManager = SessionManager( client_json=request.session.get('client', None)) sites = siteManager.all() counts = siteManager.all_site_and_session_counts() data = [] for site in sites: res = counts.get(site.label, { 1: "N/A", 2: "N/A", 3: "N/A", 4: "N/A", }) data.append((site, res['1'], res['2'], res['3'], res['4'])) return render(request, 'browse/sites/index.html', { 'request': request, 'sites': data, })
def show(request, site_id, participant_id): siteManager = SiteManager(client_json=request.session.get('client',None)) participantManager = ParticipantManager(client_json=request.session.get('client',None)) sessionManager = SessionManager(client_json=request.session.get('client',None)) languageUsageManager = LanguageUsageManager(client_json=request.session.get('client',None)) residenceHistoryManager = ResidenceHistoryManager(client_json=request.session.get('client',None)) site = siteManager.get (site_id) if site is None: raise Http404 ("Requested site not found") participant = participantManager.get (participant_id) if participant is None: raise Http404 ("Requested participant not found") sessions = sessionManager.filter_by_participant (participant) rhist = residenceHistoryManager.filter_by_participant(participant) lang = languageUsageManager.filter_by_participant(participant) language_usage = get_language_usage(request, lang) breadcrumbs = generate_breadcrumbs(request,site) if 'first_language' in participant.properties().keys(): language_url = '<' + participant.properties()['first_language'][0] + '>' first_language = get_language_name(request,language_url) else: first_language = 'N/A' if 'father_first_language' in participant.properties().keys(): language_url = '<' + participant.properties()['father_first_language'][0] + '>' father_first_language = get_language_name(request, language_url) else: father_first_language = 'N/A' if 'mother_first_language' in participant.properties().keys(): language_url = '<' + participant.properties()['mother_first_language'][0] + '>' mother_first_language = get_language_name(request, language_url) else: mother_first_language = 'N/A' return render (request, 'browse/participants/show.html', { 'participant': participant, 'site': site, 'site_id': site_id, 'sessions': sessions, 'residential_history': rhist, 'language_usage': language_usage, 'item_ids' : [ participant.identifier ], 'breadcrumbs' : breadcrumbs, 'first_language': first_language, 'father_first_language': father_first_language, 'mother_first_language': mother_first_language, 'scope' : 'browse' })
def password_reset(request): if request.method == 'POST': form = ColourAnimalHelperForm(request.POST) if form.is_valid(): # Create a SPARQL Query to retrieve possible results based on the answers siteManager = SiteManager(client_json=request.session.get('client',settings.PPCLIENT)) # Get the site object from site_label (get function needs a label parameter) site_label = form.data['pwd_site'] site = siteManager.get(label=site_label) query = '?part austalk:recording_site <%s> .\n' % site.identifier # Grab all the form data and convert them to lower case # in order to compare the result of SPARQL Query if form.data['pwd_highest_qual'] != 'None': value = form.data['pwd_highest_qual'] query += "?part austalk:education_level '%s' .\n" % value if form.data['pwd_father_highest_qual'] != 'None': value = form.data['pwd_father_highest_qual'] query += "?part austalk:father_education_level '%s' .\n" % value if form.data['pwd_mother_highest_qual'] != 'None': value = form.data['pwd_mother_highest_qual'] query += "?part austalk:mother_education_level '%s' .\n" % value sparql = SparqlManager() sparql_results = sparql.query(""" SELECT ?part where { ?part rdf:type foaf:Person . %s }""" % query,client=siteManager.client) results = [] # Bind the result from SPARQL query into a list - results for result in sparql_results["results"]["bindings"]: part = Participant ( identifier = result["part"]["value"], client = siteManager.client ) results.append (part) # return the results to the template for displaying to the user return render(request,'colour_animal_helper_done.html', {'results': results }) form = ColourAnimalHelperForm() return render(request, 'colour_animal_helper_form.html', {'form': form})