Best Python code snippet using avocado_python
workflow_admin_modify.py
Source:workflow_admin_modify.py
1# -*- coding: utf-8 -*-2from django import template3register = template.Library()4@register.inclusion_tag('workflow/submit_line.html', takes_context=True)5def workflow_model_submit_row(context):6 """7 Displays the row of buttons for delete and save.8 """9 opts = context['opts']10 change = context['change']11 is_popup = context['is_popup']12 save_as = context['save_as']13 has_content_admin_permission = context.get(14 'has_content_admin_permission', True)15 has_content_manager_permission = context.get(16 'has_content_manager_permission', False)17 can_be_branched = context.get('can_be_branched', True)18 change_status_only = context.get('change_status_only', False)19 working_with_version = context.get('working_with_version', False)20 has_children = context.get('has_children', False)21 is_approved = context.get('is_approved', False)22 is_recovering = context.get('is_recovering', False)23 is_pending = context.get('is_pending', False)24 show_manager_extra = has_content_manager_permission \25 and change \26 and can_be_branched27 result = {28 'onclick_attrib': (opts.get_ordered_objects() and change29 and 'onclick="submitOrderForm();"' or ''),30 'is_recovering': is_recovering,31 'is_popup': is_popup,32 'is_new': not change,33 }34 if is_recovering:35 result.update({36 'show_delete_link': False,37 'show_save_as_new': False,38 'show_save_and_add_another': False,39 'show_save_and_continue': False,40 'show_save': False,41 'show_save_to_history': False,42 'show_send_to_approve': False,43 'show_change_status': False,44 })45 else:46 result.update({47 'show_delete_link': (not is_popup and has_content_admin_permission48 and (change or context.get('show_delete', False))) \49 and not has_children and not is_approved,50 'delete_url': context.get('delete_url', 'delete/'),51 'show_save_as_new': not is_popup and save_as and change52 and not change_status_only,53 'show_save_and_add_another': context['has_add_permission'] and54 not is_popup and (not save_as or context['add']) and55 (not change or can_be_branched) and not change_status_only,56 'show_save_and_continue': not is_popup and context['has_change_permission'] and57 (not change or can_be_branched) and not change_status_only,58 'show_save': ((has_content_admin_permission and can_be_branched59 and not change_status_only and not is_pending) or not change),60 'show_save_to_history': (show_manager_extra or has_content_admin_permission)61 and not change_status_only and can_be_branched,62 'save_style': '' if (has_content_admin_permission and change) else 'default',63 'show_send_to_approve': show_manager_extra,64 'show_change_status': working_with_version and has_content_admin_permission65 and is_pending,66 'can_be_branched': can_be_branched,67 })...
Variable.py
Source:Variable.py
...31 # function to write in a variable32 def write(self, transaction, value):33 self._uncommitted_value = (transaction['_id'], value)34 # function to check variable status 'RECOVERING'35 def is_recovering(self):36 return self._status == VariableStatus.RECOVERING37 # function to read uncommitted value from a variable38 def read_uncommitted(self, transaction):39 if self._uncommitted_value[0] == transaction['_id']:40 return self._uncommitted_value[1]41 # Transaction with write lock, but hasn't written42 return self.read_committed(transaction)43 # function to load uncommited value44 def load_uncommitted(self, value):45 self._uncommitted_value = value46 # function to dump commited value47 def dump_committed(self):48 return self._committed_values49 # function to set variable status50 def recover(self):51 self._status = VariableStatus.RECOVERING52 # function to check if replicated53 def is_replicated(self):54 var_index = int(self._id[1:])55 return (var_index % 2) == 056 # function to commit value in a variable57 def commit(self, timestamp):58 if self.is_recovering():59 self._status = VariableStatus.ACTIVE60 self._committed_values.append((timestamp, self._uncommitted_value))61 # function to load commited value62 def load_committed(self, values):63 self._committed_values = values64 # function to commit value in a variable65 def commit(self, timestamp):66 if self.is_recovering():67 self._status = VariableStatus.ACTIVE68 self._committed_values.append((timestamp, self._uncommitted_value))69 # function to dump uncommited value70 def dump_uncommitted(self):71 return self._uncommitted_value72 # function to load state73 def load_state(self, committed_values, uncommitted_values):74 self.load_committed(committed_values)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!