本文整理汇总了Python中treeio.core.models.Object类的典型用法代码示例。如果您正苦于以下问题:Python Object类的具体用法?Python Object怎么用?Python Object使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Object类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, user, project_id, *args, **kwargs):
super(ProjectForm, self).__init__(*args, **kwargs)
self.fields['name'].label = _("Name")
self.fields['parent'].queryset = Object.filter_permitted(
user, Project.objects, mode='x')
self.fields['parent'].label = _("Parent")
if project_id:
self.fields['parent'].initial = project_id
self.fields['manager'].queryset = Object.filter_permitted(
user, Contact.objects, mode='x')
self.fields['manager'].label = _("Manager")
self.fields['manager'].widget.attrs.update({'class': 'autocomplete',
'callback': reverse('identities_ajax_contact_lookup')})
self.fields['manager'].widget.attrs.update(
{'popuplink': reverse('identities_contact_add')})
self.fields['client'].label = _("Client")
self.fields['client'].queryset = Object.filter_permitted(
user, Contact.objects, mode='x')
self.fields['client'].widget.attrs.update({'class': 'autocomplete',
'callback': reverse('identities_ajax_contact_lookup')})
self.fields['client'].widget.attrs.update(
{'popuplink': reverse('identities_contact_add')})
self.fields['details'].label = _("Details")
开发者ID:5n1p,项目名称:treeio,代码行数:28,代码来源:forms.py
示例2: folder_view
def folder_view(request, folder_id, response_format='html'):
"Single folder view page"
folder = get_object_or_404(Folder, pk=folder_id)
if not request.user.get_profile().has_permission(folder):
return user_denied(request, message="You don't have access to this Folder")
query = Q(
object_type='treeio.documents.models.Document') | Q(
object_type='treeio.documents.models.File') | Q(
object_type='treeio.documents.models.WebLink')
query = query & (Q(document__folder=folder) | Q(file__folder=folder) | Q(weblink__folder=folder))
if request.GET:
query = query & _get_filter_query(request.GET)
objects = Object.filter_by_request(request, Object.objects.filter(query).order_by('-last_updated'))
# objects = objects.order_by('-last_updated')
else:
objects = Object.filter_by_request(request, Object.objects.filter(query).order_by('-last_updated'))
# objects = objects.order_by('-last_updated')
subfolders = Folder.objects.filter(parent=folder)
filters = FilterForm(request.user.get_profile(), 'title', request.GET)
context = _get_default_context(request)
context.update({'folder': folder,
'objects':objects,
'subfolders':subfolders,
'filters':filters})
return render_to_response('documents/folder_view', context,
context_instance=RequestContext(request),
response_format=response_format)
开发者ID:3atmospheres,项目名称:treeio,代码行数:34,代码来源:views.py
示例3: __init__
def __init__(self, user, *args, **kwargs):
"Sets choices and initial value"
super(SettingsForm, self).__init__(*args, **kwargs)
self.fields['my_company'].queryset = Object.filter_permitted(user, Contact.objects)
self.fields['my_company'].widget.attrs.update({'class': 'autocomplete',
'callback': reverse('identities_ajax_contact_lookup')})
self.fields['default_account'].queryset = Object.filter_permitted(user, Account.objects)
# Translation
self.fields['default_currency'].label=_('Base Currency')
self.fields['my_company'].label=_('My Company')
self.fields['default_account'].label=_('Default Account')
try:
self.fields['default_currency'].widget.attrs.update({'popuplink': reverse('finance_currency_add')})
self.fields['default_currency'].queryset = Currency.objects.all()
self.fields['default_currency'].initial = Currency.objects.get(is_default=True)
except Exception:
pass
try:
conf = ModuleSetting.get_for_module('treeio.finance', 'my_company')[0]
my_company = Contact.objects.get(pk=long(conf.value))
self.fields['my_company'].initial = my_company.id
except Exception:
pass
try:
conf = ModuleSetting.get_for_module('treeio.finance', 'default_account')[0]
default_account = Account.objects.get(pk=long(conf.value))
self.fields['default_account'].initial = default_account.id
except Exception:
pass
开发者ID:3atmospheres,项目名称:treeio,代码行数:34,代码来源:forms.py
示例4: queue_delete
def queue_delete(request, queue_id, response_format='html'):
"Queue delete"
queue = get_object_or_404(TicketQueue, pk=queue_id)
if not request.user.get_profile().has_permission(queue, mode='w'):
return user_denied(request, message="You don't have access to this Queue")
if request.POST:
if 'delete' in request.POST:
if 'trash' in request.POST:
queue.trash = True
queue.save()
else:
queue.delete()
return HttpResponseRedirect(reverse('services_settings_view'))
elif 'cancel' in request.POST:
return HttpResponseRedirect(reverse('services_queue_view', args=[queue.id]))
query = Q(queue=queue) & Q(status__hidden=False)
tickets = Object.filter_by_request(request, Ticket.objects.filter(query))
subqueues = Object.filter_by_request(
request, TicketQueue.objects.filter(parent=queue))
context = _get_default_context(request)
context.update({'queue': queue,
'subqueues': subqueues,
'tickets': tickets})
return render_to_response('services/queue_delete', context,
context_instance=RequestContext(request), response_format=response_format)
开发者ID:AlexLX2,项目名称:treeio,代码行数:30,代码来源:views.py
示例5: index
def index(request, response_format='html'):
"Messaging index page"
query = Q(reply_to__isnull=True)
streams = False
st = MessageStream.objects.all()
for row in st:
if request.user.get_profile().has_permission(row):
if streams: streams = streams | Q(stream=row)
else: streams = Q(stream=row)
if streams: query = query & streams
if request.GET:
query = query & _get_filter_query(request.GET)
messages = Object.filter_by_request(request, Message.objects.filter(query))
else:
messages = Object.filter_by_request(request, Message.objects.filter(query))
filters = FilterForm(request.user.get_profile(), 'title', request.GET)
context = _get_default_context(request)
context.update({'filters': filters,
'messages': messages})
return render_to_response('messaging/index', context,
context_instance=RequestContext(request),
response_format=response_format)
开发者ID:jmfield2,项目名称:treeio,代码行数:30,代码来源:views.py
示例6: index_in_progress
def index_in_progress(request, response_format='html'):
"A page with a list of tasks in progress"
query = Q(parent__isnull=True)
if request.GET:
query = query & Q(
status__hidden=False) & _get_filter_query(request.GET)
else:
query = query & Q(status__hidden=False)
tasks = Object.filter_by_request(request, Task.objects.filter(query))
milestones = Object.filter_by_request(
request, Milestone.objects.filter(status__hidden=False))
filters = FilterForm(request.user.get_profile(), 'status', request.GET)
time_slots = Object.filter_by_request(
request, TaskTimeSlot.objects.filter(time_from__isnull=False, time_to__isnull=True))
context = _get_default_context(request)
context.update({'milestones': milestones,
'tasks': tasks,
'filters': filters,
'time_slots': time_slots})
return render_to_response('projects/index_in_progress', context,
context_instance=RequestContext(request), response_format=response_format)
开发者ID:5n1p,项目名称:treeio,代码行数:26,代码来源:views.py
示例7: contact_view
def contact_view(request, contact_id, attribute='', response_format='html'):
"Contact view"
contact = get_object_or_404(Contact, pk=contact_id)
if not request.user.get_profile().has_permission(contact):
return user_denied(request, message="You don't have access to this Contact")
types = Object.filter_by_request(request, ContactType.objects.order_by('name'))
subcontacts = Object.filter_by_request(request, contact.child_set)
contact_values = contact.contactvalue_set.order_by('field__name')
objects = get_contact_objects(request.user.get_profile(), contact, preformat=True)
module = None
for key in objects:
if not attribute:
if objects[key]['count']:
#attribute = objects[key]['objects'].keys()[0]
module = objects[key]['module']
else:
if attribute in objects[key]['objects'].keys():
module = objects[key]['module']
break
return render_to_response('identities/contact_view',
{'contact': contact,
'subcontacts': subcontacts,
'objects': objects,
'current_module': module,
'attribute': attribute,
'types': types,
'contact_values': contact_values},
context_instance=RequestContext(request), response_format=response_format)
开发者ID:BenoitNorrin,项目名称:treeio,代码行数:33,代码来源:views.py
示例8: index_by_status
def index_by_status(request, status_id, response_format='html'):
"Sort tasks by status"
status = get_object_or_404(TaskStatus, pk=status_id)
if not request.user.get_profile().has_permission(status):
return user_denied(request, message="You don't have access to this Task Status")
query = Q(parent__isnull=True, status=status)
if request.GET:
query = query & _get_filter_query(request.GET)
tasks = Object.filter_by_request(request, Task.objects.filter(query))
milestones = Object.filter_by_request(
request, Milestone.objects.filter(task__status=status).distinct())
filters = FilterForm(request.user.get_profile(), 'status', request.GET)
context = _get_default_context(request)
context.update({'milestones': milestones,
'tasks': tasks,
'status': status,
'filters': filters})
return render_to_response('projects/index_by_status', context,
context_instance=RequestContext(request), response_format=response_format)
开发者ID:5n1p,项目名称:treeio,代码行数:25,代码来源:views.py
示例9: __init__
def __init__(self, user, *args, **kwargs):
"Sets allowed values"
super(QueueForm, self).__init__(*args, **kwargs)
manager = TicketQueue.objects
if 'instance' in kwargs:
instance = kwargs['instance']
manager = manager.exclude(Q(parent=instance) & Q(pk=instance.id))
self.fields['parent'].queryset = Object.filter_permitted(
user, manager, mode='x')
self.fields['default_service'].queryset = Object.filter_permitted(
user, Service.objects, mode='x')
self.fields['waiting_time'].help_text = "seconds"
self.fields['name'].label = _("Name")
self.fields['active'].label = _("Active")
self.fields['parent'].label = _("Parent")
self.fields['default_ticket_status'].label = _("Default ticket status")
self.fields['default_ticket_priority'].label = _(
"Default ticket priority")
self.fields['default_service'].label = _("Default service")
self.fields['waiting_time'].label = _("Waiting time")
self.fields['next_queue'].queryset = Object.filter_permitted(
user, TicketQueue.objects, mode='x')
self.fields['next_queue'].label = _("Next queue")
self.fields['ticket_code'].label = _("Ticket code")
self.fields['message_stream'].label = _("Message stream")
self.fields['message_stream'].widget.attrs.update(
{'popuplink': reverse('messaging_stream_add')})
self.fields['details'].label = _("Details")
开发者ID:AlexLX2,项目名称:treeio,代码行数:32,代码来源:forms.py
示例10: __init__
def __init__(self, user, parent=None, *args, **kwargs):
super(ProductForm, self).__init__(*args, **kwargs)
self.fields['supplier'].queryset = Object.filter_permitted(user, Contact.objects)
self.fields['supplier'].widget.attrs.update({'class': 'autocomplete',
'callback': reverse('identities_ajax_contact_lookup')})
self.fields['supplier'].widget.attrs.update({'popuplink': reverse('identities_contact_add')})
self.fields['supplier'].label = _("Supplier")
self.fields['active'].initial = True
self.fields['active'].label = _("Active")
manager = Product.objects.filter(active=True)
if 'instance' in kwargs:
instance = kwargs['instance']
manager = manager.exclude(Q(parent=instance) & Q(pk=instance.id))
self.fields['parent'].queryset = Object.filter_permitted(user, manager, mode='x')
if parent:
self.fields['parent'].initial = get_object_or_404(Product, pk=parent)
self.fields['parent'].label = _("Parent")
self.fields['product_type'].label = _("Product type")
self.fields['code'].label = _("Code")
self.fields['supplier_code'].label = _("Supplier code")
self.fields['buy_price'].label = _("Buy price")
self.fields['sell_price'].label = _("Sell price")
self.fields['stock_quantity'].label = _("Stock quantity")
self.fields['runout_action'].label = _("Runout action")
self.fields['details'].label = _("Details")
开发者ID:MechanisM,项目名称:treeio,代码行数:29,代码来源:forms.py
示例11: index
def index(request, response_format='html'):
"Project Management index page"
query = Q(parent__isnull=True)
if request.GET:
if 'status' in request.GET and request.GET['status']:
query = query & _get_filter_query(request.GET)
else:
query = query & Q(
status__hidden=False) & _get_filter_query(request.GET)
else:
query = query & Q(status__hidden=False)
tasks = Object.filter_by_request(request, Task.objects.filter(query))
milestones = Object.filter_by_request(
request, Milestone.objects.filter(status__hidden=False))
filters = FilterForm(request.user.get_profile(), '', request.GET)
context = _get_default_context(request)
context.update({'milestones': milestones,
'tasks': tasks,
'filters': filters})
return render_to_response('projects/index', context,
context_instance=RequestContext(request), response_format=response_format)
开发者ID:5n1p,项目名称:treeio,代码行数:25,代码来源:views.py
示例12: get_events
def get_events(request):
"Return a list of EventRenderers from available Tasks and Milestones"
events = []
query = (Q(start_date__isnull=False) | Q(end_date__isnull=False)) & Q(
status__hidden=False)
tasks = Object.filter_by_request(
request, manager=Task.objects.filter(query))
for task in tasks:
if task.end_date:
event = EventRenderer(
task.name, task.start_date, task.end_date, task.get_absolute_url())
else:
event = EventRenderer(
task.name, None, task.start_date, task.get_absolute_url())
event.css_class += " projects-calendar-task"
events.append(event)
query = (Q(start_date__isnull=False) | Q(end_date__isnull=False)) & Q(
status__hidden=False)
milestones = Object.filter_by_request(
request, manager=Milestone.objects.filter(query))
for milestone in milestones:
name = " " + milestone.name
if milestone.end_date:
event = EventRenderer(name, milestone.start_date, milestone.end_date,
milestone.get_absolute_url())
else:
event = EventRenderer(
name, None, milestone.start_date, milestone.get_absolute_url())
event.css_class += " projects-calendar-milestone"
events.append(event)
return events
开发者ID:5n1p,项目名称:treeio,代码行数:34,代码来源:events.py
示例13: queue_view
def queue_view(request, queue_id, response_format='html'):
"Queue view"
queue = get_object_or_404(TicketQueue, pk=queue_id)
if not request.user.get_profile().has_permission(queue):
return user_denied(request, message="You don't have access to this Queue")
query = Q(queue=queue)
if request.GET:
if 'status' in request.GET and request.GET['status']:
query = query & _get_filter_query(request.GET)
else:
query = query & Q(
status__hidden=False) & _get_filter_query(request.GET)
else:
query = query & Q(status__hidden=False)
tickets = Object.filter_by_request(request, Ticket.objects.filter(query))
filters = FilterForm(request.user.get_profile(), 'queue', request.GET)
subqueues = Object.filter_by_request(
request, TicketQueue.objects.filter(parent=queue))
context = _get_default_context(request)
context.update({'queue': queue,
'subqueues': subqueues,
'filters': filters,
'tickets': tickets})
return render_to_response('services/queue_view', context,
context_instance=RequestContext(request), response_format=response_format)
开发者ID:AlexLX2,项目名称:treeio,代码行数:30,代码来源:views.py
示例14: task_time_slot_add
def task_time_slot_add(request, task_id, response_format='html'):
"Time slot add to preselected task"
task = get_object_or_404(Task, pk=task_id)
if not request.user.get_profile().has_permission(task, mode='x'):
return user_denied(request, message="You don't have access to this Task")
if request.POST:
task_time_slot = TaskTimeSlot(
task=task, time_to=datetime.now(), user=request.user.get_profile())
form = TaskTimeSlotForm(
request.user.get_profile(), task_id, request.POST, instance=task_time_slot)
if 'cancel' in request.POST:
return HttpResponseRedirect(reverse('projects_task_view', args=[task.id]))
elif form.is_valid():
task_time_slot = form.save()
task_time_slot.set_user_from_request(request)
return HttpResponseRedirect(reverse('projects_task_view', args=[task.id]))
else:
form = TaskTimeSlotForm(request.user.get_profile(), task_id)
subtasks = Object.filter_by_request(
request, Task.objects.filter(parent=task))
time_slots = Object.filter_by_request(
request, TaskTimeSlot.objects.filter(task=task))
context = _get_default_context(request)
context.update({'form': form,
'task': task,
'subtasks': subtasks,
'time_slots': time_slots})
return render_to_response('projects/task_time_add', context,
context_instance=RequestContext(request), response_format=response_format)
开发者ID:5n1p,项目名称:treeio,代码行数:34,代码来源:views.py
示例15: task_delete
def task_delete(request, task_id, response_format='html'):
"Task delete"
task = get_object_or_404(Task, pk=task_id)
if not request.user.get_profile().has_permission(task, mode='w'):
return user_denied(request, message="You don't have access to this Task")
if request.POST:
if 'delete' in request.POST:
if 'trash' in request.POST:
task.trash = True
task.save()
else:
task.delete()
return HttpResponseRedirect(reverse('projects_index'))
elif 'cancel' in request.POST:
return HttpResponseRedirect(reverse('projects_task_view', args=[task.id]))
subtasks = Object.filter_by_request(
request, Task.objects.filter(parent=task))
time_slots = Object.filter_by_request(
request, TaskTimeSlot.objects.filter(task=task))
context = _get_default_context(request)
context.update({'task': task,
'subtasks': subtasks,
'time_slots': time_slots})
return render_to_response('projects/task_delete', context,
context_instance=RequestContext(request), response_format=response_format)
开发者ID:5n1p,项目名称:treeio,代码行数:30,代码来源:views.py
示例16: project_view
def project_view(request, project_id, response_format='html'):
"Single project view page"
project = get_object_or_404(Project, pk=project_id)
if not request.user.get_profile().has_permission(project):
return user_denied(request, message="You don't have access to this Project")
query = Q(parent__isnull=True, project=project)
if request.GET:
if 'status' in request.GET and request.GET['status']:
query = query & _get_filter_query(request.GET)
else:
query = query & Q(status__hidden=False) & _get_filter_query(request.GET)
else:
query = query & Q(status__hidden=False)
if request.user.get_profile().has_permission(project, mode='r'):
if request.POST:
record = UpdateRecord()
record.record_type = 'manual'
form = TaskRecordForm(request.user.get_profile(), request.POST, instance=record)
if form.is_valid():
record = form.save()
record.set_user_from_request(request)
record.save()
record.about.add(project)
project.set_last_updated()
return HttpResponseRedirect(reverse('projects_project_view', args=[project.id]))
else:
form = TaskRecordForm(request.user.get_profile())
else:
form = None
tasks = Object.filter_by_request(request, Task.objects.filter(query))
tasks_progress = float(0)
tasks_progress_query = Object.filter_by_request(request, Task.objects.filter(Q(parent__isnull=True, project=project)))
if tasks_progress_query:
for task in tasks_progress_query:
if not task.status.active:
tasks_progress += 1
tasks_progress = (tasks_progress / len(tasks_progress_query)) * 100
tasks_progress = round(tasks_progress, ndigits=1)
filters = FilterForm(request.user.get_profile(), 'project', request.GET)
milestones = Object.filter_by_request(request,
Milestone.objects.filter(project=project).filter(status__hidden=False))
subprojects = Project.objects.filter(parent=project)
context = _get_default_context(request)
context.update({'project': project,
'milestones': milestones,
'tasks':tasks,
'tasks_progress':tasks_progress,
'record_form':form,
'subprojects':subprojects,
'filters': filters})
return render_to_response('projects/project_view', context,
context_instance=RequestContext(request), response_format=response_format)
开发者ID:appost,项目名称:treeio,代码行数:60,代码来源:views.py
示例17: _find_duplicates
def _find_duplicates(resource_id, item, user):
"Finds matching items"
dups = []
item_id = None
if 'id' in item.raw:
item_id = item.id.raw
# Finding previously syncd items
if item_id:
key = '#' + unicode(resource_id) + '.' + unicode(item_id) + '#'
dups = Object.filter_permitted(user, Contact.objects).filter(
nuvius_resource__contains=key)
if dups:
return dups
# Finding equivalent items
# If name and (email or phone) are the same - it's same person
if item.name:
candidates = Object.filter_permitted(
user, Contact.objects).filter(name=item.name.raw).distinct()
dups = []
if candidates and (item.email or item.phone):
for candidate in candidates:
matching_emails = []
emails = candidate.contactvalue_set.filter(
field__field_type='email')
if item.email.raw and emails:
matching_emails = emails.filter(value__in=item.email.raw)
phones = candidate.contactvalue_set.filter(
field__field_type='phone')
matching_phones = []
if item.phone.raw and phones:
matching_phones = phones.filter(value__in=item.phone.raw)
# If anything matches or if we have no emails or no phones at
# all - add to duplicates
if matching_emails or matching_phones or (not emails and not phones):
dups.append(candidate)
elif not candidates and (item.email or item.phone):
query = Q()
if item.email:
query = query & Q(contactvalue__value__in=item.email.raw)
if item.phone:
query = query | Q(contactvalue__value__in=item.phone.raw)
dups = Object.filter_permitted(
user, Contact.objects).filter(query).distinct()
else:
dups = candidates
elif item.email or item.phone:
query = Q()
if item.email:
query = query & Q(contactvalue__value__in=item.email.raw)
if item.phone:
query = query & Q(contactvalue__value__in=item.phone.raw)
dups = Object.filter_permitted(user, Contact.objects).filter(query)
return dups
开发者ID:5n1p,项目名称:treeio,代码行数:57,代码来源:integration.py
示例18: _get_default_context
def _get_default_context(request):
"Returns default context as a dict()"
projects = Object.filter_by_request(request, Project.objects)
statuses = Object.filter_by_request(request, TaskStatus.objects)
massform = MassActionForm(request.user.get_profile())
context = {'projects': projects,
'statuses': statuses,
'massform': massform}
return context
开发者ID:5n1p,项目名称:treeio,代码行数:12,代码来源:views.py
示例19: __init__
def __init__(self, user, *args, **kwargs):
super(ItemTypeForm, self).__init__(*args, **kwargs)
self.fields["name"].label = _("Name")
self.fields["parent"].label = _("Parent")
self.fields["fields"].label = _("Fields")
self.fields["details"].label = _("Details")
self.fields["fields"].queryset = Object.filter_permitted(user, ItemField.objects.all(), mode="x")
self.fields["fields"].help_text = ""
self.fields["parent"].queryset = Object.filter_permitted(
user, ItemType.objects.all().exclude(pk=self.instance.id), mode="x"
)
开发者ID:ctburley,项目名称:treeio,代码行数:14,代码来源:forms.py
注:本文中的treeio.core.models.Object类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论