コード例 #1
0
    def __init__(self, *args, **kwargs):
        im_state = get_available('im_state', *args, **kwargs)
        super(CompanyForm, self).__init__(*args, **kwargs)

        #append_choices_fileds
        self.fields['large_scale'] = forms.ChoiceField(
            choices=get_choices('large_scale'), required=False)
        self.fields['major_partner'] = forms.ChoiceField(
            choices=get_choices('major_partner'), required=False)
        self.fields['closed_net'] = forms.ChoiceField(
            choices=get_choices('closed_net'), required=False)
        self.fields['defense_industry'] = forms.ChoiceField(
            choices=get_choices('defense_industry'), required=False)
        self.fields['smart_factory'] = forms.ChoiceField(
            choices=get_choices('smart_factory'), required=False)

        #위젯 attribute 수정
        for key, field in self.fields.items():
            for config in attrs_configs:
                if key in config['fields']:
                    self.fields[key].widget.attrs[
                        config['attrs']] = config['value']

        self.fields['im_state'].widget = forms.HiddenInput()

        #im_state 초기 설정
        if im_state:
            self.fields['im_1'].initial = bool(int(im_state[0]))
            self.fields['im_2'].initial = bool(int(im_state[1]))
            self.fields['im_3'].initial = bool(int(im_state[2]))
            self.fields['im_4'].initial = bool(int(im_state[3]))
コード例 #2
0
class RansomwarePost(models.Model):
    company = models.ForeignKey(Company, on_delete=models.CASCADE)

    document_n = models.PositiveIntegerField()

    send_date = models.DateField(null=True, blank=True)

    agent_name = models.CharField(max_length=100)

    agent_ip = models.CharField(max_length=50)

    detect_date = models.DateField()

    path = models.CharField(max_length=100)

    reply = models.CharField(max_length=30, choices=get_choices('reply'))

    file_name = models.CharField(max_length=100)

    process_state = models.CharField(max_length=30, choices=get_choices('process_state'))

    created = models.DateTimeField(auto_now_add=True)

    updated = models.DateTimeField(auto_now=True)

    user = models.ForeignKey(User, on_delete=models.CASCADE)

    views = models.PositiveIntegerField(default=0)
コード例 #3
0
class Symptom(models.Model):
    detect_date = models.DateField()

    company = models.ForeignKey(Company, on_delete=models.CASCADE)

    product_name = models.CharField(max_length=100, choices=get_choices('product_name'))

    product_etc = models.CharField(max_length=200, null=True, blank=True)

    detect_name = models.CharField(max_length=100)

    start_point = models.CharField(max_length=100)

    end_point = models.CharField(max_length=100)

    dport = models.CharField(max_length=200)

    direction = models.CharField(max_length=100, choices=get_choices('direction'))

    event_report_etc = models.CharField(max_length=100, null=True, blank=True)

    response_type_etc = models.CharField(max_length=100, null=True, blank=True)

    country = models.CharField(max_length=100)

    attack_type = models.CharField(max_length=100, choices=get_choices('attack_class'))

    content = models.TextField()

    countermeasures = models.TextField()

    created = models.DateTimeField(auto_now_add=True)

    updated = models.DateTimeField(auto_now=True)

    user = models.ForeignKey(User, on_delete=models.CASCADE)

    views = models.PositiveIntegerField(default=0)

    def get_response_type(self):
        rts = list(self.response_type.all().values_list('value', flat=True))
        try:
            etc_idx = rts.index('기타')
            rts[etc_idx] = '기타(%s)'%(self.response_type_etc or ' ')

        except:
            pass

        return ', '.join(rts)

    def get_product_name(self):
        if self.product_name == '기타':
            return self.product_etc
        else:
            return self.product_name
コード例 #4
0
class DetectionPattern(models.Model):
    pattern_name = models.CharField(max_length=100, verbose_name='탐지 패턴명')

    risk = models.CharField(max_length=100, choices=get_choices('risk'))

    cve = models.CharField(max_length=100)

    rule_regist_date = models.DateField(null=True, blank=True)

    process_state = models.CharField(max_length=100, choices=get_choices('process_state'))

    equipment_class = models.CharField(max_length=100)

    equipment_etc = models.CharField(max_length=200, null=True, blank=True)

    attack_class = models.CharField(max_length=100)

    attack_class_etc = models.CharField(max_length=200, null=True, blank=True)

    attack_type = models.CharField(max_length=100)

    attack_type_etc = models.CharField(max_length=200, null=True, blank=True)

    content = models.TextField()

    countermeasures = models.TextField()

    created = models.DateTimeField(auto_now_add=True)

    updated = models.DateTimeField(auto_now=True)

    user = models.ForeignKey(User, on_delete=models.CASCADE)

    views = models.PositiveIntegerField(default=0)

    def get_equipment_class(self):
        if self.equipment_class == '기타':
            return self.equipment_etc
        else:
            return self.equipment_class

    def get_attack_class(self):
        if self.equipment_class == '기타':
            return self.attack_class_etc
        else:
            return self.attack_class

    def get_attack_type(self):
        if self.equipment_class == '기타':
            return self.attack_type_etc
        else:
            return self.attack_type
コード例 #5
0
class Outflow(models.Model):
    company = models.ForeignKey(Company, on_delete=models.CASCADE)

    document_n = models.PositiveIntegerField()

    send_date = models.DateField(null=True, blank=True)

    url = models.CharField(max_length=200)

    process_state = models.CharField(max_length=30, choices=get_choices('process_state'))

    content = models.TextField()

    created = models.DateTimeField(auto_now_add=True)

    updated = models.DateTimeField(auto_now=True)

    user = models.ForeignKey(User, on_delete=models.CASCADE)

    views = models.PositiveIntegerField(default=0)

    def get_weekness_as_text(self):
        weekness = self.weekness.all()
        text = ''
        for i in range(min(len(weekness), 3)):
            text += weekness[i].value + ', '
        if len(weekness) > 3:
            text += '등..'
        return text

    def get_weekness(self):
        weekness = self.weekness.all().values_list('value', flat=True)
        return ', '.join(weekness)
コード例 #6
0
class Schedule(models.Model):
    start_date = models.DateField()

    end_date = models.DateField()

    process_state = models.CharField(max_length=50, choices=get_choices('process_state'))

    title = models.CharField(max_length=200)

    content = models.TextField()

    file1 = models.FileField(upload_to='files/%Y/%m/%d', null=True, blank=True)

    file2 = models.FileField(upload_to='files/%Y/%m/%d', null=True, blank=True)

    user = models.ForeignKey(User, on_delete=models.CASCADE)

    created = models.DateTimeField(auto_now_add=True)

    updated = models.DateTimeField(auto_now=True)

    views = models.PositiveIntegerField(default=0)

    def get_popup_data(self):
        result = '작성자:%s <br> %s'%(self.user.user_name, self.content)
        return result

    @staticmethod
    def get_today():
        today = datetime.datetime.today()
        Q1 = Q(start_date__lte=today)
        Q2 = Q(end_date__gte=today)
        schedule = Schedule.objects.filter(Q1 & Q2).order_by('start_date')

        return schedule
コード例 #7
0
ファイル: views.py プロジェクト: parkgyoungin/crm
def updateDetectionpattern(request, id):
    subs = {
        'id_attack_class_0': get_choices('attack_class_sub1', defalut=False),
        'id_attack_class_1': get_choices('attack_class_sub2', defalut=False),
        'id_attack_class_2': get_choices('attack_class_sub3', defalut=False),
        'id_attack_class_3': get_choices('attack_class_sub4', defalut=False),
        'id_attack_class_4': [('기타', '기타')],
    }
    instance = DetectionPattern.objects.get(id=id)
    if request.method == 'POST':
        form = DetectionPatternForm(request.POST, instance=instance)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse(('main:home')))
    else:
        form = DetectionPatternForm(instance=instance)
    return render(request, 'post/detectionpattern/write.html', {
        'form': form,
        'subs': subs
    })
コード例 #8
0
class CompanyRecord(models.Model):
    company = models.ForeignKey(Company, on_delete=models.CASCADE, related_name='record')

    division = models.CharField(max_length=100, choices=get_choices('division'))

    process_method = models.CharField(max_length=100)

    process_method_etc = models.CharField(max_length=200, null=True, blank=True)

    occurr_date = models.DateTimeField()

    process_state = models.CharField(max_length=100, choices=get_choices('process_state'))

    title = models.TextField()

    content = models.TextField()

    manager_e_name = models.CharField(max_length=100, null=True, blank=True)

    manager_e_depart = models.CharField(max_length=100, null=True, blank=True)

    manager_e_phone = models.CharField(max_length=100, null=True, blank=True)

    manager_e_cphone = models.CharField(max_length=100, null=True, blank=True)

    manager_e_email = models.EmailField(max_length=100, null=True, blank=True)

    visible_m = models.BooleanField(null=True, blank=True, default=False, verbose_name='(정)')

    visible_s = models.BooleanField(null=True, blank=True, default=False, verbose_name='(부)')

    visible_e = models.BooleanField(null=True, blank=True, default=False, verbose_name='(기타)')

    created = models.DateTimeField(auto_now_add=True)

    updated = models.DateTimeField(auto_now=True)

    user = models.ForeignKey(User, on_delete=models.CASCADE)

    views = models.PositiveIntegerField(default=0)
コード例 #9
0
ファイル: views.py プロジェクト: parkgyoungin/crm
def writeDetectionpattern(request):
    subs = {
        'id_attack_class_0': get_choices('attack_class_sub1', defalut=False),
        'id_attack_class_1': get_choices('attack_class_sub2', defalut=False),
        'id_attack_class_2': get_choices('attack_class_sub3', defalut=False),
        'id_attack_class_3': get_choices('attack_class_sub4', defalut=False),
        'id_attack_class_4': [('기타', '기타')],
    }
    if request.method == 'POST':
        form = DetectionPatternForm(request.POST)
        if form.is_valid():
            obj = form.save(commit=False)
            obj.user = request.user
            obj.save()
            return HttpResponseRedirect(
                reverse("post:list", args=['detectionpattern']))
    else:
        form = DetectionPatternForm()
    return render(request, 'post/detectionpattern/write.html', {
        'form': form,
        'subs': subs
    })
コード例 #10
0
ファイル: models.py プロジェクト: parkgyoungin/crm
class Address(models.Model):
    address = models.CharField(max_length=200)

    address_old = models.CharField(max_length=200, null=True, blank=True)

    detail = models.CharField(max_length=100, null=True, blank=True)

    zip_code = models.CharField(max_length=20, null=True, blank=True)

    note = models.CharField(max_length=100, null=True, blank=True)

    location = models.CharField(max_length=20, choices=get_choices('location'))

    overseas_address = models.CharField(max_length=200, null=True, blank=True)
コード例 #11
0
    def __init__(self, *args, **kwargs):
        if kwargs.get('instance'):
            kwargs['instance'].occurr_date = kwargs[
                'instance'].occurr_date.strftime('%Y-%m-%dT%H:%M')
        occurr_date = get_available('occurr_date', *args, **kwargs)
        super(CompanyRecordForm, self).__init__(*args, **kwargs)
        self.fields['occurr_date'] = forms.DateTimeField(
            input_formats=['%Y-%m-%dT%H:%M'],
            widget=forms.TimeInput(attrs={'type': 'datetime-local'}))
        self.fields['company'].widget = forms.HiddenInput()
        self.fields['visible_m'].widget = forms.CheckboxInput()
        self.fields['visible_s'].widget = forms.CheckboxInput()
        self.fields['visible_e'].widget = forms.CheckboxInput()
        self.fields['process_method'] = forms.ChoiceField(
            choices=get_choices('process_method', defalut=False),
            widget=forms.RadioSelect)

        if occurr_date:
            print(occurr_date)
コード例 #12
0
ファイル: models.py プロジェクト: parkgyoungin/crm
class Ransomware(models.Model):
    contract = models.CharField(max_length=50,
                                null=True,
                                blank=True,
                                choices=get_choices('contract'))

    apply_n = models.IntegerField(null=True, blank=True)

    interlock_date = models.DateField(null=True, blank=True)

    termination_date = models.DateField(null=True, blank=True)

    termination_reason = models.CharField(max_length=50, null=True, blank=True)

    etc = models.CharField(max_length=255, null=True, blank=True)

    created = models.DateTimeField(auto_now_add=True)

    updated = models.DateTimeField(auto_now=True)
コード例 #13
0
class Notice(models.Model):
    title = models.CharField(max_length=200)

    content = models.TextField()

    file1 = models.FileField(upload_to='files/%Y/%m/%d', null=True, blank=True)

    file2 = models.FileField(upload_to='files/%Y/%m/%d', null=True, blank=True)

    user = models.ForeignKey(User, on_delete=models.CASCADE)

    views = models.PositiveIntegerField(default=0)

    created = models.DateTimeField(auto_now_add=True)

    updated = models.DateTimeField(auto_now=True)

    division = models.CharField(max_length=100, choices=get_choices('notice_division'))

    execute_date = models.DateField()

    answers = GenericRelation(Answer)
コード例 #14
0
    def __init__(self, *args, **kwargs):
        super(DetectionPatternForm, self).__init__(*args, **kwargs)
        to_date_widget(self.fields)
        self.fields['pattern_name'].widget.attrs['readonly'] = 'true'
        self.fields['content'].widget = SummernoteWidget()
        self.fields['equipment_class'] = forms.ChoiceField(
            widget=forms.RadioSelect,
            choices=get_choices('se_equipment_class', defalut=False))
        self.fields['attack_class'] = forms.ChoiceField(
            widget=forms.RadioSelect(attrs={'onclick': 'set_sub_list(this)'}),
            choices=get_choices('attack_class', defalut=False))

        subs = get_choices('attack_class_sub1') + get_choices(
            'attack_class_sub2', defalut=False) + get_choices(
                'attack_class_sub3', defalut=False) + get_choices(
                    'attack_class_sub4', defalut=False)
        self.fields['attack_type'] = forms.ChoiceField(widget=forms.Select,
                                                       choices=subs)

        self.fields['attack_class_etc'].widget.attrs[
            'placeholder'] = '기타선택시 입력하세요'
        self.fields['attack_type_etc'].widget.attrs[
            'placeholder'] = '기타선택시 입력하세요'
コード例 #15
0
ファイル: models.py プロジェクト: parkgyoungin/crm
class Company(models.Model):
    name = models.CharField(max_length=50, verbose_name='업체명')

    tenant = models.BooleanField(blank=True,
                                 default=False,
                                 verbose_name='입주기업')

    ss_security = models.CharField(max_length=20,
                                   choices=get_choices('service_state'),
                                   verbose_name='서비스현황-보안관제')

    ss_internal = models.CharField(max_length=20,
                                   choices=get_choices('service_state'),
                                   verbose_name='서비스현황-내부정보')

    ss_virus = models.CharField(max_length=20,
                                choices=get_choices('service_state'),
                                verbose_name='서비스현황-악성코드')

    ss_ransomware = models.CharField(max_length=20,
                                     choices=get_choices('service_state'),
                                     verbose_name='서비스현황-랜섬웨어')

    im_state = models.CharField(max_length=20, blank=True, default='0000')

    business_type = models.CharField(max_length=50,
                                     choices=get_choices('business_type'),
                                     verbose_name='사업자유형')

    business_etc = models.CharField(max_length=50, blank=True, null=True)

    business_uptae = models.CharField(max_length=50,
                                      choices=get_choices('business_uptae'),
                                      verbose_name='업태')

    business_class = models.CharField(max_length=50,
                                      choices=get_choices('business_class'),
                                      verbose_name='업종')

    join_path = models.CharField(max_length=50,
                                 choices=get_choices('join_path'),
                                 verbose_name='가입경로')

    top_name = models.CharField(max_length=50, verbose_name='대표자명')

    #top_email = models.EmailField()

    homepage = models.CharField(max_length=100,
                                null=True,
                                blank=True,
                                verbose_name='홈페이지')

    business_n = models.IntegerField(verbose_name='사업자번호')

    address = models.ForeignKey(Address,
                                on_delete=models.DO_NOTHING,
                                related_name='company_address')

    #install_address = models.ForeignKey(Address, on_delete=models.DO_NOTHING, related_name='install_address')

    operation_etc = models.CharField(max_length=50, null=True, blank=True)

    large_etc = models.CharField(max_length=50, null=True, blank=True)

    major_etc = models.CharField(max_length=50, null=True, blank=True)

    closed_etc = models.CharField(max_length=50, null=True, blank=True)

    defense_etc = models.CharField(max_length=50, null=True, blank=True)

    smart_etc = models.CharField(max_length=50, null=True, blank=True)

    large_scale = models.CharField(max_length=50,
                                   null=True,
                                   blank=True,
                                   choices=get_choices('large_scale'))

    major_partner = models.CharField(max_length=50,
                                     null=True,
                                     blank=True,
                                     choices=get_choices('major_partner'))

    closed_net = models.CharField(max_length=50,
                                  null=True,
                                  blank=True,
                                  choices=get_choices('closed_net'))

    defense_industry = models.CharField(
        max_length=50,
        null=True,
        blank=True,
        choices=get_choices('defense_industry'))

    smart_factory = models.CharField(max_length=50,
                                     null=True,
                                     blank=True,
                                     choices=get_choices('smart_factory'))

    manager_m_name = models.CharField(max_length=50, verbose_name='(정)-이름')

    manager_m_depart = models.CharField(max_length=50)

    manager_m_phone = models.IntegerField()

    manager_m_cphone = models.IntegerField()

    manager_m_email = models.EmailField()

    manager_s_name = models.CharField(max_length=50, null=True, blank=True)

    manager_s_depart = models.CharField(max_length=50, null=True, blank=True)

    manager_s_phone = models.IntegerField(null=True, blank=True)

    manager_s_cphone = models.IntegerField(null=True, blank=True)

    manager_s_email = models.EmailField(null=True, blank=True)

    manager_f_name = models.CharField(max_length=50, null=True, blank=True)

    manager_f_depart = models.CharField(max_length=50, null=True, blank=True)

    manager_f_phone = models.IntegerField(null=True, blank=True)

    manager_f_cphone = models.IntegerField(null=True, blank=True)

    manager_f_email = models.EmailField(null=True, blank=True)

    #bill_send_date = models.IntegerField()

    etc = models.TextField(null=True, blank=True)

    file = models.FileField(upload_to='files/%Y/%m/%d', null=True, blank=True)

    security = models.ForeignKey(Security, on_delete=models.DO_NOTHING)

    internal = models.ForeignKey(Internal, on_delete=models.DO_NOTHING)

    virus = models.ForeignKey(Virus, on_delete=models.DO_NOTHING)

    ransomware = models.ForeignKey(Ransomware, on_delete=models.DO_NOTHING)

    created = models.DateTimeField(auto_now_add=True)

    updated = models.DateTimeField(auto_now=True)

    user = models.ForeignKey(User, on_delete=models.CASCADE)

    views = models.PositiveIntegerField(default=0)

    colors = {
        '미사용': 'white',
        '사용중': 'green',
        '개통예정': 'darkviolet',
        '해지': 'red',
    }

    def get_area(self):
        try:
            address = self.address.address
            space = address.find(' ')
        except:
            address = ''
        return address[:space]

    def get_business_category(self):
        field_list = [
            self.large_scale, self.major_partner, self.closed_net,
            self.defense_industry, self.smart_factory, self.operation_etc
        ]
        datas = []
        for field in field_list:
            if field:
                datas.append(field)

        result = ', '.join(datas)
        html = '<span class="bscate">%s</span>' % result
        return html

    def get_im_state(self):
        value_list = ['보안관제', '내부보안', '악성코드', '랜섬웨어']
        result = ''
        for i, bite in enumerate(self.im_state):
            if int(bite):
                result += value_list[i] + '  '

        return result

    def get_address(self):
        ad = self.address
        result = '%s, %s  %s' % (
            ad.address,
            ad.detail,
            ad.note,
        )
        return result

    def set_ss_state_color(self):
        colors = dict(self.colors)
        colors['미사용'] = 'gainsboro'
        ids = [
            'ss_security',
            'ss_internal',
            'ss_virus',
            'ss_ransomware',
        ]
        result = []
        for id in ids:
            val = eval('self.%s' % id)
            color = colors[val]
            result.append('#%s {color:%s; font-weight:bold;}' % (id, color))
        return result

    def set_security_color(self):
        color = self.colors[self.ss_security]
        return 'style="color:%s; font-weight:bold;"' % color

    def set_internal_color(self):
        color = self.colors[self.ss_internal]
        return 'style="color:%s; font-weight:bold;"' % color

    def set_virus_color(self):
        color = self.colors[self.ss_virus]
        return 'style="color:%s; font-weight:bold;"' % color

    def set_ransomware_color(self):
        color = self.colors[self.ss_ransomware]
        return 'style="color:%s; font-weight:bold;"' % color

    @staticmethod
    def get_state():
        result = {
            'all': {
                'ss_security': {},
                'ss_internal': {},
                'ss_virus': {},
                'ss_ransomware': {},
                'total': {
                    'use': 0,
                    'soon': 0,
                    'termination': 0,
                    'sum': 0,
                    'sum_all': 0,
                }
            },
            'defense': {
                'ss_security': {},
                'ss_internal': {},
                'ss_virus': {},
                'ss_ransomware': {},
                'total': {
                    'use': 0,
                    'soon': 0,
                    'termination': 0,
                    'sum': 0,
                    'sum_all': 0,
                }
            },
        }
        fields = ['ss_security', 'ss_internal', 'ss_virus', 'ss_ransomware']
        Q1 = lambda field: "Q(%s = '사용중')" % field
        Q2 = lambda field: "Q(%s = '개통예정')" % field
        Q3 = lambda field: "Q(%s = '해지')" % field
        Q4 = lambda field: "Q(%s = '사용중') & Q(defense_industry__icontains = '방위')" % field
        Q5 = lambda field: "Q(%s = '개통예정') & Q(defense_industry__icontains = '방위')" % field
        Q6 = lambda field: "Q(%s = '해지') & Q(defense_industry__icontains = '방위')" % field

        for field in fields:
            use = result['all'][field][
                'use'] = Company.get_state_by_conditions(field, Q1)
            soon = result['all'][field][
                'soon'] = Company.get_state_by_conditions(field, Q2)
            termination = result['all'][field][
                'termination'] = Company.get_state_by_conditions(field, Q3)
            sum = result['all'][field][
                'sum'] = Company.get_state_by_conditions(field, Q1, Q2)
            sum_all = result['all'][field][
                'sum_all'] = Company.get_state_by_conditions(
                    field, Q1, Q2, Q3)
            result['all'][field][
                'content'] = "사용중 : %s , 개통예정 : %s, 해지 : %s <br> %s+%s (%s+%s+%s)" % (
                    result['all'][field]['use'], result['all'][field]['soon'],
                    result['all'][field]['termination'],
                    result['all'][field]['use'], result['all'][field]['soon'],
                    result['all'][field]['use'], result['all'][field]['soon'],
                    result['all'][field]['termination'])
            # += total
            result['all']['total']['use'] += use
            result['all']['total']['soon'] += soon
            result['all']['total']['termination'] += termination
            result['all']['total']['sum'] += sum
            result['all']['total']['sum_all'] += sum_all

            use = result['defense'][field][
                'use'] = Company.get_state_by_conditions(field, Q4)
            soon = result['defense'][field][
                'soon'] = Company.get_state_by_conditions(field, Q5)
            termination = result['defense'][field][
                'termination'] = Company.get_state_by_conditions(field, Q6)
            sum = result['defense'][field][
                'sum'] = Company.get_state_by_conditions(field, Q4, Q5)
            sum_all = result['defense'][field][
                'sum_all'] = Company.get_state_by_conditions(
                    field, Q4, Q5, Q6)
            result['defense'][field][
                'content'] = "사용중 : %s , 개통예정 : %s, 해지 : %s <br> %s+%s (%s+%s+%s)" % (
                    result['defense'][field]['use'],
                    result['defense'][field]['soon'],
                    result['defense'][field]['termination'],
                    result['defense'][field]['use'],
                    result['defense'][field]['soon'],
                    result['defense'][field]['use'],
                    result['defense'][field]['soon'],
                    result['defense'][field]['termination'])
            # += total
            result['defense']['total']['use'] += use
            result['defense']['total']['soon'] += soon
            result['defense']['total']['termination'] += termination
            result['defense']['total']['sum'] += sum
            result['defense']['total']['sum_all'] += sum_all

        result['all']['total'][
            'content'] = "사용중 : %s , 개통예정 : %s, 해지 : %s <br> %s+%s (%s+%s+%s)" % (
                result['all']['total']['use'], result['all']['total']['soon'],
                result['all']['total']['termination'],
                result['all']['total']['use'], result['all']['total']['soon'],
                result['all']['total']['use'], result['all']['total']['soon'],
                result['all']['total']['termination'])
        result['defense']['total'][
            'content'] = "사용중 : %s , 개통예정 : %s, 해지 : %s <br> %s+%s (%s+%s+%s)" % (
                result['defense']['total']['use'],
                result['defense']['total']['soon'],
                result['defense']['total']['termination'],
                result['defense']['total']['use'],
                result['defense']['total']['soon'],
                result['defense']['total']['use'],
                result['defense']['total']['soon'],
                result['defense']['total']['termination'])

        return result

    @staticmethod
    def get_state_by_conditions(field, *args):
        all_Q = Q()

        for q in args:
            all_Q = all_Q | eval(q(field))

        return Company.objects.filter(all_Q).count()
コード例 #16
0
ファイル: models.py プロジェクト: parkgyoungin/crm
class Security(models.Model):
    contract = models.CharField(max_length=50,
                                null=True,
                                blank=True,
                                choices=get_choices('contract'))

    block_permis = models.CharField(max_length=50,
                                    null=True,
                                    blank=True,
                                    choices=get_choices('block_permis'))

    send_date = models.DateField(null=True, blank=True)

    interlock_date = models.DateField(null=True, blank=True)

    serial = models.CharField(max_length=100, null=True, blank=True)

    expiry_date = models.DateField(null=True, blank=True)

    firmware = models.CharField(max_length=50, null=True, blank=True)

    equipment_class = models.CharField(max_length=50,
                                       null=True,
                                       blank=True,
                                       choices=get_choices('equipment_class'))

    ownership = models.CharField(max_length=50,
                                 null=True,
                                 blank=True,
                                 choices=get_choices('ownership'))

    access_permis = models.CharField(max_length=50,
                                     null=True,
                                     blank=True,
                                     choices=get_choices('access_permis'))

    termination_date = models.DateField(null=True, blank=True)

    termination_reason = models.CharField(max_length=50, null=True, blank=True)

    ips_rule = models.CharField(max_length=30,
                                null=True,
                                blank=True,
                                choices=get_choices('ips_check'))

    sys_log = models.CharField(max_length=30,
                               null=True,
                               blank=True,
                               choices=get_choices('ips_check'))

    icmp = models.CharField(max_length=30,
                            null=True,
                            blank=True,
                            choices=get_choices('ips_check'))

    snmp = models.CharField(max_length=30,
                            null=True,
                            blank=True,
                            choices=get_choices('ips_check'))

    snmp_sub = models.CharField(max_length=30,
                                null=True,
                                blank=True,
                                choices=get_choices('snmp_sub'))

    etc = models.CharField(max_length=255, null=True, blank=True)

    created = models.DateTimeField(auto_now_add=True)

    updated = models.DateTimeField(auto_now=True)