コード例 #1
0
def details(request, package, version, simple=False, **kwargs):
    kwargs.setdefault('template_object_name', 'release')
    release = get_object_or_404(Package, name=package).get_release(version)

    if not release:
        raise Http404('Version %s does not exist for %s' % (
            version,
            package,
        ))

    if not simple:
        if not request.user.is_authenticated():
            return redirect_to_login(request.get_full_path())

        kwargs.setdefault('queryset', user_releases(request.user))

        try:
            return list_detail.object_detail(request,
                                             object_id=release.id,
                                             **kwargs)
        except Http404:
            return HttpResponseForbidden('You do not have sufficient \
                                            permissions to view this package.')
    else:
        kwargs.setdefault('queryset', Release.objects.all())
        return list_detail.object_detail(request,
                                         object_id=release.id,
                                         **kwargs)
コード例 #2
0
def send_email(request, object_id):

    # create email message using generic views
    msg_text = list_detail.object_detail(
        request,
        queryset=Person.objects.all(),
        template_name="etreg/person_email_text.html",
        object_id=object_id,
        mimetype=None)

    # create email message using generic views
    msg_html = list_detail.object_detail(
        request,
        queryset=Person.objects.all(),
        template_name="etreg/person_email_html.html",
        object_id=object_id,
        mimetype=None)

    message_text = ''
    for line in msg_text:
        if not "Content-Type" in line:
            message_text += line

    message_html = ''
    for line in msg_html:
        if not "Content-Type" in line:
            message_html += line

    # Remove line "Content-Type: text/html; charset=utf-8"
    # http://stackoverflow.com/questions/1801008/django-html-email-adds-extra-characters-to-the-email-body
    #message_html = str(message_html).replace('Content-Type: text/html; charset=utf-8', '')
    #message_html = message_html.replace('X-Object-Type: etreg.person Content-Type: text/html; charset=utf-8 X-Object-Id: ', '')
    #message_html = message_html.replace('X-Object-Type: etreg.person X-Object-Id: ', '')

    person = Person.objects.filter(id=object_id)

    subject = _('Europatreffen Registration')
    from_email = '*****@*****.**'
    to_email = person[0].email

    msg = EmailMultiAlternatives(
        subject, message_text, from_email,
        ['*****@*****.**', '*****@*****.**', to_email])
    msg.attach_alternative(message_html, "text/html")
    msg.send()

    redirect_url = '/etreg/detail/%s/?token=sent' % object_id
    return HttpResponseRedirect(redirect_url)
コード例 #3
0
def associate(request, object_id, modelname="", **kwargs):
    if not kwargs.get("template_name"):
        kwargs["template_name"] = 'csv_detail.html'
    if not kwargs.get("form_class"):
        kwargs["form_class"] = CSVAssociateForm
    if not modelname:
        raise ValueError(
            "A model wasn't specified. This is our fault. Please let us know this happened so we can fix it, thanks.")
    else:
        kwargs["model"] = eval(modelname)

    kwargs = prepare_view(request, kwargs)
    instance = get_object_or_404(CSV, pk=object_id)
    if request.method == 'POST':
        form = kwargs["form_class"](instance, request.POST)
        if form.is_valid():
            form.save(request)
            request.user.message_set.create(message='CSV imported.')
            return HttpResponseRedirect("/core/%s" % (modelname.lower()))
    else:
        messages.info(request, 'Uploaded CSV. Please associate fields below.')
        form = CSVAssociateForm(instance)
    kwargs["extra_context"].update({"form": form})
    return object_detail(request,
        queryset=CSV.objects.all(),
        object_id=object_id,
        template_name=kwargs["template_name"],
        template_object_name='csv',
        extra_context=kwargs["extra_context"],
    )
コード例 #4
0
ファイル: views.py プロジェクト: B-Rich/M2M
def city_detail(request, slug, **kwargs):
    return list_detail.object_detail(
        request,
        queryset = City.objects.all(),
        slug = slug,
        **kwargs
    )
コード例 #5
0
ファイル: views.py プロジェクト: redvasily/django-newsletter
def newsletter_detail(request, newsletter_slug):
    newsletters = Newsletter.on_site.filter(visible=True)
    
    if not newsletters:
        raise Http404
        
    return list_detail.object_detail(request, newsletters, slug=newsletter_slug)
コード例 #6
0
ファイル: views.py プロジェクト: tieugene/tipython
def	org_detail(request, object_id):
	return object_detail (
		request,
		queryset = Org.objects.all(),
		object_id = object_id,
		template_name = 'contact/org_detail.html',
	)
コード例 #7
0
ファイル: views.py プロジェクト: aawsolutions/bslcks
def talents_detail(request, slug, **kwargs):
    return list_detail.object_detail(
        request,
        queryset=Talents.objects.all(),
        slug=slug,
        **kwargs
    )
コード例 #8
0
ファイル: views.py プロジェクト: FOSSEE/scipycon
def talk(request, scope, id):
    objects = Talk.objects.filter(approved=True)
    audience = {}
    for choice in AUDIENCE_CHOICES:
        audience[choice[0]] = choice[1]
    extra_context = dict(choices=audience)
    return object_detail(request, objects, id, extra_context=extra_context)
コード例 #9
0
ファイル: views.py プロジェクト: peernohell/pnbank
def view_account(request, account_id):
    if not request.user.is_superuser:
        get_object_or_404(Account, owner=request.user, pk=account_id)
    else:
        get_object_or_404(Account, pk=account_id)

    qss_entries = None
    qss_transactions = None
    qs = Account.objects.filter(pk = account_id)
    transaction_qs = Transaction.objects.filter(entries__account = account_id)\
            .annotate(date=Min('entries__date'))

    if qs:
        qss_entries = QuerySetStats(qs, 'entries__date')
        qss_transactions = QuerySetStats(transaction_qs, 'date')

    return object_detail(
        request = request,
        queryset = qs,
        object_id = account_id,
        template_name = "account_detail.html",
        extra_context = {
            'qss_entries': qss_entries,
            'qss_transactions': qss_transactions,
        }
    )
コード例 #10
0
ファイル: views.py プロジェクト: umitproject/network-admin
def widget_detail(request, widgetsettings_id):
    """Widget details page where user can set options defined for the widget
    """
    widget = WidgetSettings.objects.get(pk=widgetsettings_id)
    opts = widget.get_widget().options(widget)
    
    if request.method == "POST":
        form = options_form(opts)(request.POST)
        if form.is_valid():
            for field in form.cleaned_data:
                set_option(field, form.cleaned_data[field])
    
    if opts:
        defaults = [opt.get('default') for opt in opts.values()]
        initial = get_options(opts.keys(), defaults)
        form = options_form(opts)(initial=initial)
    else:
        form = None
    
    extra_context = {
        'options_form': form 
    }
    queryset = WidgetSettings.objects.all()
    return object_detail(request, queryset, widgetsettings_id,
                         template_name="plugins/widget_detail.html",
                         extra_context=extra_context)
コード例 #11
0
ファイル: views.py プロジェクト: muskanmahajan37/scipycon
def talk(request, scope, id):
    objects = Talk.objects.filter(approved=True)
    audience = {}
    for choice in AUDIENCE_CHOICES:
        audience[choice[0]] = choice[1]
    extra_context = dict(choices=audience)
    return object_detail(request, objects, id, extra_context=extra_context)
コード例 #12
0
ファイル: views.py プロジェクト: t001/Praktomat
def solution_detail(request, solution_id, full):
    solution = get_object_or_404(Solution, pk=solution_id)
    if (not (solution.author == request.user
             or in_group(request.user, 'Trainer') or
             (solution.author.tutorial and
              solution.author.tutorial.tutors.filter(id=request.user.id)))):
        return access_denied(request)

    if (request.method == "POST"):
        solution.copy()
        return HttpResponseRedirect(
            reverse('solution_list', args=[solution.task.id]))
    else:
        attestations = Attestation.objects.filter(
            solution__task=solution.task,
            author__tutored_tutorials=request.user.tutorial)
        attestationsPublished = attestations[
            0].published if attestations else False
        return object_detail(request,
                             Solution.objects.all(),
                             solution_id,
                             extra_context={
                                 "attestationsPublished":
                                 attestationsPublished,
                                 "accept_all_solutions":
                                 get_settings().accept_all_solutions,
                                 "full": full
                             },
                             template_object_name='solution')
コード例 #13
0
def index(request):
    if first_nav:
        return object_detail(request, Article.objects.all(),
                             slug=first_nav.get_article().slug,
                             extra_context={'nav_headers': nav_headers})
    else:
        raise Http404
コード例 #14
0
def book_detail(request, book_id):
    return object_detail(
        request,
        queryset=Book.objects.all(),
        object_id=book_id,
        template_object_name='book',
    )
コード例 #15
0
ファイル: views.py プロジェクト: dmeehan/actionmanual
def precedent_detail(request, slug):
    precedents = Precedent.published.all()
    return object_detail(request,
                         queryset=precedents,
                         slug=slug,
                         template_object_name='project',
                         template_name='portfolio/precedent_detail.html',)
コード例 #16
0
ファイル: views.py プロジェクト: mcr/ietfdb
def liaison_detail(request, object_id):
    if settings.USE_DB_REDESIGN_PROXY_CLASSES:
        qfilter = Q()
        public_liaisons = LiaisonDetail.objects.exclude(approved=None).order_by("-submitted_date")
    else:
        qfilter = Q(approval__isnull=True)|Q(approval__approved=True)
        public_liaisons = LiaisonDetail.objects.filter(qfilter).order_by("-submitted_date")
    liaison = get_object_or_404(public_liaisons, pk=object_id)
    can_edit = False
    user = request.user
    can_take_care = _can_take_care(liaison, user)
    if user.is_authenticated() and can_edit_liaison(user, liaison):
        can_edit = True
    if request.method == 'POST' and request.POST.get('do_action_taken', None) and can_take_care:
        liaison.action_taken = True
        liaison.save()
        can_take_care = False
    relations = liaison.liaisondetail_set.filter(qfilter)
    return  object_detail(request,
                          public_liaisons,
                          template_name="liaisons/liaisondetail_detail.html",
                          object_id=object_id,
                          extra_context = {'can_edit': can_edit,
                                           'relations': relations,
                                           'can_take_care': can_take_care}
                         )
コード例 #17
0
def generic_wrapper_detail(request, *args, **kwargs):
    if request.user.is_anonymous():
        queryset = Entry.objects.filter(status='P',
                                        pub_date__lte=datetime.datetime.now())
    else:
        queryset = Entry.objects.all()
    return object_detail(request, queryset, *args, **kwargs)
コード例 #18
0
ファイル: views.py プロジェクト: andynicholson/transitlabour
def blog_view(request, slug_name, author_name):
	# note - this is currently only used for a specfic blog view and author view - not the front page of the "blogs" section of the site
	# check urls.py carefully
	is_owner = False

	#find the required blog via its slug 'slug_name'
	if not slug_name is None:
		blogs = Blog.objects.all().filter(slug=slug_name).order_by('-published_date')
		author_view = False
		blog_view = True
		bauthor = None
		sticky_blogs = None
		is_owner = is_owner_of(request, blogs[0])
	else:
		#no slugname - author view
		bauthor = User.objects.all().filter(username=author_name)[0]
		blogs = Blog.objects.all().filter(author=bauthor, sticky=False).order_by('-published_date')
		sticky_blogs = Blog.objects.all().filter(author=bauthor, sticky=True).order_by('-published_date')
		author_view = True
		blog_view = False
	#get list of latest bloggers
	bloggers = latest_bloggers(Blog.objects.all().order_by('-published_date'))
	#paginate results
	blog_paginator = paginate(request,blogs)

	extra_context = {'bloggers':bloggers, 'blogs':blog_paginator, 'blog_view':blog_view, 'author_view':author_view, 'bauthor':bauthor, 'sticky_blogs':sticky_blogs, 'is_owner':is_owner}

	template_file_name='blogs'
	page_name='blogs'
	# find the page object which represents the actual page (not blogs within page) by its slug name 'page_name' , and the template
	return object_detail( request, queryset = Page.objects.filter(slug=page_name), slug=page_name, template_name="transitlabourapp/%s.html"%template_file_name, extra_context=extra_context )
コード例 #19
0
ファイル: views.py プロジェクト: klenks/jobsportal
def job_confirm(request, job_id, auth):
    ''' A view to confirm a recently created job, if it has been published
        by a previously approved user then it gets automatically published,
        if not then it will need to be verified by a moderator.
    '''
    job = get_object_or_404(Job, pk=job_id, auth=auth)
    if job.status not in (Job.ACTIVE, Job.TEMPORARY):
        raise Http404
    new_post = job.is_temporary()
    requires_mod = not job.email_published_before() and \
                 djobberbase_settings.DJOBBERBASE_ENABLE_NEW_POST_MODERATION
    if requires_mod:
        messages.add_message(request, 
                       messages.INFO, 
                       _('Your job post needs to be verified by a moderator.'))
        if djobberbase_settings.DJOBBERBASE_POSTER_NOTIFICATIONS:
            pending_email = MailPublishPendingToUser(job, request)
            pending_email.start()
    else:
        messages.add_message(request, 
                             messages.INFO, 
                             _('Your job post has been published.'))
        if not job.is_active():
            job.activate()
        if new_post:
            if djobberbase_settings.DJOBBERBASE_POSTER_NOTIFICATIONS:
                publish_email = MailPublishToUser(job, request)
                publish_email.start()    
    queryset = Job.objects.all()
    if djobberbase_settings.DJOBBERBASE_ADMIN_NOTIFICATIONS:
        admin_email = MailPublishToAdmin(job, request)
        admin_email.start()
    return object_detail(request, queryset=queryset,
                         object_id=job_id,
                         extra_context={'page_type':'confirm'})
コード例 #20
0
ファイル: views.py プロジェクト: aawsolutions/bslcks
def group_detail(request, slug, **kwargs):
    return list_detail.object_detail(
        request,
        queryset=Group.objects.all(),
        slug=slug,
        **kwargs
    )
コード例 #21
0
ファイル: views.py プロジェクト: khayford/mzalendo
def info_page(request, slug='index'):
    """Show the page, or 'index' if no slug"""
    return object_detail(
        request,
        queryset=InfoPage.objects,
        slug=slug,
    )
コード例 #22
0
ファイル: views.py プロジェクト: pombredanne/chiplog
def entry_detail(request, object_id):
    return list_detail.object_detail(
        request,
        object_id = object_id,
        queryset = Entry.objects.all(),
        template_object_name = 'entry'
    )
コード例 #23
0
ファイル: views.py プロジェクト: aehlke/django-newsletter
def newsletter_detail(request, newsletter_slug):
    newsletters = Newsletter.on_site.filter(visible=True)
    
    if not newsletters:
        raise Http404
        
    return list_detail.object_detail(request, newsletters, slug=newsletter_slug)
コード例 #24
0
ファイル: views.py プロジェクト: tieugene/tipython
def	jobrole_detail(request, object_id):
	return object_detail (
		request,
		queryset = JobRole.objects.all(),
		object_id = object_id,
		template_name = 'contact/jobrole_detail.html',
	)
コード例 #25
0
ファイル: views.py プロジェクト: isabella232/transparencyjobs
def joblisting_detail(request, object_id):
    jobs = gatekeeper.approved(JobListing.objects.filter(pk=object_id))
    other_jobs = gatekeeper.approved(JobListing.objects.open().exclude(pk=object_id).order_by("?"))[:5]
    try:
        return object_detail(request, queryset=jobs, object_id=object_id, template_object_name="job", extra_context={"other_jobs":other_jobs})
    except Http404:
        return HttpResponse("couldn't find job")
コード例 #26
0
ファイル: views.py プロジェクト: micahr/django-events
def event_time_detail(request, event_time_id, event_slug,
                        template_name = 'event_time.html'):
    event_time = get_object_or_404(EventTime,
        id = event_time_id,
        event__slug = event_slug)
    attending = False
    past = False
    if event_time.end < datetime.datetime.now():
        past = True
    if request.user.is_authenticated() \
        and event_time in [x.event_time for x in request.user.attendee_set.all()] \
        or event_time in request.session.get('event_times',[]):
        attending = True
    if request.user.is_authenticated():
        request.session['name'] = ''
    return list_detail.object_detail(
            request,
            queryset = EventTime.objects.filter(id=event_time_id,
                event__slug = event_slug),
            template_name = template_name,
            object_id = event_time_id,
            extra_context = {'attending':attending, 
                             'name':request.session.get('name', None),
                             'past':past},
            template_object_name = 'event_time',
        )
コード例 #27
0
def View_available_goods_detail(request, id):
    return object_detail(request,
                         queryset=GoodsResource.objects.all(),
                         object_id=id,
                         template_name='ViewAvailableGoods/detail.html',
                         template_object_name='ViewAvailableGoods',
                         context_instance=RequestContext(request))
コード例 #28
0
ファイル: normal.py プロジェクト: chaosk/django-faq
def topic_detail(request, slug):
    """
    A detail view of a Topic

    Templates:
        ``<topic_template_name>``
            If the :model:`faq.Topic` object has a ``template_name`` value,
            the system will attempt to load that template.
        :template:`faq/topic_detail.html`
            If there is no ``template_name`` given or the template specified
            does not exist the standard template will be used.
    Context:
        topic
            An :model:`faq.Topic` object.
        question_list
            A list of all published :model:`faq.Question` objects that relate
            to the given :model:`faq.Topic`.

    """
    extra_context = {
        'question_list': Question.objects.published().filter(topic__slug=slug),
    }

    return object_detail(request, queryset=Topic.objects.published(),
        extra_context=extra_context, template_object_name='topic',
        template_name_field='template_name', slug=slug)
コード例 #29
0
def LocalGovernment_detail(request, id):

    return object_detail(request,
                         queryset=LocalGovernment.objects.all(),
                         object_id=id,
                         template_name='ManageResources/detail.html',
                         template_object_name='LocalGovernment')
コード例 #30
0
ファイル: views.py プロジェクト: opendream/openkala
def photo_detail(request, project_id, photo_id):
    if not request.GET.get('ajax'):
        return project_overview(request, project_id)

    photo = Photo.objects.get(id=photo_id)
    info = get_exif(photo.fullurl()[1:])
    if info:
        dt = info.get('DateTime') or info.get('DateTimeOriginal') or info.get(
            'DateTimeDigitized')
        if dt:
            dt = datetime.strptime(dt, '%Y:%m:%d %H:%M:%S')
        else:
            dt = None
    else:
        dt = None

    # Mode
    mode = project_getmode_helper(request, project_id)
    is_view_mode = mode == 'view'

    return object_detail(request,
                         Photo.objects.all(),
                         object_id=photo_id,
                         template_object_name='photo',
                         template_name='stockphoto/photo_detail.html',
                         extra_context={
                             'project_id': project_id,
                             'datetime': dt,
                             'is_view_mode': is_view_mode
                         })
コード例 #31
0
def Goods_details(request, id):

    return object_detail(request,
                         queryset=GoodsResource.objects.all(),
                         object_id=id,
                         template_name='ManageResources/detail_goods.html',
                         template_object_name='GoodsResource')
コード例 #32
0
ファイル: views.py プロジェクト: mcr/ietfdb
def liaison_approval_detail(request, object_id):
    if is_secretariat(request.user):
        to_approve = LiaisonDetail.objects.filter(approved=None).order_by("-submitted")
    else:
        person = get_person_for_user(request.user)
        approval_codes = IETFHM.get_all_can_approve_codes(person)
        if settings.USE_DB_REDESIGN_PROXY_CLASSES:
            to_approve = approvable_liaison_statements(approval_codes).order_by("-submitted")
        else:
            to_approve = LiaisonDetail.objects.filter(approval__isnull=False, approval__approved=False, from_raw_code__in=approval_codes).order_by("-submitted_date")

    if request.method=='POST' and request.POST.get('do_approval', False):
        try:
            liaison = to_approve.get(pk=object_id)
            if settings.USE_DB_REDESIGN_PROXY_CLASSES:
                liaison.approved = datetime.datetime.now()
                liaison.save()
            else:
                approval = liaison.approval
                if not approval:
                    approval = OutgoingLiaisonApproval.objects.create(approved=True, approval_date=datetime.datetime.now())
                    liaison.approval = approval
                    liaison.save()
                else:
                    approval.approved=True
                    approval.save()
            liaison.send_by_email()
        except LiaisonDetail.DoesNotExist:
            pass
        return HttpResponseRedirect(reverse('liaison_list'))
    return  object_detail(request,
                          to_approve,
                          object_id=object_id,
                          template_name='liaisons/liaisondetail_approval_detail.html',
                         )
コード例 #33
0
def Rent_details(request, id):

    return object_detail(request,
                         queryset=RentResource.objects.all(),
                         object_id=id,
                         template_name='ManageResources/detail_rent.html',
                         template_object_name='gymResource')
コード例 #34
0
ファイル: views.py プロジェクト: peernohell/pnbank
def view_entry(request, entry_id, account_id=None):
    if not request.user.is_superuser:
        entry = get_object_or_404(Entry, owner=request.user, pk=entry_id)
    else:
        entry = get_object_or_404(Entry, pk=entry_id)

    if account_id:
        account = get_object_or_404(Account, pk=account_id)
        if entry.account != account:
            raise Http404

        extra_context = {
            'account': account,
        }
    else:
        extra_context = {}

    qs = Entry.objects.filter(pk = entry_id)

    return object_detail(
        request = request,
        queryset = qs,
        object_id = entry_id,
        template_name = "entry_detail.html",
        extra_context = extra_context,
    )
コード例 #35
0
def	phone_detail(request, object_id):
	return	object_detail (
		request,
		queryset = Phone.objects.all(),
		object_id = object_id,
		template_name = 'core/phone_detail.html',	# FIXME: 
	)
コード例 #36
0
ファイル: views.py プロジェクト: andynicholson/transitlabour
def event_view(request, slug_name, author_name):
	#find the required blog via its slug 'slug_name'
	is_owner = False
	if not slug_name is None:
		events = Event.objects.all().filter(slug=slug_name).order_by('starting_date')
		author_view = False
		event_view = True
		bauthor = None
		is_owner = is_owner_of(request,events[0])
	else:
		bauthor = User.objects.all().filter(username=author_name)[0]
		events = Event.objects.all().filter(author=bauthor).order_by('starting_date')
		author_view = True
		event_view = False

	blogs = Blog.objects.all().order_by('-published_date')
	bloggers=latest_bloggers(blogs)
	events_paginator = paginate(request,events)

	extra_context = {'bloggers':bloggers, 'events':events_paginator, 'event_view':event_view, 'author_view':author_view, 'bauthor':bauthor, 'is_owner':is_owner}

	template_file_name='events'
	page_name='events'
	# find the page object which represents the actual page (not blogs within page) by its slug name 'page_name' , and the template
	return object_detail( request, queryset = Page.objects.filter(slug=page_name), slug=page_name, template_name="transitlabourapp/%s.html"%template_file_name, extra_context=extra_context )
コード例 #37
0
def	im_detail(request, object_id):
	return	object_detail (
		request,
		queryset = IM.objects.all(),
		object_id = object_id,
		template_name = 'core/im_detail.html',	# FIXME: 
	)
コード例 #38
0
ファイル: views.py プロジェクト: manuq/pathagar
def book_detail(request, book_id):
    return object_detail(
        request,
        queryset = Book.objects.all(),
        object_id = book_id,
        template_object_name = 'book',
    )
コード例 #39
0
def preview(request, code=None, api=False, template_name=None):

    ## if the page is being accessed as API, return the clean data
    if api is True:
        if code is None:
            url = request.GET.get('url')
            code = url.rstrip('/').split('/')[-1]
        object_id = SequenceMapper.to_decimal(code)
        try:
            shorturl = ShortURL.objects.get(pk=object_id).url
        except ShortURL.DoesNotExist:
            shorturl = ''
        return _api_response(shorturl, request.GET.get('type'))

    ## get the object id from code
    object_id = SequenceMapper.to_decimal(code)
    template_name = template_name or 'base_shorturl_preview.html'

    info_dict = {
        'queryset': ShortURL.objects,
        'object_id': object_id,
        'template_name': template_name,
    }

    return list_detail.object_detail(request, **info_dict)
コード例 #40
0
def cert_revoke(request, cert_id):
    # Look up the Cert (and raise a 404 if not found)
    cert = get_object_or_404(Cert, pk=cert_id)
    if cert.pubkey.user != request.user:
        raise Http404

    if request.method == "POST":
        hidden = request.POST.get('post', None)
        if hidden and hidden == "yes":
            revoke_cert(cert)
            #XXX we should use messages here.
            return render_to_response(
                'django_webid/provider/cert_revoked.html',
                {
                    "MEDIA_URL": settings.MEDIA_URL,
                    "STATIC_URL": settings.STATIC_URL,
                })
    if request.method == "GET":
        # Show the detail page
        # with a confirmation message.
        return list_detail.object_detail(
            request,
            queryset=Cert.objects.all(),
            object_id=cert_id,
            template_name="django_webid/provider/cert_revoke.html"
        )
コード例 #41
0
ファイル: normal.py プロジェクト: coin/django-faq
def topic_detail(request, slug):
    """
    A detail view of a Topic

    Templates:
        ``<topic_template_name>``
            If the :model:`faq.Topic` object has a ``template_name`` value,
            the system will attempt to load that template.
        :template:`faq/topic_detail.html`
            If there is no ``template_name`` given or the template specified
            does not exist the standard template will be used.
    Context:
        topic
            An :model:`faq.Topic` object.
        question_list
            A list of all published :model:`faq.Question` objects that relate
            to the given :model:`faq.Topic`.

    """
    extra_context = {
        'question_list': Question.objects.published().filter(topic__slug=slug),
    }

    return object_detail(request,
                         queryset=Topic.objects.published(),
                         extra_context=extra_context,
                         template_object_name='topic',
                         template_name_field='template_name',
                         slug=slug)
コード例 #42
0
ファイル: views.py プロジェクト: aawsolutions/bslcks
def mailbox_detail(request, slug, **kwargs):
    return list_detail.object_detail(
        request,
        queryset=Mailbox.objects.all(),
        slug=slug,
        **kwargs
    )
コード例 #43
0
def detail(request, proj_id):
    '''Show information about the project'''
    project = get_object_or_404(Project, id=proj_id)
    role_reqs = ProjectRoleRequest.objects.filter(
        giver=request.user, requested_role__project=project)
    # Structure with members, ids and roles to pass to project template
    permittees = project.members_as_permittees.all()
    member_roles = dict()
    for permittee in permittees:
        member_roles[str(permittee.object.username)] = {
            "id": str(permittee.object.id),
            "roles":
            permittee.projectrole_set.filter(project__name=project.name)
        }
    return list_detail.object_detail(request,
                                     Project.objects.all(),
                                     object_id=proj_id,
                                     template_name=TEMPLATE_PATH +
                                     "/detail.html",
                                     template_object_name="project",
                                     extra_context={
                                         "role_requests":
                                         role_reqs,
                                         "member_roles":
                                         member_roles,
                                         "breadcrumbs": (
                                             ("Home", reverse("home")),
                                             ("Project %s" % project.name,
                                              reverse("project_detail",
                                                      args=[project.id])),
                                         )
                                     })
コード例 #44
0
ファイル: views.py プロジェクト: gerlad/greenline
def share_detail(request, share_id):
    """
    A shared item, in detail.
    
    """
    return object_detail(request, SharedItem.objects.select_related(), object_id=share_id,
        template_object_name='share', template_name='sharing/item.html')
コード例 #45
0
def liaison_detail(request, object_id):
    if settings.USE_DB_REDESIGN_PROXY_CLASSES:
        qfilter = Q()
        public_liaisons = LiaisonDetail.objects.exclude(
            approved=None).order_by("-submitted_date")
    else:
        qfilter = Q(approval__isnull=True) | Q(approval__approved=True)
        public_liaisons = LiaisonDetail.objects.filter(qfilter).order_by(
            "-submitted_date")
    liaison = get_object_or_404(public_liaisons, pk=object_id)
    can_edit = False
    user = request.user
    can_take_care = _can_take_care(liaison, user)
    if user.is_authenticated() and can_edit_liaison(user, liaison):
        can_edit = True
    if request.method == 'POST' and request.POST.get('do_action_taken',
                                                     None) and can_take_care:
        liaison.action_taken = True
        liaison.save()
        can_take_care = False
    relations = liaison.liaisondetail_set.filter(qfilter)
    return object_detail(request,
                         public_liaisons,
                         template_name="liaisons/liaisondetail_detail.html",
                         object_id=object_id,
                         extra_context={
                             'can_edit': can_edit,
                             'relations': relations,
                             'can_take_care': can_take_care
                         })
コード例 #46
0
def detail(request, id, slug):

    return object_detail(
        request,
        queryset=Event.objects.all(),
        object_id=id,
    )
コード例 #47
0
def book_detail(request, book_id):
    return object_detail(
        request,
        queryset=Book.objects.all(),
        object_id=book_id,
        template_object_name='book',
        extra_context={'allow_user_comments': settings.ALLOW_USER_COMMENTS})
コード例 #48
0
ファイル: views.py プロジェクト: tieugene/tipython
def	person_detail(request, object_id):
	return object_detail (
		request,
		queryset = Person.objects.all(),
		object_id = object_id,
		template_name = 'contact/person_detail.html',
	)
コード例 #49
0
ファイル: views.py プロジェクト: fetzig/django-csv-importer
def csv_import(request, object_id, **kwargs):
    if not kwargs.get("template_name"):
        kwargs["template_name"] = 'csvimporter/csv_import.html'
    if not kwargs.get("form_class"):
        kwargs["form_class"] = CSVImportForm
    kwargs = prepare_view(request, kwargs)
    instance = get_object_or_404(CSV, pk=object_id)
    if request.method == 'POST':
        form = kwargs["form_class"](instance, request.POST)
        if form.is_valid():
            form.save(request)
            request.user.message_set.create(message=_('CSV imported.'))
            kwargs["redirect_url"] = reverse('csv_result', args=[instance.id])
            return HttpResponseRedirect(kwargs["redirect_url"])
    else:
        messages.info(request, _('Uploaded CSV. Please associate fields below.'))
        form = CSVImportForm(instance)
    kwargs["extra_context"].update({"form": form})
    return object_detail(request,
        queryset=CSV.objects.all(),
        object_id=object_id,
        template_name=kwargs["template_name"],
        template_object_name='csv',
        extra_context=kwargs["extra_context"],
    )
コード例 #50
0
ファイル: views.py プロジェクト: dmeehan/douglasmeehan.com
def project_detail(request, slug):
    projects = Project.live.all()
    return object_detail(request,
                         queryset=projects,
                         slug=slug,
                         template_object_name='project',
                         template_name='portfolio/project_detail.html',)
コード例 #51
0
ファイル: views.py プロジェクト: espiritolivre/django-shortim
def preview(request, code=None, api=False, template_name=None):

    ## if the page is being accessed as API, return the clean data
    if api is True:
        if code is None:
            url = request.GET.get('url')
            code = url.rstrip('/').split('/')[-1]
        object_id = SequenceMapper.to_decimal(code)
        try:
            shorturl = ShortURL.objects.get(pk=object_id).url
        except ShortURL.DoesNotExist:
            shorturl = ''
        return _api_response(shorturl, request.GET.get('type'))

    ## get the object id from code
    object_id = SequenceMapper.to_decimal(code)
    template_name = template_name or 'base_shorturl_preview.html'

    info_dict = {
        'queryset': ShortURL.objects,
        'object_id': object_id,
        'template_name': template_name,
    }

    return list_detail.object_detail(request, **info_dict)
コード例 #52
0
def person_type_detail(request, slug, **kwargs):
    return list_detail.object_detail(
        request,
        queryset = PersonType.objects.all(),
        slug = slug,
        **kwargs
    )
コード例 #53
0
ファイル: views.py プロジェクト: AhmadSAnsari/techventory
def server_detail(request, object_id):
    return list_detail.object_detail(
        request,
        queryset=Server.objects.all(),
        template_name='techventory/server_detail.html',
        object_id=object_id,
    )
コード例 #54
0
ファイル: views.py プロジェクト: tieugene/tipython
def file_view(request, id):
    return object_detail(
        request,
        queryset=models.File.objects.all(),
        object_id=id,
        template_name='filer/view.html',
    )
コード例 #55
0
ファイル: views.py プロジェクト: ncrao/WebApps
def profile(request):
    """Show a user profile."""
    object_id = request.user.userprofile.id
    queryset = UserProfile.objects.all()
    return object_detail(request, queryset=queryset, object_id=object_id,
                         template_name='accounts/profile.html',
                         template_object_name='profile')
コード例 #56
0
ファイル: views.py プロジェクト: B-Rich/M2M
def place_detail(request, slug, **kwargs):
    return list_detail.object_detail(
        request,
        queryset = Place.objects.all(),
        slug = slug,
        **kwargs
    )
コード例 #57
0
def comic_strip_detail(request, strip_id):
    return list_detail.object_detail(
        request,
        ComicStrip.objects.filter(language=request.LANGUAGE_CODE),
        id=strip_id,
        template_object_name='comic_strip',
    )
コード例 #58
0
ファイル: views.py プロジェクト: tieugene/tipython
def	file_view(request, id):
        return  object_detail (
                request,
                queryset = models.File.objects.all(),
                object_id = id,
                template_name = 'core/file_view.html',
        )
コード例 #59
0
def photo_detail(request, project_id, photo_id):
    if not request.GET.get('ajax'):
        return project_overview(request, project_id)

    photo = Photo.objects.get(id=photo_id)
    info = get_exif(photo.fullurl()[1:])
    if info:
        dt = info.get('DateTime') or info.get('DateTimeOriginal') or info.get('DateTimeDigitized')
        if dt:
            dt = datetime.strptime(dt, '%Y:%m:%d %H:%M:%S')
        else:
            dt = None
    else:
        dt = None

    # Mode
    mode = project_getmode_helper(request, project_id)
    is_view_mode = mode == 'view'

    return object_detail(
        request, 
        Photo.objects.all(), 
        object_id=photo_id,
        template_object_name='photo', 
        template_name='stockphoto/photo_detail.html',
        extra_context={'project_id': project_id, 'datetime': dt, 'is_view_mode': is_view_mode}
    )