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

来源:互联网 发布:davinci软件 编辑:程序博客网 时间:2024/06/08 06:41
  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
原创粉丝点击