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


Python models.ModuleSetting类代码示例

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


在下文中一共展示了ModuleSetting类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:alejo8591,项目名称:maker,代码行数: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:alejo8591,项目名称:maker,代码行数:28,代码来源:tests.py

示例3: __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('maker.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('maker.messaging', 'default_imap_folder',
                                             user=user)[0]
         self.fields['default_imap_folder'].initial = conf.value
     except:
         self.fields['default_imap_folder'].initial = settings.MAKER_MESSAGING_IMAP_DEFAULT_FOLDER_NAME
     
     
     self.fields['signature'].label = _('Signature')
     try:
         conf = ModuleSetting.get_for_module('maker.messaging', 'signature',
                                             user=user, strict=True)[0]
         signature = conf.value
         self.fields['signature'].initial = signature
     except:
         pass
开发者ID:alejo8591,项目名称:maker,代码行数:34,代码来源:forms.py

示例4: 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:alejo8591,项目名称:maker,代码行数:60,代码来源:tests.py

示例5: 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:alejo8591,项目名称:maker,代码行数:60,代码来源:tests.py

示例6: 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', 'maker.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.MAKER_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, 'MAKER_SERVER_TIMEZONE')[default_timezone][0]
        
    all_timezones = getattr(settings, 'MAKER_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:alejo8591,项目名称:maker,代码行数:59,代码来源:modules.py

示例7: save

    def save(self):
        "Form processor"
        try:
            ModuleSetting.set_for_module('default_task_status',
                                         self.cleaned_data['default_task_status'].id,
                                         'maker.projects')

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

示例8: 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('maker.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('maker.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:alejo8591,项目名称:maker,代码行数:54,代码来源:models.py

示例9: 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.event = Event(name='TestStatus', end=datetime.now())
            self.event.set_default_user()
            self.event.save()

            self.client = Client()

            self.prepared = True
开发者ID:alejo8591,项目名称:maker,代码行数:48,代码来源:tests.py

示例10: profile_check

def profile_check(request):
    "If nuvius_id within GET parameters of the request, store the ID within Django session"
    nuvius_id = request.GET.get('nuvius_id', None)
    if nuvius_id:
        nuvius_key = request.GET.get('profile_key', None)
        if nuvius_key:
            con = Connector(profile_id=nuvius_id, profile_key=nuvius_key)
            profile = con.get_profile()
            try:
                if profile['key_valid']:
                    request.session['nuvius_id'] = nuvius_id
                    request.session['nuvius_profile_key'] = nuvius_key
            except KeyError:
                pass
        else:
            request.session['nuvius_id'] = nuvius_id
    
    response = HttpResponse(json.dumps(profile), mimetype='application/json')
    
    # Hardtree code
    if 'applications' in profile:
        del profile['applications']
    if 'bindings' in profile:
        del profile['bindings']
    user = request.user.get_profile()
    conf = ModuleSetting.set('nuvius_profile', '', user=user)
    conf.dumps(profile).save()
    # End of Hardtree code
    
    return response
开发者ID:alejo8591,项目名称:maker,代码行数:30,代码来源:views.py

示例11: core_logo_content

def core_logo_content(context, gif=False):
    "Return current logo encoded as base64"
    
    staticpath = getattr(settings, 'STATIC_DOC_ROOT', './static')
    logopath = staticpath + '/logo'
    if gif:
        logopath += '.gif'
        mimetype = 'image/gif'
    else:
        logopath += '.png'
        mimetype = 'image/png'
    
    customlogo = ''
    try:
        conf = ModuleSetting.get_for_module('maker.core', 'logopath')[0]
        customlogo = getattr(settings, 'MEDIA_ROOT', './static/media') + conf.value
    except:
        pass
    
    logofile = ''
    if customlogo:
        try:
            logofile = open(customlogo, 'r')
        except:
            pass
    
    if not logofile:
        try:
            logofile = open(logopath, 'r')
        except:
            pass
    
    result = "data:" + mimetype + ";base64," + base64.b64encode(logofile.read())
    
    return Markup(result)
开发者ID:alejo8591,项目名称:maker,代码行数:35,代码来源:modules.py

示例12: integration_view

def integration_view(request, conf_id, response_format='html'):
    "Integration view resource page"
    
    user = request.user.get_profile()
    
    resconf = get_object_or_404(ModuleSetting, pk=conf_id)
    res = resconf.loads()
    
    conf = ModuleSetting.get('nuvius_profile', user=user)
    try:
        profile = conf[0].loads()
    except IndexError:
        profile = None
    
    resource = None
    if profile:
        connector = Connector(request, profile_id=profile['id'])
        resource = DataBlock(connector.get_app(res.resource_id))
        if request.POST and 'delete' in request.POST:
            resconf.delete()
            return HttpResponseRedirect(reverse('events_integration_index'))
        
    context = {'conf_id': conf_id, 'resource': resource}
    
    return render_to_response('events/integration_view', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:alejo8591,项目名称:maker,代码行数:26,代码来源:views.py

示例13: settings_view

def settings_view(request, response_format='html'):
    "Settings"
    
    if not request.user.get_profile().is_admin('maker.infrastructure'):
        return user_denied(request, message="You are not an Administrator of the Infrastructure module", 
                           response_format=response_format)
    
    item_types = ItemType.objects.all().filter(trash=False)
    item_statuses = ItemStatus.objects.all().filter(trash=False)
    item_fields = ItemField.objects.all().filter(trash=False)
    
    default_item_status = None
    try:
        conf = ModuleSetting.get_for_module('maker.infrastructure', 'default_item_status')[0]
        default_item_status = ItemStatus.objects.get(pk=long(conf.value), trash=False)
    except Exception:
        pass
        
    context = _get_default_context(request)
    context.update({'item_types': item_types,
                    'item_fields': item_fields,
                    'item_statuses': item_statuses,
                    'default_item_status': default_item_status})
    
    return render_to_response('infrastructure/settings_view', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:alejo8591,项目名称:maker,代码行数:26,代码来源:views.py

示例14: invoice

 def invoice(self):
     "Create a new sale order for self"
     new_invoice = SaleOrder()
     try:
         conf = ModuleSetting.get_for_module('maker.sales', 'default_order_status')[0]
         new_invoice.status = long(conf.value)
     except Exception:
         ss = SaleStatus.objects.all()[0]
         new_invoice.status = ss
     so = SaleSource.objects.all()[0]
     new_invoice.source = so
     new_invoice.client = self.client
     new_invoice.reference = "Subscription Invoice " + str(datetime.today().strftime('%Y-%m-%d'))
     new_invoice.save()
     try:
         op = self.orderedproduct_set.filter(trash=False).order_by('-date_created')[0]
         opn = OrderedProduct()
         opn.order = new_invoice
         opn.product = self.product
         opn.quantity = op.quantity
         opn.discount = op.discount
         opn.subscription = self
         opn.save()
     except IndexError:
         opn = OrderedProduct()
         opn.order = new_invoice
         opn.product = self.product
         opn.quantity = 1
         opn.subscription = self
         opn.save()
     return new_invoice.reference
开发者ID:alejo8591,项目名称:maker,代码行数:31,代码来源:models.py


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