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


Python models.ModuleSetting类代码示例

本文整理汇总了Python中treeio.core.models.ModuleSetting的典型用法代码示例。如果您正苦于以下问题:Python ModuleSetting类的具体用法?Python ModuleSetting怎么用?Python ModuleSetting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setUp

    def setUp(self):
        "Initial Setup"

        if not self.prepared:
            self.group, created = Group.objects.get_or_create(name='test')
            duser, created = DjangoUser.objects.get_or_create(username=self.username)
            duser.set_password(self.password)
            duser.save()
            self.user, created = User.objects.get_or_create(user=duser)
            self.user.save()
            perspective, created = Perspective.objects.get_or_create(name='default')
            perspective.set_default_user()
            perspective.save()
            ModuleSetting.set('default_perspective', perspective.id)
            
            self.contact_type = ContactType(name='test')
            self.contact_type.set_default_user()
            self.contact_type.save()   
        
            self.contact = Contact(name='test', contact_type=self.contact_type)
            self.contact.set_default_user()
            self.contact.save()
            
            self.stream = MessageStream(name='test')
            self.stream.set_default_user()
            self.stream.save()
            
            self.message = Message(title='test', body='test', author=self.contact, stream=self.stream)
            self.message.set_default_user()
            self.message.save()
                    
            self.client = Client()  
            
            self.prepared = True
开发者ID:3atmospheres,项目名称:treeio,代码行数:34,代码来源:tests.py

示例2: setUp

    def setUp(self):
        "Initial Setup"

        if not self.prepared:
            Object.objects.all().delete()

            # Create objects
            self.group, created = Group.objects.get_or_create(name='test')
            duser, created = DjangoUser.objects.get_or_create(username=self.username)
            duser.set_password(self.password)
            duser.save()
            self.user, created = User.objects.get_or_create(user=duser)
            self.user.save()
            perspective, created = Perspective.objects.get_or_create(name='default')
            perspective.set_default_user()
            perspective.save()
            ModuleSetting.set('default_perspective', perspective.id) 

            self.perspective = Perspective(name='test')
            self.perspective.set_default_user()
            self.perspective.save()

            self.group = Group(name='test')
            self.group.save()

            self.client = Client()

            self.prepared = True
开发者ID:3atmospheres,项目名称:treeio,代码行数:28,代码来源:tests.py

示例3: setUp

 def setUp(self):
     "Initial Setup"
     if not self.prepared:
         # Clean up first
         Object.objects.all().delete()
         
         # Create objects
         try:
             self.group = Group.objects.get(name='test')
         except Group.DoesNotExist:
             Group.objects.all().delete()
             self.group = Group(name='test')
             self.group.save()
         
         try:
             self.user = DjangoUser.objects.get(username=self.username)
             self.user.set_password(self.password)
             try:
                 self.profile = self.user.get_profile()
             except Exception:
                 User.objects.all().delete()
                 self.user = DjangoUser(username=self.username, password='')
                 self.user.set_password(self.password)
                 self.user.save()
         except DjangoUser.DoesNotExist:
             User.objects.all().delete()
             self.user = DjangoUser(username=self.username, password='')
             self.user.set_password(self.password)
             self.user.save()
             
         try:
             perspective = Perspective.objects.get(name='default')
         except Perspective.DoesNotExist:
             Perspective.objects.all().delete()
             perspective = Perspective(name='default')
             perspective.set_default_user()
             perspective.save()
         ModuleSetting.set('default_perspective', perspective.id)
         
         self.folder = KnowledgeFolder(name='test', treepath='test')
         self.folder.set_default_user()
         self.folder.save()
         
         self.category = KnowledgeCategory(name='test', treepath='test')
         self.category.set_default_user()
         self.category.save()
         
         self.item = KnowledgeItem(name='test', folder=self.folder, 
                                   category=self.category, treepath='test')
         self.item.set_default_user()
         self.item.save()
         
         # parent folder
         self.parent = KnowledgeFolder(name='test', treepath='test')
         self.parent.set_default_user()
         self.parent.save()
         
         self.client = Client()
         
         self.prepared = True
开发者ID:KristianOellegaard,项目名称:treeio,代码行数:60,代码来源:tests.py

示例4: __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

示例5: setUp

 def setUp(self):
     "Initial Setup"
     
     if not self.prepared:
         # Clean up first
         Object.objects.all().delete()
         
         # Create objects
         self.group, created = Group.objects.get_or_create(name='test')
         duser, created = DjangoUser.objects.get_or_create(username=self.username)
         duser.set_password(self.password)
         duser.save()
         self.user, created = User.objects.get_or_create(user=duser)
         self.user.save()
         perspective, created = Perspective.objects.get_or_create(name='default')
         perspective.set_default_user()
         perspective.save()
         ModuleSetting.set('default_perspective', perspective.id)
         
         self.contact_type = ContactType(name='Person')
         self.contact_type.set_default_user()
         self.contact_type.save()
         
         self.contact = Contact(name='Test', contact_type=self.contact_type)
         self.contact.set_default_user()
         self.contact.save()
         
         self.field = ContactField(name='Test', label='test', field_type='text')
         self.field.set_default_user()
         self.field.save()
                 
         self.client = Client()
         
         self.prepared = True
开发者ID:BenoitNorrin,项目名称:treeio,代码行数:34,代码来源:tests.py

示例6: setUp

    def setUp(self):
        "Initial Setup"

        if not self.prepared:
            # Clean up first
            Object.objects.all().delete()

            # Create objects
            self.group, created = Group.objects.get_or_create(name='test')
            duser, created = DjangoUser.objects.get_or_create(
                username=self.username)
            duser.set_password(self.password)
            duser.save()
            self.user, created = User.objects.get_or_create(user=duser)
            self.user.save()
            perspective, created = Perspective.objects.get_or_create(
                name='default')
            perspective.set_default_user()
            perspective.save()

            ModuleSetting.set('default_perspective', perspective.id)

            self.event = Event(name='TestStatus', end=datetime.now())
            self.event.set_default_user()
            self.event.save()

            self.client = Client()

            self.prepared = True
开发者ID:AlexLX2,项目名称:treeio,代码行数:29,代码来源:tests.py

示例7: __init__

 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
开发者ID:jmfield2,项目名称:treeio,代码行数:34,代码来源:forms.py

示例8: setUp

    def setUp(self):
        "Initial Setup"

        if not self.prepared:
            Object.objects.all().delete()

            # Create objects

            try:
                self.group = Group.objects.get(name='test')
            except Group.DoesNotExist:
                Group.objects.all().delete()
                self.group = Group(name='test')
                self.group.save()

            try:
                self.user = DjangoUser.objects.get(username=self.username)
                self.user.set_password(self.password)
                try:
                    self.profile = self.user.get_profile()
                except Exception:
                    User.objects.all().delete()
                    self.user = DjangoUser(username=self.username, password='')
                    self.user.set_password(self.password)
                    self.user.save()
            except DjangoUser.DoesNotExist:
                User.objects.all().delete()
                self.user = DjangoUser(username=self.username, password='')
                self.user.set_password(self.password)
                self.user.save()

            try:
                perspective = Perspective.objects.get(name='default')
            except Perspective.DoesNotExist:
                Perspective.objects.all().delete()
                perspective = Perspective(name='default')
                perspective.set_default_user()
                perspective.save()

            ModuleSetting.set('default_perspective', perspective.id)

            self.folder = Folder(name='test')
            self.folder.set_default_user()
            self.folder.save()

            self.document = Document(title='test_document', folder=self.folder)
            self.document.set_default_user()
            self.document.save()

            self.file = File(name='test_file', folder=self.folder)
            self.file.set_default_user()
            self.file.save()

            self.link = WebLink(title='test', folder=self.folder, url='test')
            self.link.set_default_user()
            self.link.save()

            self.client = Client()

            self.prepared = True
开发者ID:AlexLX2,项目名称:treeio,代码行数:60,代码来源:tests.py

示例9: email_caller_on_new_ticket

def email_caller_on_new_ticket(sender, instance, created, **kwargs):
    "When a new ticket is created send an email to the caller"
    if created:
        send_email_to_caller = False
        try:
            conf = ModuleSetting.get_for_module("treeio.services", "send_email_to_caller")[0]
            send_email_to_caller = conf.value
        except:
            send_email_to_caller = getattr(settings, "HARDTREE_SEND_EMAIL_TO_CALLER", True)

        if send_email_to_caller:
            # don't send email to yourself
            creator_contact = None
            if instance.creator:
                creator_contact = instance.creator.get_contact()

            if instance.caller and instance.caller != creator_contact:
                if not instance.reference:
                    if instance.queue:
                        instance.reference = instance.queue.ticket_code + str(instance.id)
                    else:
                        instance.reference = str(instance.id)
                    instance.save()
                subject = "[#%s] %s" % (instance.reference, instance.name)

                # Construct context and render to html, body
                context = {"ticket": instance}
                try:
                    conf = ModuleSetting.get_for_module("treeio.services", "send_email_template")[0]
                    send_email_template = conf.value
                    html = render_string_template(send_email_template, context)
                except Exception, e:
                    html = render_to_string("services/emails/notify_caller", context, response_format="html")
                body = strip_tags(html)

                if instance.queue and instance.queue.message_stream:
                    stream = instance.queue.message_stream
                    if stream.outgoing_server_name:
                        try:
                            caller_email = instance.caller.get_email()
                            if caller_email:
                                toaddr = caller_email
                                ssl = False
                                if stream.outgoing_server_type == "SMTP-SSL":
                                    ssl = True
                                email = BaseEmail(
                                    stream.outgoing_server_name,
                                    stream.outgoing_server_username,
                                    stream.outgoing_password,
                                    stream.outgoing_email,
                                    toaddr,
                                    subject,
                                    body,
                                    html=html,
                                    ssl=ssl,
                                )
                                email.process_email()
                        except:
                            pass
开发者ID:nrazon,项目名称:treeio,代码行数:59,代码来源:models.py

示例10: htdate

def htdate(context, date, dateformat='DATE_FORMAT'):
    """ Render date in the current locale
    
    To render date in a custom format use Django format, details:
    http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
    
    """
    
    if not date:
        return ''
    
    lang = translation.get_language()
    
    localeformat = dateformat
    formatspath = getattr(settings, 'FORMAT_MODULE_PATH', 'treeio.formats')
    try:
        modulepath = formatspath + "." + lang + ".formats"
        module = __import__(modulepath, fromlist=[str(modulepath)])
        localeformat = getattr(module, dateformat, dateformat)
    except ImportError:
        pass
    
    request = context['request']
    
    user = None
    if request.user.username:
        try: 
            user = request.user.get_profile()
        except Exception:
            pass
        
    # timezone
    default_timezone = settings.HARDTREE_SERVER_DEFAULT_TIMEZONE
    try:
        conf = ModuleSetting.get('default_timezone')[0]
        default_timezone = conf.value
    except:
        pass
     
    try:
        conf = ModuleSetting.get('default_timezone', user=user)[0]
        default_timezone = conf.value
    except Exception:
        default_timezone = getattr(settings, 'HARDTREE_SERVER_TIMEZONE')[default_timezone][0]
        
    all_timezones = getattr(settings, 'HARDTREE_SERVER_TIMEZONE', [(1, '(GMT-11:00) International Date Line West')])
    title = all_timezones[int(default_timezone)][1]
    GMT = title[4:10] # with sign e.g. +06:00
    sign = GMT[0:1] # + or -
    hours = int(GMT[1:3]) # e.g. 06
    mins = int(GMT[4:6])

    if sign == "-":
        date = date - timedelta(hours=hours, minutes=mins)
    else: 
        date = date + timedelta(hours=hours, minutes=mins)
    
    result = djangodate(date, localeformat)
    return Markup(result)
开发者ID:appost,项目名称:treeio,代码行数:59,代码来源:modules.py

示例11: create_ticket_from_message

def create_ticket_from_message(sender, instance, created, **kwargs):
    """
    Get a signal from messaging.models
    Check if (new) message's stream is also assigned to Ticket Queue
    Create a new ticket from that message
    Rename original message title
    """
    
    if created and getattr(instance, 'auto_notify', True):
        if instance.reply_to:
            tickets = instance.reply_to.ticket_set.all()
            for ticket in tickets:
                record = TicketRecord()
                record.sender = instance.author
                record.record_type = 'manual'
                record.body = instance.body
                record.save()
                record.about.add(ticket)
                ticket.set_last_updated()
                try:
                    conf = ModuleSetting.get_for_module('treeio.services', 'default_ticket_status')[0]
                    ticket.status = TicketStatus.objects.get(pk=long(conf.value))
                except:
                    statuses = TicketStatus.objects.all()
                    ticket.status = statuses[0]
                ticket.save()
        else:
            stream = instance.stream
            queues = TicketQueue.objects.filter(message_stream=stream)
            if stream and queues:
                queue = queues[0]
                ticket = Ticket()
                try:
                    conf = ModuleSetting.get_for_module('treeio.services', 'default_ticket_status')[0]
                    ticket.status = TicketStatus.objects.get(pk=long(conf.value))
                except:
                    statuses = TicketStatus.objects.all()
                    ticket.status = statuses[0]
                ticket.queue = queue
                ticket.caller = instance.author
                ticket.details = instance.body
                ticket.message = instance
                ticket.name = instance.title
                ticket.auto_notify = False
                ticket.save()
                try:
                    if stream.creator:
                        ticket.set_user(stream.creator)
                    elif queue.creator:
                        ticket.set_user(queue.creator)
                    else:
                        ticket.copy_permissions(queue)
                except:
                    pass
                
                # Rename original message title
                instance.title = "[#" + ticket.reference + "] " + instance.title
                instance.save()
开发者ID:pascalmouret,项目名称:treeio,代码行数:58,代码来源:models.py

示例12: save

 def save(self):
     "Form processor"
     try:
         ModuleSetting.set_for_module('default_contact_type',
                                      self.cleaned_data['default_contact_type'].id,
                                      'treeio.identities')
         
     except Exception:
         return False
开发者ID:KristianOellegaard,项目名称:treeio,代码行数:9,代码来源:forms.py

示例13: __init__

    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")
开发者ID:MechanisM,项目名称:treeio,代码行数:57,代码来源:forms.py

示例14: save

    def save(self):
        "Form processor"
        try:
            ModuleSetting.set_for_module(
                "default_item_status", self.cleaned_data["default_item_status"].id, "treeio.infrastructure"
            )

        except Exception:
            return False
开发者ID:ctburley,项目名称:treeio,代码行数:9,代码来源:forms.py

示例15: save

    def save(self):
        "Form processor"
        try:
            ModuleSetting.set_for_module('default_changeset_status',
                                         self.cleaned_data['default_changeset_status'].id,
                                         'treeio.changes')
            return True

        except Exception:
            return False
开发者ID:3atmospheres,项目名称:treeio,代码行数:10,代码来源:forms.py


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