Beispiel #1
0
 def __init__(self, user, order, *args, **kwargs):
     
     super(OrderedProductForm, self).__init__(*args, **kwargs)
     
     self.fields['subscription'].queryset = Object.filter_permitted(user, Subscription.objects)
     self.fields['subscription'].widget.attrs.update({'class': 'autocomplete',
                                                      'callback': reverse('sales_ajax_subscription_lookup')})
     self.fields['subscription'].widget.attrs.update({'popuplink': reverse('sales_subscription_add')})
     self.fields['subscription'].label = _("Subscription")
     
     self.fields['product'].queryset = Object.filter_permitted(user, Product.objects.filter(active=True))
     if user.is_admin('treeio.sales'):
         self.fields['product'].widget.attrs.update({'popuplink': reverse('sales_product_add')})
         self.fields['product'].label = _("Product")
     
     try:
         conf = ModuleSetting.get_for_module('treeio.sales', 'default_order_product')[0]
         # AJAX to set the initial rate as the currency converted value of product sell price 
         self.fields['product'].initial = long(conf.value)
     except:
         pass
     
     # Tax
     self.fields['tax'].widget.attrs.update({'popuplink': reverse('finance_tax_add')})
     
     # TODO: rate
     #  self.fields['rate_display'].label = _("Rate")
     #  self.fields['rate_display'].help_text = order.currency.code
     
     self.fields['quantity'].label = _("Quantity")
     self.fields['quantity'].initial = 1
     self.fields['discount'].label = _("Discount")
     self.fields['discount'].help_text = "%"
Beispiel #2
0
    def __init__(self, user, skip=[], *args, **kwargs):
        super(OrderFilterForm, self).__init__(*args, **kwargs)

        if 'status' in skip:
            del self.fields['status']
        else:
            self.fields['status'].queryset = Object.filter_permitted(user,
                                                                     SaleStatus.objects.filter(use_sales=True))
            self.fields['status'].required = False
            self.fields['status'].label = _("Status")

        self.fields['paid'].label = _("Payment Status")

        self.fields['client'].queryset = Object.filter_permitted(
            user, Contact.objects)
        self.fields['client'].widget.attrs.update({'class': 'autocomplete',
                                                   'callback': reverse('identities_ajax_contact_lookup')})
        self.fields['client'].required = False
        self.fields['client'].label = _("Client")

        self.fields['source'].queryset = Object.filter_permitted(
            user, SaleSource.objects.filter(active=True))
        self.fields['source'].required = False
        self.fields['source'].label = _("Source")

        self.fields['assigned'].label = _("Assigned")
        self.fields['assigned'].widget.attrs.update({'class': 'multicomplete',
                                                     'callback': reverse('identities_ajax_user_lookup')})
        if 'assigned' in skip:
            del self.fields['assigned']
        else:
            self.fields['assigned'].help_text = ""
Beispiel #3
0
 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")
Beispiel #4
0
    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")
Beispiel #5
0
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, Event.objects).filter(nuvius_resource__contains=key)
        if dups:
            return dups

    # Finding equivalent items
    if item.date:
        title = item.title.raw
        start = datetime(*item.date[0].start.raw[:6])
        end = datetime(*item.date[0].end.raw[:6])
        dups = Object.filter_permitted(user, Event.objects).filter(name=title,
                                                                   start=start,
                                                                   end=end)

    return dups
Beispiel #6
0
 def __init__(self, user, skip=[], *args, **kwargs):
     super(LeadFilterForm, self).__init__(*args, **kwargs)
 
     self.fields['contact'].queryset = Object.filter_permitted(user, Contact.objects)
     self.fields['contact'].widget.attrs.update({'class': 'autocomplete', 
                                                 'callback': reverse('identities_ajax_contact_lookup')})
     self.fields['contact'].required = False
     self.fields['contact'].label = _("Contact")
 
     self.fields['products_interested'].queryset = Object.filter_permitted(user, Product.objects)
     self.fields['products_interested'].required = False
     self.fields['products_interested'].help_text = ""
     self.fields['products_interested'].label = _("Products interested")
     
     self.fields['source'].queryset = Object.filter_permitted(user, 
                                                              SaleSource.objects.filter(active=True))
     self.fields['source'].required = False
     self.fields['source'].label = _("Source")
             
     self.fields['status'].queryset = Object.filter_permitted(user, 
                                                              SaleStatus.objects.filter(use_leads=True))
     self.fields['status'].required = False
     self.fields['status'].label = _("Status")
     
     self.fields['contact_method'].required = False
     self.fields['contact_method'].label = _("Contact method")
Beispiel #7
0
 def __init__(self, user, project_id, *args, **kwargs):
     super(MilestoneForm, self ).__init__(*args, **kwargs)
     
     self.fields['name'].label = _("Name")
     
     self.fields['project'].label = _("Project")
     self.fields['project'].queryset = Object.filter_permitted(user, Project.objects, mode='x')
     if project_id:
         self.fields['project'].initial = project_id
         
     self.fields['status'].label = _("Status")
     self.fields['status'].queryset = Object.filter_permitted(user, TaskStatus.objects, mode='x')
     try:
         conf = ModuleSetting.get_for_module('treeio.projects', 'default_task_status')[0]
         self.fields['status'].initial = long(conf.value)
     except Exception:
         pass
     
     # Set datepicker
     self.fields['start_date'].label = _("Start date")
     self.fields['start_date'].widget.attrs.update({'class': 'datetimepicker'})
     self.fields['end_date'].label = _("End date")
     self.fields['end_date'].widget.attrs.update({'class': 'datetimepicker'})
     
     if 'instance' in kwargs:
         instance = kwargs['instance']
         if instance.start_date:
             self.fields['start_date'].widget.attrs.update({'initial': instance.start_date.strftime('%s')})
         if instance.end_date:
             self.fields['end_date'].widget.attrs.update({'initial': instance.end_date.strftime('%s')})
     
     self.fields['details'].label = _("Details")
Beispiel #8
0
    def __init__(self, user, skip=[], *args, **kwargs):
        super(LeadFilterForm, self).__init__(*args, **kwargs)

        self.fields['contact'].queryset = Object.filter_permitted(
            user, Contact.objects)
        self.fields['contact'].widget.attrs.update({
            'class':
            'autocomplete',
            'callback':
            reverse('identities_ajax_contact_lookup')
        })
        self.fields['contact'].required = False
        self.fields['contact'].label = _("Contact")

        self.fields['products_interested'].queryset = Object.filter_permitted(
            user, Product.objects)
        self.fields['products_interested'].required = False
        self.fields['products_interested'].help_text = ""
        self.fields['products_interested'].label = _("Products interested")

        self.fields['source'].queryset = Object.filter_permitted(
            user, SaleSource.objects.filter(active=True))
        self.fields['source'].required = False
        self.fields['source'].label = _("Source")

        self.fields['status'].queryset = Object.filter_permitted(
            user, SaleStatus.objects.filter(use_leads=True))
        self.fields['status'].required = False
        self.fields['status'].label = _("Status")

        self.fields['contact_method'].required = False
        self.fields['contact_method'].label = _("Contact method")
Beispiel #9
0
    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")
Beispiel #10
0
    def __init__(self, user, *args, **kwargs):
        super(SubscriptionForm, self).__init__(*args, **kwargs)

        del self.fields['cycle_end']

        self.fields['product'].queryset = Object.filter_permitted(
            user, Product.objects)
        self.fields['product'].label = _("Product")

        self.fields['client'].queryset = Object.filter_permitted(
            user, Contact.objects)
        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['client'].label = _("Client")

        self.fields['start'].widget.attrs.update({'class': 'datepicker'})
        self.fields['start'].label = _("Start")
        self.fields['expiry'].widget.attrs.update({'class': 'datepicker'})
        self.fields['expiry'].label = _("Expiry")

        if 'instance' in kwargs:
            self.instance = kwargs['instance']
            self.fields['start'].widget.attrs['readonly'] = True
            del kwargs['instance']

        self.fields['active'].initial = True
        self.fields['active'].label = _("Active")
        self.fields['cycle_period'].label = _("Cycle period")
        self.fields['details'].label = _("Details")
Beispiel #11
0
    def __init__(self, user, skip=[], *args, **kwargs):
        super(FilterForm, self).__init__(*args, **kwargs)

        if 'title' in skip:
            del self.fields['title']
        else:
            self.fields['title'].required = False
            self.fields['title'].label = _("Title")

        if 'stream' in skip:
            del self.fields['stream']
        else:
            self.fields['stream'].queryset = Object.filter_permitted(
                user, MessageStream.objects, mode='x')
            self.fields['stream'].required = False
            self.fields['stream'].label = _("Stream")

        if 'author' in skip:
            del self.fields['author']
        else:
            self.fields['author'].required = False
            self.fields['author'].label = _("Author")
            self.fields['author'].queryset = Object.filter_permitted(
                user, Contact.objects, mode='x')
            self.fields['author'].widget.attrs.update({
                'class':
                'autocomplete',
                'callback':
                reverse('identities_ajax_contact_lookup')
            })
Beispiel #12
0
    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
Beispiel #13
0
    def __init__(self, user, *args, **kwargs):
        super(LiabilityForm, self ).__init__(*args, **kwargs)
        
        self.fields['name'].label = _("Name")
        self.fields['category'].label = _("Category")
        self.fields['source'].label = _("Source")
        self.fields['target'].label = _("Target")
        self.fields['account'].label = _("Bank Account")
        self.fields['due_date'].label = _("Due date")
        self.fields['value_currency'].label = _("Currency")
        self.fields['value_currency'].widget.attrs.update({'popuplink': reverse('finance_currency_add')})
        self.fields['value_currency'].initial = Currency.objects.get(is_default=True)
        self.fields['value_display'].label = _("Value")
        self.fields['details'].label = _("Details")
    
        self.fields['target'].queryset = Object.filter_permitted(user, Contact.objects)
        self.fields['target'].widget.attrs.update({'class': 'autocomplete', 
                                                   'callback': reverse('identities_ajax_contact_lookup')})
        self.fields['target'].widget.attrs.update({'popuplink': reverse('identities_contact_add')})

        self.fields['account'].queryset = Object.filter_permitted(user, Account.objects)  
        
        try:
            conf = ModuleSetting.get_for_module('treeio.finance', 'default_account')[0]
            self.fields['account'].initial = long(conf.value)
        except Exception:
            pass
        
        self.fields['due_date'].widget.attrs.update({'class': 'datepicker'})
    
        del self.fields['source']  
Beispiel #14
0
    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")
Beispiel #15
0
    def __init__(self, user, *args, **kwargs):
        super(SubscriptionForm, self).__init__(*args, **kwargs)

        del self.fields['cycle_end']
        
        self.fields['product'].queryset = Object.filter_permitted(user, Product.objects)
        self.fields['product'].label = _("Product")
        
        self.fields['client'].queryset = Object.filter_permitted(user, Contact.objects)
        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['client'].label = _("Client")
        
        self.fields['start'].widget.attrs.update({'class': 'datepicker'})
        self.fields['start'].label = _("Start")
        self.fields['expiry'].widget.attrs.update({'class': 'datepicker'})
        self.fields['expiry'].label = _("Expiry")

        if 'instance' in kwargs:
            self.instance = kwargs['instance']
            self.fields['start'].widget.attrs['readonly'] = True
            del kwargs['instance']
                
        self.fields['active'].initial = True
        self.fields['active'].label = _("Active")
        self.fields['cycle_period'].label = _("Cycle period")
        self.fields['details'].label = _("Details")
Beispiel #16
0
    def __init__(self, user, skip=[], *args, **kwargs):
        super(FilterForm, self).__init__(*args, **kwargs)

        if 'title' in skip:
            del self.fields['title']
        else:
            self.fields['title'].required = False
            self.fields['title'].label = _("Title")

        if 'stream' in skip:
            del self.fields['stream']
        else:
            self.fields['stream'].queryset = Object.filter_permitted(
                user, MessageStream.objects, mode='x')
            self.fields['stream'].required = False
            self.fields['stream'].label = _("Stream")

        if 'author' in skip:
            del self.fields['author']
        else:
            self.fields['author'].required = False
            self.fields['author'].label = _("Author")
            self.fields['author'].queryset = Object.filter_permitted(
                user, Contact.objects, mode='x')
            self.fields['author'].widget.attrs.update({'class': 'autocomplete',
                                                                'callback': reverse('identities_ajax_contact_lookup')})
Beispiel #17
0
 def __init__(self, user, skip=[], *args, **kwargs):
     super(OrderFilterForm, self).__init__(*args, **kwargs)
     
     if 'status' in skip:
         del self.fields['status']
     else:
         self.fields['status'].queryset = Object.filter_permitted(user, 
                                                         SaleStatus.objects.filter(use_sales=True))
         self.fields['status'].required = False
         self.fields['status'].label = _("Status")
         
     self.fields['paid'].label = _("Payment Status")
 
     self.fields['client'].queryset = Object.filter_permitted(user, Contact.objects)
     self.fields['client'].widget.attrs.update({'class': 'autocomplete', 
                                                'callback': reverse('identities_ajax_contact_lookup')})   
     self.fields['client'].required = False
     self.fields['client'].label = _("Client")
 
     self.fields['source'].queryset = Object.filter_permitted(user, SaleSource.objects.filter(active=True))
     self.fields['source'].required = False
     self.fields['source'].label = _("Source")
             
     if 'assigned' in skip:
         del self.fields['assigned']
     else:
         self.fields['assigned'].label = _("Assigned to")
         self.fields['assigned'].help_text = ""
         self.fields['assigned'].required = False
         self.fields['assigned'].widget.attrs.update({'class': 'autocomplete', 
                                                'callback': reverse('identities_ajax_user_lookup')}) 
Beispiel #18
0
    def __init__(self, user, skip=[], *args, **kwargs):
        "Sets allowed values"
        super(SLAFilterForm, self).__init__(*args, **kwargs)

        self.fields['client'].queryset = Object.filter_permitted(
            user, Contact.objects, mode='x')
        self.fields['client'].required = False
        self.fields['client'].widget.attrs.update({
            'class':
            'autocomplete',
            'callback':
            reverse('identities_ajax_contact_lookup')
        })
        self.fields['client'].label = _("Client")

        self.fields['provider'].queryset = Object.filter_permitted(
            user, Contact.objects, mode='x')
        self.fields['provider'].required = False
        self.fields['provider'].widget.attrs.update({
            'class':
            'autocomplete',
            'callback':
            reverse('identities_ajax_contact_lookup')
        })
        self.fields['provider'].label = _("Provider")

        self.fields['service'].queryset = Object.filter_permitted(
            user, Service.objects, mode='x')
        self.fields['service'].required = False
        self.fields['service'].label = _("Service")
Beispiel #19
0
    def __init__(self, user, *args, **kwargs):
        super(EquityForm, self).__init__(*args, **kwargs)

        self.fields['equity_type'].label = _("Equity type")
        self.fields['issue_price'].label = _("Issue price")
        self.fields['sell_price'].label = _("Sell price")
        self.fields['issuer'].label = _("Issuer")
        self.fields['owner'].label = _("Owner")
        self.fields['amount'].label = _("Quantity")
        self.fields['purchase_date'].label = _("Purchase date")
        self.fields['details'].label = _("Details")

        self.fields['owner'].queryset = Object.filter_permitted(
            user, Contact.objects)
        self.fields['owner'].widget.attrs.update({'class': 'autocomplete',
                                                  'callback': reverse('identities_ajax_contact_lookup')})
        self.fields['owner'].widget.attrs.update(
            {'popuplink': reverse('identities_contact_add')})
        self.fields['issuer'].queryset = Object.filter_permitted(
            user, Contact.objects)
        self.fields['issuer'].widget.attrs.update({'class': 'autocomplete',
                                                   'callback': reverse('identities_ajax_contact_lookup')})
        self.fields['issuer'].widget.attrs.update(
            {'popuplink': reverse('identities_contact_add')})
        try:
            conf = ModuleSetting.get_for_module(
                'treeio.finance', 'my_company')[0]
            self.fields['issuer'].initial = long(conf.value)
        except Exception:
            pass

        self.fields['purchase_date'].widget.attrs.update(
            {'class': 'datepicker'})
Beispiel #20
0
    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")
Beispiel #21
0
    def __init__(self, user, skip=[], *args, **kwargs):
        super(LiabilityFilterForm, self).__init__(*args, **kwargs)

        if 'due_date_from' in skip:
            del self.fields['due_date_from']
        else:
            self.fields['due_date_from'] = forms.DateField(
                label=_("Due Date From:"), required=False)
            self.fields['due_date_from'].widget.attrs.update(
                {'class': 'datepicker'})

        if 'due_date_to' in skip:
            del self.fields['due_date_to']
        else:
            self.fields['due_date_to'] = forms.DateField(
                label=_("Due Date To:"), required=False)
            self.fields['due_date_to'].widget.attrs.update(
                {'class': 'datepicker'})

        if 'category' in skip:
            del self.fields['category']
        else:
            self.fields['category'].queryset = Object.filter_permitted(
                user, Category.objects)
            self.fields['category'].label = _("Category")
            self.fields['category'].help_text = ""
            self.fields['category'].required = False

        if 'source' in skip:
            del self.fields['source']
        else:
            self.fields['source'].queryset = Object.filter_permitted(
                user, Contact.objects)
            self.fields['source'].label = _("Source")
            self.fields['source'].help_text = ""
            self.fields['source'].required = False
            self.fields['source'].widget.attrs.update({'class': 'autocomplete',
                                                       'callback': reverse('identities_ajax_contact_lookup')})

        if 'target' in skip:
            del self.fields['target']
        else:
            self.fields['target'].queryset = Object.filter_permitted(
                user, Contact.objects)
            self.fields['target'].required = False
            self.fields['target'].label = _("Target")
            self.fields['target'].help_text = ""
            self.fields['target'].widget.attrs.update({'class': 'autocomplete',
                                                       'callback': reverse('identities_ajax_contact_lookup')})

        if 'account' in skip:
            del self.fields['account']
        else:
            self.fields['account'].queryset = Object.filter_permitted(
                user, Account.objects)
            self.fields['account'].required = False
            self.fields['account'].label = _("Account")
            self.fields['account'].help_text = ""
Beispiel #22
0
    def __init__(self, user, skip=[], *args, **kwargs):
        super(TransactionFilterForm, self).__init__(*args, **kwargs)

        if 'datefrom' in skip:
            del self.fields['datefrom']
            del self.fields['dateto']
        else:
            self.fields['datefrom'] = forms.DateField(label=_("Date From"),
                                                      required=False)
            self.fields['datefrom'].widget.attrs.update(
                {'class': 'datepicker'})

        if 'dateto' in skip:
            del self.fields['dateto']
            del self.fields['datefrom']
        else:
            self.fields['dateto'] = forms.DateField(label=_("Date To"),
                                                    required=False)
            self.fields['dateto'].widget.attrs.update({'class': 'datepicker'})

        if 'category' in skip:
            del self.fields['category']
        else:
            self.fields['category'].queryset = Object.filter_permitted(
                user, Category.objects)
            self.fields['category'].label = _("Category")
            self.fields['category'].help_text = ""
            self.fields['category'].required = False

        if 'source' in skip:
            del self.fields['source']
        else:
            self.fields['source'].queryset = Object.filter_permitted(
                user, Contact.objects)
            self.fields['source'].label = _("Source")
            self.fields['source'].help_text = ""
            self.fields['source'].required = False
            self.fields['source'].widget.attrs.update({
                'class':
                'autocomplete',
                'callback':
                reverse('identities_ajax_contact_lookup')
            })

        if 'target' in skip:
            del self.fields['target']
        else:
            self.fields['target'].queryset = Object.filter_permitted(
                user, Contact.objects)
            self.fields['target'].required = False
            self.fields['target'].label = _("Target")
            self.fields['target'].help_text = ""
            self.fields['target'].widget.attrs.update({
                'class':
                'autocomplete',
                'callback':
                reverse('identities_ajax_contact_lookup')
            })
Beispiel #23
0
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
Beispiel #24
0
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
Beispiel #25
0
    def __init__(self, user, lead, *args, **kwargs):
        super(OpportunityForm, self).__init__(*args, **kwargs)
              
        self.fields['lead'].queryset = Object.filter_permitted(user, Lead.objects)
        self.fields['contact'].queryset = Object.filter_permitted(user, Contact.objects)
        self.fields['contact'].widget.attrs.update({'popuplink': reverse('identities_contact_add')})
        self.fields['contact'].widget.attrs.update({'class': 'autocomplete', 
                                                    'callback': reverse('identities_ajax_contact_lookup')})
        self.fields['products_interested'].queryset = Object.filter_permitted(user, Product.objects)
        self.fields['products_interested'].widget.attrs.update({'popuplink': reverse('sales_product_add')})
        try:
            conf = ModuleSetting.get_for_module('treeio.sales', 'default_order_product')[0]
            self.fields['products_interested'].initial = [long(conf.value)]
        except:
            pass 
        self.fields['source'].queryset = Object.filter_permitted(user, 
                                                                 SaleSource.objects.filter(active=True))
        self.fields['status'].queryset = Object.filter_permitted(user, 
                                                        SaleStatus.objects.filter(use_opportunities=True))
        self.fields['assigned'].widget.attrs.update({'class': 'multicomplete', 
                                                     'callback': reverse('identities_ajax_user_lookup')})
        
        try:
            conf = ModuleSetting.get_for_module('treeio.sales', 'default_opportunity_status')[0]
            self.fields['status'].initial = long(conf.value)
        except:
            pass 
        
        if lead:
            self.fields['lead'].initial = lead.id
            self.fields['contact'].initial = lead.contact_id
            self.fields['products_interested'].initial = [i.id for i in lead.products_interested.only('id')]
            self.fields['source'].initial = lead.source_id
            self.fields['assigned'].initial = [i.id for i in lead.assigned.only('id')]
        else:
            del self.fields['lead']
        
        self.fields['products_interested'].help_text = ""
        self.fields['assigned'].help_text = ""
        
        self.fields['expected_date'].widget.attrs.update({'class': 'datepicker'})
        self.fields['closed_date'].widget.attrs.update({'class': 'datepicker'})

        self.fields['contact'].label = _("Contact")
        self.fields['products_interested'].label = _("Products interested")
        self.fields['source'].label = _("Source")
        self.fields['expected_date'].label = _("Expected date")
        self.fields['closed_date'].label = _("Closed date")
        self.fields['assigned'].label = _("Assigned to")
        self.fields['amount_display'].label = _("Amount")
        self.fields['amount_currency'].label = _("Currency")
        self.fields['amount_currency'].widget.attrs.update({'popuplink': reverse('finance_currency_add')})
        self.fields['amount_currency'].initial = Currency.objects.get(is_default=True)
        
        self.fields['probability'].label = _("Probability")
        self.fields['status'].label = _("Status")
        self.fields['details'].label = _("Details")
Beispiel #26
0
    def __init__(self, user, skip=[], *args, **kwargs):
        super(EquityFilterForm, self).__init__(*args, **kwargs)

        if 'purchase_date_from' in skip:
            del self.fields['purchase_date_from']
        else:
            self.fields['purchase_date_from'] = forms.DateField(
                label="Purchase Date From:", required=False)
            self.fields['purchase_date_from'].widget.attrs.update(
                {'class': 'datepicker'})
            self.fields['purchase_date_from'].label = _("Purchase Date From")

        if 'purchase_date_to' in skip:
            del self.fields['purchase_date_to']
        else:
            self.fields['purchase_date_to'] = forms.DateField(
                label="Purchase Date To:", required=False)
            self.fields['purchase_date_to'].widget.attrs.update(
                {'class': 'datepicker'})
            self.fields['purchase_date_to'].label = _("Purchase Date To")

        if 'equity_type' in skip:
            del self.fields['equity_type']
        else:
            self.fields['equity_type'].label = _("Equity Type")
            self.fields['equity_type'].help_text = ""
            self.fields['equity_type'].required = False

        if 'issuer' in skip:
            del self.fields['issuer']
        else:
            self.fields['issuer'].queryset = Object.filter_permitted(
                user, Contact.objects)
            self.fields['issuer'].label = _("Issuer")
            self.fields['issuer'].help_text = ""
            self.fields['issuer'].required = False
            self.fields['issuer'].widget.attrs.update({
                'class':
                'autocomplete',
                'callback':
                reverse('identities_ajax_contact_lookup')
            })

        if 'owner' in skip:
            del self.fields['owner']
        else:
            self.fields['owner'].queryset = Object.filter_permitted(
                user, Contact.objects)
            self.fields['owner'].required = False
            self.fields['owner'].label = _("Owner")
            self.fields['owner'].help_text = ""
            self.fields['owner'].widget.attrs.update({
                'class':
                'autocomplete',
                'callback':
                reverse('identities_ajax_contact_lookup')
            })
Beispiel #27
0
    def __init__(self, user, *args, **kwargs):
        super(LeadForm, self).__init__(*args, **kwargs)

        self.fields['contact'].queryset = Object.filter_permitted(
            user, Contact.objects)
        self.fields['contact'].widget.attrs.update({
            'class':
            'autocomplete',
            'callback':
            reverse('identities_ajax_contact_lookup')
        })
        self.fields['contact'].widget.attrs.update(
            {'popuplink': reverse('identities_contact_add')})
        self.fields['contact'].label = _("Contact")

        self.fields['source'].queryset = Object.filter_permitted(
            user, SaleSource.objects.filter(active=True))
        self.fields['source'].label = _("Source")
        self.fields['products_interested'].queryset = Object.filter_permitted(
            user, Product.objects)
        self.fields['products_interested'].help_text = ""
        self.fields['products_interested'].widget.attrs.update(
            {'popuplink': reverse('sales_product_add')})
        self.fields['products_interested'].label = _("Products interested")

        self.fields['assigned'].help_text = ""
        self.fields['assigned'].label = _("Assigned to")
        self.fields['assigned'].widget.attrs.update({
            'class':
            'multicomplete',
            'callback':
            reverse('identities_ajax_user_lookup')
        })

        try:
            conf = ModuleSetting.get_for_module('treeio.sales',
                                                'default_order_product')[0]
            self.fields['products_interested'].initial = [long(conf.value)]
        except:
            pass

        self.fields['status'].queryset = Object.filter_permitted(
            user, SaleStatus.objects.filter(use_leads=True))
        self.fields['status'].label = _("Status")

        try:
            conf = ModuleSetting.get_for_module('treeio.sales',
                                                'default_lead_status')[0]
            self.fields['status'].initial = long(conf.value)
        except:
            pass

        self.fields['contact_method'].label = _("Contact method")
        self.fields['details'].label = _("Details")
Beispiel #28
0
    def __init__(self, user, *args, **kwargs):
        "Sets allowed values"
        super(ServiceLevelAgreementForm, self).__init__(*args, **kwargs)

        self.fields['name'].label = _("Name")

        self.fields['response_time'].help_text = 'minutes'
        self.fields['response_time'].widget.attrs.update({'size': 10})
        self.fields['response_time'].label = _("Response time")

        self.fields['uptime_rate'].help_text = 'percent'
        self.fields['uptime_rate'].widget.attrs.update({'size': 5})
        self.fields['uptime_rate'].label = _("Uptime rate")

        self.fields['service'].queryset = Object.filter_permitted(
            user, Service.objects, mode='x')
        self.fields['service'].label = _("Service")

        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['client'].label = _("Client")

        self.fields['provider'].queryset = Object.filter_permitted(
            user, Contact.objects, mode='x')
        self.fields['provider'].widget.attrs.update({
            'class':
            'autocomplete',
            'callback':
            reverse('identities_ajax_contact_lookup')
        })
        self.fields['provider'].widget.attrs.update(
            {'popuplink': reverse('identities_contact_add')})
        self.fields['provider'].label = _("Provider")

        self.fields['available_from'].initial = "09:00"
        self.fields['available_from'].widget.attrs.update({'size': 10})
        self.fields['available_from'].label = _("Available from")
        self.fields['available_to'].initial = "18:00"
        self.fields['available_to'].widget.attrs.update({'size': 10})
        self.fields['available_to'].label = _("Available to")

        contact = user.default_group.get_contact()
        if contact:
            self.fields['provider'].initial = contact.id
Beispiel #29
0
    def __init__(self, user, *args, **kwargs):
        "Sets choices and initial value"
        super(SettingsForm, self).__init__(*args, **kwargs)

        # Translate
        self.fields['default_ticket_status'].label = _('Default Ticket Status')
        self.fields['default_ticket_queue'].label = _('Default Queue')
        self.fields['send_email_to_caller'].label = _(
            "Notify Caller By E-mail")
        self.fields['send_email_template'].label = _("E-mail Template")

        self.fields[
            'default_ticket_status'].queryset = Object.filter_permitted(
                user, TicketStatus.objects, mode='x')
        self.fields['default_ticket_queue'].queryset = Object.filter_permitted(
            user, TicketQueue.objects, mode='x')

        try:
            conf = ModuleSetting.get_for_module('treeio.services',
                                                'default_ticket_status')[0]
            default_ticket_status = TicketStatus.objects.get(
                pk=long(conf.value))
            self.fields[
                'default_ticket_status'].initial = default_ticket_status.id
        except Exception:
            pass

        try:
            conf = ModuleSetting.get_for_module('treeio.services',
                                                'default_ticket_queue')[0]
            default_ticket_queue = TicketQueue.objects.get(pk=long(conf.value))
            self.fields[
                'default_ticket_queue'].initial = default_ticket_queue.id
        except Exception:
            pass

        try:
            conf = ModuleSetting.get_for_module('treeio.services',
                                                'send_email_to_caller')[0]
            self.fields['send_email_to_caller'].initial = conf.value
        except:
            self.fields[
                'send_email_to_caller'].initial = settings.HARDTREE_SEND_EMAIL_TO_CALLER

        # notification template
        try:
            conf = ModuleSetting.get_for_module('treeio.services',
                                                'send_email_template')[0]
            self.fields['send_email_template'].initial = conf.value
        except Exception:
            self.fields['send_email_template'].initial = get_template_source(
                'services/emails/notify_caller.html')
Beispiel #30
0
    def __init__(self, user, skip=[], *args, **kwargs):
        super(FilterForm, self).__init__(*args, **kwargs)

        self.fields['caller'].label = _("Caller")
        if 'caller' in skip:
            del self.fields['caller']
        else:
            self.fields['caller'].queryset = Object.filter_permitted(
                user, Contact.objects, mode='x')
            self.fields['caller'].required = False
            self.fields['caller'].widget.attrs.update({
                'class':
                'autocomplete',
                'callback':
                reverse('identities_ajax_contact_lookup')
            })

        self.fields['status'].label = _("Status")
        if 'status' in skip:
            del self.fields['status']
        else:
            self.fields['status'].queryset = Object.filter_permitted(
                user, TaskStatus.objects, mode='x')
            self.fields['status'].required = False

        self.fields['assigned'].label = _("Assigned")
        self.fields['assigned'].widget.attrs.update({
            'class':
            'multicomplete',
            'callback':
            reverse('identities_ajax_user_lookup')
        })
        if 'assigned' in skip:
            del self.fields['assigned']
        else:
            self.fields['assigned'].help_text = ""

        self.fields['project'].label = _("Project")
        if 'project' in skip:
            del self.fields['project']
        else:
            self.fields['project'].queryset = Object.filter_permitted(
                user, Project.objects, mode='x')
            self.fields['project'].required = False

        self.fields['milestone'].label = _("Milestone")
        if 'milestone' in skip:
            del self.fields['milestone']
        else:
            self.fields['milestone'].queryset = Object.filter_permitted(
                user, Milestone.objects, mode='x')
Beispiel #31
0
    def __init__(self, user, *args, **kwargs):
        "Sets choices and initial value"
        super(SettingsForm, self).__init__(*args, **kwargs)

        # Translate
        self.fields['default_ticket_status'].label = _('Default Ticket Status')
        self.fields['default_ticket_queue'].label = _('Default Queue')
        self.fields['send_email_to_caller'].label = _(
            "Notify Caller By E-mail")
        self.fields['send_email_template'].label = _("E-mail Template")

        self.fields['default_ticket_status'].queryset = Object.filter_permitted(
            user, TicketStatus.objects, mode='x')
        self.fields['default_ticket_queue'].queryset = Object.filter_permitted(
            user, TicketQueue.objects, mode='x')

        try:
            conf = ModuleSetting.get_for_module(
                'treeio.services', 'default_ticket_status')[0]
            default_ticket_status = TicketStatus.objects.get(
                pk=long(conf.value))
            self.fields[
                'default_ticket_status'].initial = default_ticket_status.id
        except Exception:
            pass

        try:
            conf = ModuleSetting.get_for_module(
                'treeio.services', 'default_ticket_queue')[0]
            default_ticket_queue = TicketQueue.objects.get(pk=long(conf.value))
            self.fields[
                'default_ticket_queue'].initial = default_ticket_queue.id
        except Exception:
            pass

        try:
            conf = ModuleSetting.get_for_module(
                'treeio.services', 'send_email_to_caller')[0]
            self.fields['send_email_to_caller'].initial = conf.value
        except:
            self.fields[
                'send_email_to_caller'].initial = settings.HARDTREE_SEND_EMAIL_TO_CALLER

        # notification template
        try:
            conf = ModuleSetting.get_for_module(
                'treeio.services', 'send_email_template')[0]
            self.fields['send_email_template'].initial = conf.value
        except Exception:
            self.fields['send_email_template'].initial = get_template_source(
                'services/emails/notify_caller.html')
Beispiel #32
0
    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"
        )
Beispiel #33
0
    def __init__(self, user, skip=[], *args, **kwargs):
        super(TransactionFilterForm, self).__init__(*args, **kwargs)
      
	if 'details' in skip:
	    del self.fields['details']
	else:
	    self.fields['details'] = forms.CharField(label="Details", required=False)
  
        if 'datefrom' in skip:
            del self.fields['datefrom']
            del self.fields['dateto']
        else:
            self.fields['datefrom'] = forms.DateField(label=_("Date From"), required = False)
            self.fields['datefrom'].widget.attrs.update({'class': 'datepicker'})
            
        if 'dateto' in skip:
            del self.fields['dateto']
            del self.fields['datefrom']
        else:
            self.fields['dateto'] = forms.DateField(label=_("Date To"), required = False)
            self.fields['dateto'].widget.attrs.update({'class': 'datepicker'})
        
        if 'category' in skip:
            del self.fields['category']
        else:
            self.fields['category'].queryset = Object.filter_permitted(user, Category.objects)
            self.fields['category'].label = _("Category")
            self.fields['category'].help_text = ""
            self.fields['category'].required = False
        
        if 'source' in skip:
            del self.fields['source']
        else:
            self.fields['source'].queryset = Object.filter_permitted(user, Contact.objects)
            self.fields['source'].label = _("Source")
            self.fields['source'].help_text = ""
            self.fields['source'].required = False
            self.fields['source'].widget.attrs.update({'class': 'autocomplete', 
                                                       'callback': reverse('identities_ajax_contact_lookup')})

        
        if 'target' in skip:
            del self.fields['target']
        else:
            self.fields['target'].queryset = Object.filter_permitted(user, Contact.objects)
            self.fields['target'].required = False
            self.fields['target'].label = _("Target")
            self.fields['target'].help_text = ""
            self.fields['target'].widget.attrs.update({'class': 'autocomplete', 
                                                    'callback': reverse('identities_ajax_contact_lookup')})
Beispiel #34
0
    def __init__(self, user, skip=[], *args, **kwargs):
        super(EquityFilterForm, self).__init__(*args, **kwargs)

        if 'purchase_date_from' in skip:
            del self.fields['purchase_date_from']
        else:
            self.fields['purchase_date_from'] = forms.DateField(label="Purchase Date From:",
                                                                required=False)
            self.fields['purchase_date_from'].widget.attrs.update(
                {'class': 'datepicker'})
            self.fields['purchase_date_from'].label = _("Purchase Date From")

        if 'purchase_date_to' in skip:
            del self.fields['purchase_date_to']
        else:
            self.fields['purchase_date_to'] = forms.DateField(
                label="Purchase Date To:", required=False)
            self.fields['purchase_date_to'].widget.attrs.update(
                {'class': 'datepicker'})
            self.fields['purchase_date_to'].label = _("Purchase Date To")

        if 'equity_type' in skip:
            del self.fields['equity_type']
        else:
            self.fields['equity_type'].label = _("Equity Type")
            self.fields['equity_type'].help_text = ""
            self.fields['equity_type'].required = False

        if 'issuer' in skip:
            del self.fields['issuer']
        else:
            self.fields['issuer'].queryset = Object.filter_permitted(
                user, Contact.objects)
            self.fields['issuer'].label = _("Issuer")
            self.fields['issuer'].help_text = ""
            self.fields['issuer'].required = False
            self.fields['issuer'].widget.attrs.update({'class': 'autocomplete',
                                                       'callback': reverse('identities_ajax_contact_lookup')})

        if 'owner' in skip:
            del self.fields['owner']
        else:
            self.fields['owner'].queryset = Object.filter_permitted(
                user, Contact.objects)
            self.fields['owner'].required = False
            self.fields['owner'].label = _("Owner")
            self.fields['owner'].help_text = ""
            self.fields['owner'].widget.attrs.update({'class': 'autocomplete',
                                                      'callback': reverse('identities_ajax_contact_lookup')})
Beispiel #35
0
    def __init__(self, user, *args, **kwargs):
        super(WidgetForm, self).__init__(*args, **kwargs)

        self.fields['perspective'].queryset = Object.filter_permitted(
            user, Perspective.objects)
        self.fields['perspective'].label = _("Perspective")
        self.fields['weight'].label = _("Weight")
Beispiel #36
0
 def __init__(self, user, *args, **kwargs):
     "Sets choices and initial value"
     super(SettingsForm, self).__init__(*args, **kwargs)
     self.user = user
     
     self.fields['default_contact_type'].label = _('Default Contact Type')
     self.fields['default_contact_type'].queryset = Object.filter_permitted(user, 
                                                                            ContactType.objects, mode='x')
     try:
         conf = ModuleSetting.get_for_module('treeio.messaging', 'default_contact_type',
                                             user=user)[0]
         default_contact_type = ContactType.objects.get(pk=long(conf.value))
         self.fields['default_contact_type'].initial = default_contact_type.id
     except:
         pass
     
     
     self.fields['default_imap_folder'].label = _('Default IMAP Folder')
     try:
         conf = ModuleSetting.get_for_module('treeio.messaging', 'default_imap_folder',
                                             user=user)[0]
         self.fields['default_imap_folder'].initial = conf.value
     except:
         self.fields['default_imap_folder'].initial = settings.HARDTREE_MESSAGING_IMAP_DEFAULT_FOLDER_NAME
     
     
     self.fields['signature'].label = _('Signature')
     try:
         conf = ModuleSetting.get_for_module('treeio.messaging', 'signature',
                                             user=user, strict=True)[0]
         signature = conf.value
         self.fields['signature'].initial = signature
     except:
         pass
Beispiel #37
0
 def save(self, *args, **kwargs):
     "Save override to omit empty fields"
     if self.instance:
         if self.is_valid():
             if self.cleaned_data['stream']:
                 self.instance.stream = self.cleaned_data['stream']
             if self.user and self.cleaned_data['mark']:
                 if self.cleaned_data['mark'] == 'read':
                     try:
                         self.instance.read_by.add(self.user)
                     except Exception:
                         pass
                 if self.cleaned_data['mark'] == 'unread':
                     try:
                         self.instance.read_by.remove(self.user)
                     except Exception:
                         pass
             self.instance.save()
             if self.user and self.cleaned_data['mark']:
                 if self.cleaned_data['mark'] == 'delete':
                     self.instance.delete()
                 if self.cleaned_data['mark'] == 'trash':
                     self.instance.trash = True  
                     self.instance.save()  
     else:
         if self.user and self.cleaned_data['markall']:
             query = Q(reply_to__isnull=True) & ~Q(read_by=self.user)
             for message in Object.filter_permitted(self.user, Message.objects.filter(query), mode='x'):
                 try:
                     message.read_by.add(self.user)
                 except Exception:
                     pass
Beispiel #38
0
def category_delete(request, knowledgeCategory_id, response_format='html'):
    "Knowledge Category delete"

    category = get_object_or_404(KnowledgeCategory, pk=knowledgeCategory_id)
    items = Object.filter_permitted(manager=KnowledgeItem.objects, user=request.user.get_profile(), mode='r')
    
    if not request.user.get_profile().has_permission(category, mode="w"):
        return user_denied(request, message="You don't have access to this Knowledge Category")
    
    if request.POST:
        if 'delete' in request.POST:
            if 'trash' in request.POST:
                category.trash = True
                category.save()
            else:
                category.delete()
            return HttpResponseRedirect(reverse('knowledge_index'))
        elif 'cancel' in request.POST:
            return HttpResponseRedirect(reverse('knowledge_category_view', args=[category.treepath]))
        
    context = _get_default_context(request)
    context.update({'category': category, 
                    'items':items})
        
    return render_to_response('knowledge/category_delete', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Beispiel #39
0
def item_edit(request, knowledgeItem_id, response_format='html'):
    "Knowledge item edit page"
    item = get_object_or_404(KnowledgeItem, pk=knowledgeItem_id)
    items = Object.filter_permitted(manager=KnowledgeItem.objects, user=request.user.get_profile(), mode='r')
    
    if not request.user.get_profile().has_permission(item, mode="w"):
        return user_denied(request, message="You don't have access to this Knowledge Item")
    
    if request.POST:
        if not 'cancel' in request.POST:
            form = KnowledgeItemForm(request.user.get_profile(), None, request.POST, instance=item)
            if form.is_valid():
                item = form.save()
                return HttpResponseRedirect(reverse('knowledge_item_view', 
                                                    args=[item.folder.treepath, item.treepath]))
        else:
            return HttpResponseRedirect(reverse('knowledge_item_view', 
                                                    args=[item.folder.treepath, item.treepath]))
    else:
        form = KnowledgeItemForm(request.user.get_profile(), None, instance=item)
        
    context = _get_default_context(request)
    context.update({'form': form,
                    'item':item,
                    'items':items})
        
    return render_to_response('knowledge/item_edit', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Beispiel #40
0
def item_add(request, response_format='html'):
    "Add new knowledge item"
    items = Object.filter_permitted(manager=KnowledgeItem.objects, user=request.user.get_profile(), mode='r')
    
    if request.POST:
        if not 'cancel' in request.POST:
            item = KnowledgeItem()
            form = KnowledgeItemForm(request.user.get_profile(), None, request.POST, instance=item)
            if form.is_valid():
                item = form.save()
                item.set_user_from_request(request)
                return HttpResponseRedirect(reverse('knowledge_item_view', 
                                                    args=[item.folder.treepath, item.treepath]))
        else:
            return HttpResponseRedirect(reverse('knowledge'))
    else:   
        form = KnowledgeItemForm(request.user.get_profile(), None)
        
    context = _get_default_context(request)
    context.update({'items': items,
                    'form':form})
    
    return render_to_response('knowledge/item_add', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Beispiel #41
0
def category_edit(request, knowledgeCategory_id, response_format='html'):
    "Knowledge category edit page"
    category = get_object_or_404(KnowledgeCategory, pk=knowledgeCategory_id)
    items = Object.filter_permitted(manager=KnowledgeItem.objects,
                                    user=request.user.get_profile(),
                                    mode='r')

    if not request.user.get_profile().has_permission(category, mode="w"):
        return user_denied(
            request,
            message="You don't have access to this Knowledge Category")

    if request.POST:
        if not 'cancel' in request.POST:
            form = KnowledgeCategoryForm(request.POST, instance=category)
            if form.is_valid():
                category = form.save()
                return HttpResponseRedirect(
                    reverse('knowledge_category_view',
                            args=[category.treepath]))
        else:
            return HttpResponseRedirect(
                reverse('knowledge_category_view', args=[category.treepath]))
    else:
        form = KnowledgeCategoryForm(instance=category)

    context = _get_default_context(request)
    context.update({'form': form, 'category': category, 'items': items})

    return render_to_response('knowledge/category_edit',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Beispiel #42
0
def item_add(request, response_format='html'):
    "Add new knowledge item"
    items = Object.filter_permitted(manager=KnowledgeItem.objects,
                                    user=request.user.get_profile(),
                                    mode='r')

    if request.POST:
        if not 'cancel' in request.POST:
            item = KnowledgeItem()
            form = KnowledgeItemForm(request.user.get_profile(),
                                     None,
                                     request.POST,
                                     instance=item)
            if form.is_valid():
                item = form.save()
                item.set_user_from_request(request)
                return HttpResponseRedirect(
                    reverse('knowledge_item_view',
                            args=[item.folder.treepath, item.treepath]))
        else:
            return HttpResponseRedirect(reverse('knowledge'))
    else:
        form = KnowledgeItemForm(request.user.get_profile(), None)

    context = _get_default_context(request)
    context.update({'items': items, 'form': form})

    return render_to_response('knowledge/item_add',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Beispiel #43
0
    def __init__(self, user, *args, **kwargs):
        super(WidgetForm, self).__init__(*args, **kwargs)

        self.fields['perspective'].queryset = Object.filter_permitted(
            user, Perspective.objects)
        self.fields['perspective'].label = _("Perspective")
        self.fields['weight'].label = _("Weight")
Beispiel #44
0
 def __init__(self, user, *args, **kwargs):
     if 'instance' in kwargs:
         self.instance = kwargs['instance']
         del kwargs['instance']
         
     super(MassActionForm, self).__init__(*args, **kwargs)
     
     self.fields['status'].queryset = Object.filter_permitted(user, TaskStatus.objects, mode='x')
     self.fields['status'].label = _("Mark as")
     self.fields['project'].queryset = Object.filter_permitted(user, Project.objects, mode='x')
     self.fields['project'].label = _("Move to Project")
     self.fields['milestone'].queryset = Object.filter_permitted(user, Milestone.objects, mode='x')
     self.fields['milestone'].label = _("Move to Milestone")
     self.fields['delete'] = ChoiceField(label=_("Delete"), choices=(('', '-----'),
                                                                     ('delete', _('Delete Completely')), 
                                                                     ('trash', _('Move to Trash'))), required=False)
Beispiel #45
0
    def __init__(self, user, *args, **kwargs):
        super(UpdateRecordFilterForm, self).__init__(*args, **kwargs)

        self.fields['author'].label = _("Author")
        self.fields['about'].label = _("About")

        self.fields['author'].required = False
        self.fields['author'].widget.attrs.update({
            'class':
            'autocomplete',
            'callback':
            reverse('identities_ajax_user_lookup')
        })

        self.fields['about'].queryset = Object.filter_permitted(user,
                                                                Object.objects,
                                                                mode='x')
        self.fields['about'].required = False
        self.fields['about'].null = True
        self.fields['about'].help_text = ""
        self.fields['about'].widget.attrs.update({
            'class':
            'multicomplete',
            'callback':
            reverse('core_ajax_object_lookup')
        })
Beispiel #46
0
    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')
Beispiel #47
0
def item_add_folder(request, folderPath, response_format='html'):
    "Add new knowledge item to preselected folder"
    items = Object.filter_permitted(
        manager=KnowledgeItem.objects, user=request.user.get_profile(), mode='r')

    try:
        folder = KnowledgeFolder.by_path(folderPath)
        knowledgeType_id = folder.id
    except KnowledgeFolder.DoesNotExist:
        raise Http404

    if request.POST:
        if not 'cancel' in request.POST:
            item = KnowledgeItem()
            form = KnowledgeItemForm(
                request.user.get_profile(), knowledgeType_id, request.POST, instance=item)
            if form.is_valid():
                item = form.save()
                item.set_user_from_request(request)
                return HttpResponseRedirect(reverse('knowledge_item_view',
                                                    args=[item.folder.treepath, item.treepath]))
        else:
            return HttpResponseRedirect(reverse('knowledge'))
    else:
        form = KnowledgeItemForm(request.user.get_profile(), knowledgeType_id)

    context = _get_default_context(request)
    context.update({'items': items,
                    'form': form,
                    'folder': folder})

    return render_to_response('knowledge/item_add_folder', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Beispiel #48
0
def item_edit(request, knowledgeItem_id, response_format='html'):
    "Knowledge item edit page"
    item = get_object_or_404(KnowledgeItem, pk=knowledgeItem_id)
    items = Object.filter_permitted(
        manager=KnowledgeItem.objects, user=request.user.get_profile(), mode='r')

    if not request.user.get_profile().has_permission(item, mode="w"):
        return user_denied(request, message="You don't have access to this Knowledge Item")

    if request.POST:
        if not 'cancel' in request.POST:
            form = KnowledgeItemForm(
                request.user.get_profile(), None, request.POST, instance=item)
            if form.is_valid():
                item = form.save()
                return HttpResponseRedirect(reverse('knowledge_item_view',
                                                    args=[item.folder.treepath, item.treepath]))
        else:
            return HttpResponseRedirect(reverse('knowledge_item_view',
                                                args=[item.folder.treepath, item.treepath]))
    else:
        form = KnowledgeItemForm(
            request.user.get_profile(), None, instance=item)

    context = _get_default_context(request)
    context.update({'form': form,
                    'item': item,
                    'items': items})

    return render_to_response('knowledge/item_edit', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Beispiel #49
0
def item_view(request, folderPath, itemPath, response_format='html'):
    "Single knowledge item view page"

    try:
        item = KnowledgeItem.by_path(folderPath, itemPath)
    except KnowledgeItem.DoesNotExist:
        raise Http404
    if not item:
        raise Http404

    items = Object.filter_permitted(manager=KnowledgeItem.objects,
                                    user=request.user.get_profile(),
                                    mode='r')

    if not request.user.get_profile().has_permission(item):
        return user_denied(
            request, message="You don't have access to this Knowledge Item")

    context = _get_default_context(request)
    context.update({'items': items, 'item': item})

    return render_to_response('knowledge/item_view',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Beispiel #50
0
 def save(self, *args, **kwargs):
     "Save override to omit empty fields"
     if self.instance:
         if self.is_valid():
             if self.cleaned_data['stream']:
                 self.instance.stream = self.cleaned_data['stream']
             if self.user and self.cleaned_data['mark']:
                 if self.cleaned_data['mark'] == 'read':
                     try:
                         self.instance.read_by.add(self.user)
                     except Exception:
                         pass
                 if self.cleaned_data['mark'] == 'unread':
                     try:
                         self.instance.read_by.remove(self.user)
                     except Exception:
                         pass
             self.instance.save()
             if self.user and self.cleaned_data['mark']:
                 if self.cleaned_data['mark'] == 'delete':
                     self.instance.delete()
                 if self.cleaned_data['mark'] == 'trash':
                     self.instance.trash = True
                     self.instance.save()
     else:
         if self.user and self.cleaned_data['markall']:
             query = Q(reply_to__isnull=True) & ~Q(read_by=self.user)
             for message in Object.filter_permitted(
                     self.user, Message.objects.filter(query), mode='x'):
                 try:
                     message.read_by.add(self.user)
                 except Exception:
                     pass
Beispiel #51
0
def category_delete(request, knowledgeCategory_id, response_format='html'):
    "Knowledge Category delete"

    category = get_object_or_404(KnowledgeCategory, pk=knowledgeCategory_id)
    items = Object.filter_permitted(manager=KnowledgeItem.objects,
                                    user=request.user.get_profile(),
                                    mode='r')

    if not request.user.get_profile().has_permission(category, mode="w"):
        return user_denied(
            request,
            message="You don't have access to this Knowledge Category")

    if request.POST:
        if 'delete' in request.POST:
            if 'trash' in request.POST:
                category.trash = True
                category.save()
            else:
                category.delete()
            return HttpResponseRedirect(reverse('knowledge_index'))
        elif 'cancel' in request.POST:
            return HttpResponseRedirect(
                reverse('knowledge_category_view', args=[category.treepath]))

    context = _get_default_context(request)
    context.update({'category': category, 'items': items})

    return render_to_response('knowledge/category_delete',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Beispiel #52
0
def messaging_unread(context):
    "Print a number of unread messages"

    request = context['request']

    user = None
    if request.user.username:
        try:
            user = request.user.get_profile()
        except Exception:
            pass

    unread = 0
    messaging = None
    if user:
        modules = user.get_perspective().get_modules()
        messaging = modules.filter(name='treeio.messaging')
        if messaging:
            unread = Object.filter_permitted(
                user,
                Message.objects.filter(reply_to__isnull=True).exclude(
                    read_by=user)).count()

    response_format = 'html'
    if 'response_format' in context:
        response_format = context['response_format']

    return Markup(
        render_to_string('messaging/tags/unread', {
            'messaging': messaging,
            'unread': unread
        },
                         context_instance=RequestContext(request),
                         response_format=response_format))
Beispiel #53
0
def item_add_folder(request, folderPath, response_format='html'):
    "Add new knowledge item to preselected folder"
    items = Object.filter_permitted(manager=KnowledgeItem.objects, user=request.user.get_profile(), mode='r')
    
    try:
        folder = KnowledgeFolder.by_path(folderPath)
        knowledgeType_id = folder.id
    except KnowledgeFolder.DoesNotExist:
        raise Http404    
            
    if request.POST:
        if not 'cancel' in request.POST:
            item = KnowledgeItem()
            form = KnowledgeItemForm(request.user.get_profile(), knowledgeType_id, request.POST, instance=item)
            if form.is_valid():
                item = form.save()
                item.set_user_from_request(request)
                return HttpResponseRedirect(reverse('knowledge_item_view', 
                                                    args=[item.folder.treepath, item.treepath]))
        else:
            return HttpResponseRedirect(reverse('knowledge'))
    else:   
        form = KnowledgeItemForm(request.user.get_profile(), knowledgeType_id)
        
    context = _get_default_context(request)
    context.update({'items': items,
                    'form':form,
                    'folder':folder})
    
    return render_to_response('knowledge/item_add_folder', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Beispiel #54
0
    def __init__(self, user, *args, **kwargs):
        super(AccountForm, self).__init__(*args, **kwargs)

        self.fields['name'].label = _("Name")

        self.fields['owner'].label = _("Owner")
        self.fields['owner'].queryset = Object.filter_permitted(
            user, Contact.objects)
        self.fields['owner'].widget.attrs.update({
            'class':
            'autocomplete',
            'callback':
            reverse('identities_ajax_contact_lookup')
        })
        self.fields['owner'].widget.attrs.update(
            {'popuplink': reverse('identities_contact_add')})

        self.fields['balance_currency'].label = _("Currency")
        self.fields['balance_currency'].widget.attrs.update(
            {'popuplink': reverse('finance_currency_add')})
        try:
            self.fields['balance_currency'].initial = Currency.objects.get(
                is_default=True)
        except:
            pass
        self.fields['balance_display'].label = _("Initial Balance")

        self.fields['details'].label = _("Details")
Beispiel #55
0
def category_edit(request, knowledgeCategory_id, response_format='html'):
    "Knowledge category edit page"
    category = get_object_or_404(KnowledgeCategory, pk=knowledgeCategory_id)
    items = Object.filter_permitted(manager=KnowledgeItem.objects, user=request.user.get_profile(), mode='r')
    
    if not request.user.get_profile().has_permission(category, mode="w"):
        return user_denied(request, message="You don't have access to this Knowledge Category")
    
    if request.POST:
        if not 'cancel' in request.POST:
            form = KnowledgeCategoryForm(request.POST, instance=category)
            if form.is_valid():
                category = form.save()
                return HttpResponseRedirect(reverse('knowledge_category_view', args=[category.treepath]))
        else:
            return HttpResponseRedirect(reverse('knowledge_category_view', args=[category.treepath]))
    else:
        form = KnowledgeCategoryForm(instance=category)
        
    context = _get_default_context(request)
    context.update({'form': form, 
                    'category': category, 
                    'items':items})
        
    return render_to_response('knowledge/category_edit', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Beispiel #56
0
 def __init__(self, user, stream_id, message=None, *args, **kwargs):
     super(MessageForm, self ).__init__(*args, **kwargs)
     
     self.fields['title'].label = _("Subject")
     self.fields['title'].widget = forms.TextInput(attrs = {'size':'40'})
     self.fields['stream'].queryset = Object.filter_permitted(user, MessageStream.objects, mode='x')
     self.fields['stream'].label = _("Stream")
     
     self.fields['recipients'].label = _("To")
     self.fields['recipients'].help_text = ""                
     self.fields['recipients'].widget.attrs.update({'class': 'multicomplete', 
                                                  'callback': reverse('identities_ajax_contact_lookup')})
     
     if stream_id:
         self.fields['stream'].initial = stream_id
         self.fields['stream'].widget = forms.HiddenInput()
     elif self.fields['stream'].queryset:
         self.fields['stream'].initial = self.fields['stream'].queryset[0].id
     
     self.fields['body'].label = _("Body")
     # signature
     try:
         conf = ModuleSetting.get_for_module('treeio.messaging', 'signature',
                                             user=user, strict=True)[0]
         signature = conf.value
         self.fields['body'].initial = signature 
     except:
         pass
Beispiel #57
0
    def __init__(self, user, response_format, instance, *args, **kwargs):

        super(ObjectLinksForm, self).__init__(*args, **kwargs)

        queryset = Object.filter_permitted(user, Object.objects)
        self.fields['links'].queryset = queryset

        if not 'ajax' in response_format:
            if instance:
                queryset = queryset.exclude(pk__in=instance.links.all())

            choices = []
            for obj in queryset:
                human_type = obj.get_human_type()
                name = do_truncate(do_striptags(unicode(obj.object_name)), 20,
                                   True)
                if human_type:
                    name += u" (" + human_type + u")"
                choices.append((obj.id, name))
            self.fields['links'].choices = choices

        self.fields['links'].label = ""
        self.fields['links'].initial = ""
        self.fields['links'].widget.attrs.update({
            'class':
            'autocomplete',
            'callback':
            reverse('core_ajax_object_lookup')
        })
Beispiel #58
0
    def __init__(self, user, *args, **kwargs):
        super(ChangeSetForm, self ).__init__(*args, **kwargs)
        
        self.user = None
        if user:
            self.user = user
        
        self.fields['name'].label = _("Name")
        self.fields['name'].widget.attrs.update({'size': 50})
        
        self.fields['object'].label = _("Object")
        self.fields['object'] = ObjectModelChoiceField(label=_("Object"), 
                                                       queryset = Object.filter_permitted(user, 
                                                                                          Object.objects))
        self.fields['object'].widget.attrs.update({'class': 'autocomplete', 
                                                   'callback': reverse('core_ajax_object_lookup')})
        if 'object_id' in kwargs:
            self.fields['parent'].initial = kwargs['object_id']
            del kwargs['object_id']

        try:
            conf = ModuleSetting.get_for_module('treeio.changes', 'default_changeset_status')[0]
            default_changeset_status = ChangeSetStatus.objects.get(pk=long(conf.value))
            if not default_changeset_status.trash:
                self.fields['status'].initial = default_changeset_status.id
        except Exception:
            pass
        
        self.fields['status'].label = _("Status")
        self.fields['details'].label = _("Details")
Beispiel #59
0
 def __init__(self, user, *args, **kwargs):
     "Sets allowed values"
     if 'instance' in kwargs:
         self.instance = kwargs['instance']
         del kwargs['instance']
     
     super(MassActionForm, self).__init__(*args, **kwargs)
     
     self.fields['status'].queryset = Object.filter_permitted(user, TicketStatus.objects, mode='x')
     self.fields['status'].label = _("Status")
     self.fields['service'].queryset = Object.filter_permitted(user, Service.objects, mode='x')
     self.fields['service'].label = _("Service")
     self.fields['queue'].queryset = Object.filter_permitted(user, TicketQueue.objects, mode='x')
     self.fields['queue'].label = _("Queue")
     self.fields['delete'] = forms.ChoiceField(label=_("Delete"), choices=(('', '-----'),
                                                                           ('delete', _('Delete Completely')), 
                                                                           ('trash', _('Move to Trash'))), required=False)