6.27-6.28 JLL--实习日志Tips for Horizon+ retail_interface

  1. 下拉框机制的整体运行的流程
    1.1在 form_policy下面 会有一个 true_false_choice =[ ('后台',u''),()] 表示的下拉框的显示值,
    1.2selection_box.py 有一个 selection_box = [] 作用是在前端进行识别,如果在这个list 里面的都会被默认为 下拉框的形式 ,相当于一个 快捷键的形式
    1.3 form.py 中有一个属性是 widgets 表示的是 里面决定了下拉框 的内容, 表示的是这个form里面有两个下拉框 ,并且下拉框的值
  widgets = {'EmployeeTitle': forms.Select(choices=employee_title_choices),
            'EmployeeDepartment': forms.Select(choices=employee_department_choices),
        }

1.4 前端 判断 是不是在 selectionbox里面 如果是在selectionbox里面就形成新的下拉框的形式

1.5 小知识点,label 的for 标签就是相当于id的作用,并且是自动实现的,格式是id_field.label_tag

<label for="id_Pref_Brand_Name_Flg">Preferred Brand Name Flag:</label>

1.6 前端通过 Js的方式,进行check 的机制 和样式选择 <select class="form-control">


需要写一些 interface
要求 如下

Add a search page in navbar to get full JLL broker list, using value from User Role. Reference the code from view_jll_contact.

Add new attributes to indicate and protect primary broker:
PrimaryBroker: a foreign key field (null=True, blank=True) in brand level to reference user role.

Add a timeout mechanism in the primary broker list interface under brand detail with a timeout configuration parameter (default to 120 days).
If last conversation timestamp from primary broker is not timeout:
list the current PrimaryBroker as 1st, and set 2nd - 5th brokers using current logic.
If last conversation timestamp from primary broker is timeout:
Change the PrimaryBroker to the most up-to-date conversation owner.
list the current PrimaryBroker as 1st, and set 2nd - 5th brokers using current logic.

Add a function SetPrimaryBroker, with a GET parameter "brand_id" (No front-end UI for now, this function would be used in future stage):
If current primary broker cannot reference to a user role (which means blank):
Use brand_id and user (get the UserRole) to add primary broker in Brand.
If current primary broker reference to a user role:
Remove current UserRole reference in brand (use brand_id to get).
Use brand_id and user (get the UserRole) to add primary broker in Brand.

view 端
需要有个leader设置primary-contact的功能,set_primary_contact 输入的是 userrole_id,brand_id 然后save
有一个定期刷新的primary-contact 的 功能,refresh_primary_contact()

def refresh_primary_contact():
    Conversation_instances = Conversation_Brand.objects.all()
    brand_instances = Brand.objects.all()
    for brand_instance in brand_instances:
        conversations = Conversation_Brand.objects.filter(Q(Brand=brand_instance)).order_by('-Created_On')[:5]
        #check the proetcctperiod exist ? check outtime ?
        if not brand_instance.PrimaryContact:# no PrimaryContact add ,else check the timestamp
            conversation_instance = Conversation_Brand.objects.filter(Q(Brand=brand_instance)).order_by('-Created_On').first()
            if conversation_instance:
                brand_instance.PrimaryContact = Conversation_Brand.objects.filter(Q(Brand=brand_instance)).order_by('-Created_On').first().JLL_Contact
        else:
            if (brand_instance.Protect_period +str(120) <= time.strftime('%Y%m%d')):
                brand_instance.Protect_period = ''# free the protect
                conversation_time_stamp = Conversation_Brand.objects.filter(~Q(Brand.PrimaryContact == None)).order_by('-Created_On')[0].Modified_On.timetuple()
                conversation_time_stamp1 = int(time.mktime(conversation_time_stamp)*1000)
                now = datetime.datetime.now()
                now_time_stamp =  int(time.mktime(now)*1000)
                time_minus = round((now_time_stamp-conversation_time_stamp1)/ 86400);
                if time_minus >= 120:
                    brand_instance.PrimaryContact = Conversation_Brand.objects.filter(Q(Brand=brand_instance)).order_by('-Created_On')[0].JLL_Contact
        brand_instance.save()
    return True

@login_required      
def set_primary_contact(brand_id,userrole_id):
    brand_instance=get_object_or_404(Brand,pk=int(brand_id))
    user_role = get_object_or_404(UserRole,pk=int(userrole_id))
    brand_instance.Protect_period = time.strftime('%Y%m%d %H%M')
    brand_instance.save()
    return True
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值