当前位置: 首页>>代码示例>>Python>>正文


Python Core.current_user方法代码示例

本文整理汇总了Python中core.Core.current_user方法的典型用法代码示例。如果您正苦于以下问题:Python Core.current_user方法的具体用法?Python Core.current_user怎么用?Python Core.current_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.Core的用法示例。


在下文中一共展示了Core.current_user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_update_mails

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
def send_update_mails(ticket, ticket_update):
    """
    Sends email to all users who commented or created ticket
    """
    assigned_sent = check_assigned_to(ticket)

    recipients = set([])

    if not ticket.mailbox_hash:

        ticket.mailbox_hash = hashlib.sha224("ticket-%s"%ticket.id).hexdigest()
        ticket.save()

    if ticket.assigned_to:
        if ticket.assigned_to.email:
            recipients.add(ticket.assigned_to.email)

    if not assigned_sent and ticket.assigned_to:
        if ticket.assigned_to.email in recipients:
            recipients.remove(ticket.assigned_to.email)

    for recipient in ticket.get_recipients():
        if recipient.email:
            recipients.add(recipient.email)

    if Core.current_user().email:
        if Core.current_user().email in recipients:
            recipients.remove(Core.current_user().email)

    if ticket_update.public and ticket_update.comment:
        _send_to_clients(ticket, ticket_update)

    msg = _create_msg(ticket, ticket_update)
    send_mail(_("Ticket update"), msg, "support+"+ticket.mailbox_hash+"@focustime.no", recipients)
开发者ID:frecar,项目名称:focus,代码行数:36,代码来源:utils.py

示例2: products

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
def products(request, id):
    supplier = Core.current_user().get_permitted_objects("VIEW", Supplier).get(id=id)
    products = Core.current_user().get_permitted_objects("VIEW", Product).filter(supplier=supplier)

    return render(request, 'suppliers/products.html', {'title': _("Products"),
                                                       'supplier': supplier,
                                                       'products': products})
开发者ID:frecar,项目名称:focus,代码行数:9,代码来源:views.py

示例3: form

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
def form (request, id=False):
    if id:
        instance = Core.current_user().get_permitted_objects("VIEW", Group).get(id=id)
        msg = _("Successfully edited group")
    else:
        instance = Group()
        msg = _("Successfully added new group")

    #Save and set to active, require valid form
    if request.method == 'POST':
        form = GroupForm(request.POST, instance=instance)
        if form.is_valid():
            o = form.save(commit=False)
            o.company = Core.current_user().get_company()
            o.save()
            form.save_m2m()

            request.message_success(msg)
            return redirect(overview)

    else:
        form = GroupForm(instance=instance)

    return render(request, "admin/groups/form.html",
                  {'title': _("Group"), 'group': instance, 'form': form})
开发者ID:frecar,项目名称:focus,代码行数:27,代码来源:group.py

示例4: is_authenticated

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
    def is_authenticated(self, request):
        #Check if already logged in, for use inside the application
        if Core.current_user() and Core.current_user().is_authenticated():
            return True

        #If not, then use basic auth
        else:
            auth_string = request.META.get('HTTP_AUTHORIZATION', None)

            if not auth_string:
                return False

            (authmeth, auth) = auth_string.split(" ", 1)

            if not authmeth.lower() == 'basic':
                return False

            auth = auth.strip().decode('base64')
            (username, password) = auth.split(':', 1)

            if Core.login(request, username, password):
                user = User.objects.get(username=username)
                return user.canLogin

        return False
开发者ID:frecar,项目名称:focus,代码行数:27,代码来源:authentication.py

示例5: handle

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
    def handle(self, *args, **kwargs):
        randomCompanyIdentifier = str(int(random.random() * 99999))

        company, user = createNewCustomer(
            "Ledere",
            "Bjarte Hatlenes",
            "superadmin" + randomCompanyIdentifier,
            "superadmin" + randomCompanyIdentifier,
            "Ansatte",
            "Focus Security AS" + randomCompanyIdentifier,
        )

        self.company = company
        self.user = user

        Core.set_test_user(user)
        password = generate_new_password_for_user(user)
        print "Company: %s " % company
        print "Current user is: %s " % Core.current_user()
        print "Current user is: %s " % Core.current_user().username
        print "Current users password: %s " % password

        self.customers = []
        self.projects = []

        self.seed_customers()
        self.seed_contacts()
        self.seed_projects()
        self.seed_orders()
        self.seed_offers()
        self.seed_tickets()
        self.seed_suppliers()
        self.seed_products()
开发者ID:frecar,项目名称:focus,代码行数:35,代码来源:seed.py

示例6: filter_current_company

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
    def filter_current_company(self):

        #Check if no current_user
        if not Core.current_user():
            return None
        
        return super(PersistentManager, self).get_query_set().filter(deleted=False,
                                                                     company=Core.current_user().get_company())
开发者ID:frecar,项目名称:focus,代码行数:10,代码来源:managers.py

示例7: save

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
    def save(self, *args, **kwargs):
        self.date = datetime.now()

        if 'user' in kwargs:
            self.creator = kwargs['user']
        else:
            self.creator = Core.current_user()

        if Core.current_user() and Core.current_user().get_company():
            self.company = Core.current_user().get_company()
            
        super(Log, self).save()
开发者ID:frecar,项目名称:focus,代码行数:14,代码来源:models.py

示例8: update

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
    def update(self, request, id=None):

        if id:
            trackers = [Core.current_user().get_permitted_objects("EDIT", TimeTracker).get(id=id)]
        else:
            trackers = Core.current_user().get_permitted_objects("EDIT", TimeTracker).all()
        for tracker in trackers:
            try:
                self._do_update(request, tracker)
            except ValueError as e:
                return {'error': str(e)}

        return {'success': True}
开发者ID:frecar,项目名称:focus,代码行数:15,代码来源:handlers.py

示例9: save

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
    def save(self, *args, **kwargs):
        new = False
        if not self.id:
            new = True

        super(Project, self).save()

        self.invalidate_cache()
        
        #Give the user who created this ALL permissions on object
        if new:
            Core.current_user().grant_role("Owner", self)
            admin_group = Core.current_user().get_company_admingroup()

            if admin_group:
                admin_group.grant_role("Admin", self)
开发者ID:frecar,项目名称:focus,代码行数:18,代码来源:models.py

示例10: disbursements

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
def disbursements(request, id=None):
    instance = Disbursement()
    disb = Disbursement.objects.filter(trashed=False, creator=Core.current_user())

    if id:
        instance = get_object_or_404(Disbursement, id=id)

    #Save and set to active, require valid form
    if request.method == 'POST':
        form = DisbursementForm(request.POST, request.FILES, instance=instance)
        if form.is_valid():
            o = form.save(commit=False)
            o.save()

            request.message_success("Success")

            instance = Disbursement()
            form = DisbursementForm(instance=instance, initial={'attachment': None})

    else:
        form = DisbursementForm(instance=instance, initial={'attachment': None})


    return render(request, "hourregistrations/disbursements.html",
            {'title': _("Disbursements"), 'disbursements': disb, 'disbursement': instance, 'form': form})
开发者ID:frecar,项目名称:focus,代码行数:27,代码来源:views.py

示例11: edit

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
def edit(request, id):
    ticket = Core.current_user().get_permitted_objects("VIEW", Ticket).get(id=id)
    updates = TicketUpdate.objects.filter(ticket=ticket).order_by("-id")

    #ticket.visited_by_since_last_edit.add((Core.current_user()))

    if request.method == "POST":
        old_ticket = copy.copy(ticket)
        ticket_form = EditTicketForm(request.POST, request.FILES, instance=ticket)

        if ticket_form.is_valid():
            ticket = create_update_for_ticket(old_ticket, ticket_form)

            ticket.invalidate_cache()

            request.message_success(_("Ticket updated"))

            return redirect(edit, ticket.id)

    else:
        ticket_form = EditTicketForm(instance=ticket)

    return render(request, "tickets/edit.html", {'title': _('Update Ticket'),
                                                 'ticket': ticket,
                                                 'updates': updates,
                                                 'form': ticket_form,
                                                 })
开发者ID:frecar,项目名称:focus,代码行数:29,代码来源:views.py

示例12: assigned_to_user

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
def assigned_to_user(request):
    tickets = Core.current_user().get_permitted_objects("VIEW", Ticket).\
    filter(trashed=False, assigned_to=request.user).order_by("status", "-priority", "-date_edited")

    return render(request, 'tickets/list.html', {"title": "Tickets",
                                                 "assigned_to": True,
                                                 'tickets': tickets})
开发者ID:frecar,项目名称:focus,代码行数:9,代码来源:views.py

示例13: process_request

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
    def process_request (self, request):

        # Save the current thread with the current user
        Core.attach_user(request)
        request.user = Core.current_user()

        return None
开发者ID:frecar,项目名称:focus,代码行数:9,代码来源:middleware.py

示例14: overview_trashed

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
def overview_trashed(request):
    tickets = Core.current_user().get_permitted_objects("VIEW", Ticket).filter(trashed=True).order_by("status",
                                                                                                      "-priority",
                                                                                                      "-date_edited")

    return render(request, 'tickets/list.html',
            {"title": "Tickets", 'tickets': tickets})
开发者ID:frecar,项目名称:focus,代码行数:9,代码来源:views.py

示例15: delete

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import current_user [as 别名]
 def delete(self, request, id):
     try:
         tracker = Core.current_user().get_permitted_objects("EDIT", TimeTracker).get(id=id)
         tracker.trash()
         return rc.DELETED
     except TimeTracker.DoesNotExist:
         return rc.NOT_FOUND
开发者ID:frecar,项目名称:focus,代码行数:9,代码来源:handlers.py


注:本文中的core.Core.current_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。