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


Python Log.create方法代码示例

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


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

示例1: clean_trash

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import create [as 别名]
def clean_trash(request):
    file_list = File.objects.filter(trashed=True)
    print "CLEAN ALL"
    for a in file_list:
        os.remove(os.path.realpath(os.path.dirname(__file__)) + "/media/" + a.file.name)
        a.delete()
        Log.create(request.user, "Permanently deleted a file", a, None).save()
    return HttpResponseRedirect("/trash/")
开发者ID:mariciabalayan,项目名称:DCS_Archiving_System2,代码行数:10,代码来源:views.py

示例2: trash

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import create [as 别名]
def trash(request):
    if request.method=="POST":
        file_list = File.objects.filter(trashed=True)
        for a in file_list:
            if request.POST.get(str(a.id))!=None:
                a.trashed=False
                a.save()
                Log.create(request.user, "Restored a file", a, None).save()
        return HttpResponseRedirect("/trash/")
    else:
        is_admin = request.user.is_staff
        file_list = File.objects.filter(trashed=True)
        return render_to_response('trash.html', {'user': request.user, 'file_list':file_list, 'is_admin':is_admin}, context_instance=RequestContext(request))
开发者ID:mariciabalayan,项目名称:DCS_Archiving_System2,代码行数:15,代码来源:views.py

示例3: request_delete

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import create [as 别名]
def request_delete(request, document_number):
    if request.method=="POST":
        doc= Dokument.objects.get(id= int(document_number))
        for k in doc.files.filter(trashed=False):
            if request.POST.get(str(k.id))!=None:
                k.trashed=1
            # else:
            #    k.trashed=0
                k.save()
                Log.create(request.user, "Deleted a file", k, doc).save()
        return HttpResponseRedirect("/records")
    else:
        doc= Dokument.objects.get(id= int(document_number))
        return render_to_response('request_delete.html', {'doc':doc})
开发者ID:mariciabalayan,项目名称:DCS_Archiving_System2,代码行数:16,代码来源:views.py

示例4: upload

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import create [as 别名]
def upload(request):
    if request.POST:
        userid = request.POST.get('userid')
        
        # Queries all non-expired sessions
        sessions = Session.objects.filter(expire_date__gte=datetime.now())

        # Checks if session is active
        for session in sessions:
            data = session.get_decoded()
            found_userid=data.get('_auth_user_id')

            # Prceeds when user id is validated
            if found_userid!=None and long(userid)==found_userid:
                user = User.objects.filter(id=userid)[0]
                faculty=None
                faculty=Faculty.objects.filter(id=request.POST.get('fid'))[0]
                transaction = Transaction.objects.get(id=request.POST.get('transaction'))
                document = Dokument()
                document.faculty= faculty
                document.transaction= transaction
                document.save()

                #Generates a random alphanum string for filename template
                while True:
                    fnameTemplate=''
                    fnameTemplate = ''.join(random.choice(string.ascii_lowercase))
                    fnameTemplate += ''.join(random.choice(string.ascii_lowercase + string.digits) for x in range(4)) + '_'
                    if len(File.objects.filter(filename__startswith = fnameTemplate))==0: break

                #Processes uploaded files, page by page
                for key in request.FILES:
                    files = request.FILES[key]
                    filename = fnameTemplate + key.split('_')[1] + '.bmp'
                    with open('DCSArchivingSystem/testapp/media/files/' + filename, 'wb+') as destination:
                        for chunk in files.chunks():
                            destination.write(chunk)
                        file = File()
                        file.filename = filename
                        file.file = 'files/' + filename
                        file.save()                    
                        document.files.add(file)
                    Log.create(user, "Uploaded file", file, document).save()    
                Log.create(user, "Created Document", None, document).save()    
                return HttpResponseRedirect("/dashboard/")
            
    else:
        return render_to_response('upload.html', context_instance=RequestContext(request))
开发者ID:mariciabalayan,项目名称:DCS_Archiving_System2,代码行数:50,代码来源:views.py

示例5: post

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import create [as 别名]
    def post(self, application_name):
        sender = self.request.get("sender")

        if not sender:
            sender = self.request.get("email")

        if not sender:
            sender = self.request.get("username")

        if not sender:
            sender = self.request.get("facebookId")

        if not sender:
            sender = self.request.get("fullname")

        log = Log.create(
            application_name,
            sender,
            self.request.get("body"),
            email=self.request.params.get("email"),
            facebookId=self.request.params.get("facebookId"),
            fullname=self.request.params.get("fullname"),
            username=self.request.params.get("username"))

        log.links = list(enum_request_files(log, self.get_file_infos()))

        log.put()
开发者ID:erlichmen,项目名称:jugoflogs,代码行数:29,代码来源:upload.py

示例6: log_in

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import create [as 别名]
def log_in(request):
    if request.user.is_authenticated():
        return render_to_response('dashboard.html', {'user': request.user})
    state = ""
    username = password = ''
    if request.POST:
        username = request.POST.get('username')
        password = request.POST.get('password')
        user = authenticate(username=username, password=password)
        if user is not None:
            if user.is_active:
                login(request, user)
                state = "Login ok!"
                Log.create(user, "Logged in", None, None).save()
                return HttpResponseRedirect("/dashboard/")
            else:
                state = "Account not active."
        else:
            state = "* Wrong username or password."

    return render_to_response('login.html',RequestContext(request, {'state':state}))
开发者ID:mariciabalayan,项目名称:DCS_Archiving_System2,代码行数:23,代码来源:views.py

示例7: change

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import create [as 别名]
def change(request, document_number):
    doc= Dokument.objects.get(id=int(document_number))
    prevfaculty = doc.faculty
    users_list= Faculty.objects.all()
    if request.method=='POST':
        faculty= request.POST.get('faculty')
        current_faculty = faculty
        faculty_name= faculty
        faculty= faculty.replace(',', "")
        for person in users_list:
            if faculty.split(' ')[0]==person.last_name: 
                for k in faculty.split(' '):
                    if k== person.last_name: continue
                    elif k not in person.first_name: break
                    doc.faculty_id=person.id
        doc.save()
        Log.create(request.user, "Changed owenership of a record owned by " + str(prevfaculty) + " to " + str(current_faculty), None, doc).save()
        return HttpResponseRedirect("/records")
    else:
        print 'hi'
        faculty_list= Faculty.objects.all()
        return render_to_response('change.html', {'doc':doc, 'faculty_list':faculty_list})
开发者ID:mariciabalayan,项目名称:DCS_Archiving_System2,代码行数:24,代码来源:views.py

示例8: store_email

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import create [as 别名]
    def store_email(cls, app_name, body):
        message = mail.InboundEmailMessage(body)
        message_id = message.original.get("Message-Id")
        parent_id = message.original.get("In-Reply-To")

        _, body = message.bodies("text/plain").next()

        created_at = parser.parse(message.date)
        created_at = created_at.replace(tzinfo=None)

        log = Log.create(
            app_name,
            message.sender,
            body,
            created_at=created_at,
            message_id=message_id,
            parent_id=parent_id)

        log.links = list(enum_message_files(log, message))

        log.put()
开发者ID:erlichmen,项目名称:jugoflogs,代码行数:23,代码来源:handle_incoming_email.py

示例9: restore

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import create [as 别名]
def restore(request, file_number):
    file = File.objects.get(id=int(file_number))
    file.trashed = False
    file.save()
    Log.create(request.user, "Restored a file", file, None).save()
    return HttpResponseRedirect("/trash/")
开发者ID:mariciabalayan,项目名称:DCS_Archiving_System2,代码行数:8,代码来源:views.py

示例10: log_out

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import create [as 别名]
def log_out(request):
    Log.create(request.user, "Logged out", None, None).save()
    logout(request)
    return HttpResponseRedirect('/')
开发者ID:mariciabalayan,项目名称:DCS_Archiving_System2,代码行数:6,代码来源:views.py


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