input
stringlengths
11
7.65k
target
stringlengths
22
8.26k
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def get_repository_root(cls, location): loc = super(Git, cls).get_repository_root(location) if loc: return loc try: r = cls.run_command( ['rev-parse', '--show-toplevel'], cwd=location, show_stdout=False, stdo...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def get_spec(field, limit=10, query='', query_dsl=''): """Returns aggregation specs for a term of filtered events. The aggregation spec will summarize values of an attribute whose events fall under a filter. Args: field (str): this denotes the event attribute that is used for aggre...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __call__(self, env, start_response): return env
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def chart_title(self): """Returns a title for the chart.""" if self.field: return 'Top filtered results for "{0:s}"'.format(self.field) return 'Top results for an unknown field after filtering'
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def read(self, path): raise Exception('read called with %r' % path)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def run( self, field, query_string='', query_dsl='', supported_charts='table', start_time='', end_time='', limit=10): """Run the aggregation. Args: field (str): this denotes the event attribute that is used for aggregation. query_string (s...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def read(self, path): return False
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def items(self, section_name): if section_name != section: raise NoSectionError(section_name) return { 'memcache_servers': memcache_servers, 'memcache_serialization_support': memcache_serialization_support, 'memcache...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def read(self, path): return True
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def get(self, section, option): if _section == section: if option == 'memcache_servers': if _srvs == 'error': raise NoOptionError(option, section) return _srvs elif option == 'memcache_serialization_support': ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def start_response(*args): pass
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def setUp(self): self.app = memcache.MemcacheMiddleware(FakeApp(), {})
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_cache_middleware(self): req = Request.blank('/something', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) self.assertTrue('swift.cache' in resp) self.assertTrue(isinstance(resp['swift.cache'], MemcacheRing))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_conf_inline_ratelimiting(self): with mock.patch.object(memcache, 'ConfigParser', get_config_parser()): app = memcache.MemcacheMiddleware( FakeApp(), {'error_suppression_limit': '5', 'error_suppression_interval': '2.5'}) self.assertEqu...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_conf_inline_tls(self): fake_context = mock.Mock() with mock.patch.object(ssl, 'create_default_context', return_value=fake_context): with mock.patch.object(memcache, 'ConfigParser', get_config_parser()): ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_filter_factory(self): factory = memcache.filter_factory({'max_connections': '3'}, memcache_servers='10.10.10.10:10', memcache_serialization_support='1') thefilter = factory('myapp') self.assertEqual(thef...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _loadapp(self, proxy_config_path): """ Load a proxy from an app.conf to get the memcache_ring :returns: the memcache_ring of the memcache middleware filter """ with mock.patch('swift.proxy.server.Ring'): app = loadapp(proxy_config_path) memcache_ring = No...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_real_config(self, tempdir): config = """ [pipeline:main] pipeline = cache proxy-server [app:proxy-server] use = egg:swift#proxy [filter:cache] use = egg:swift#memcache """ config_path = os.path.join(tempdir, 'test.conf') with ope...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_real_config_with_options(self, tempdir): config = """ [pipeline:main] pipeline = cache proxy-server [app:proxy-server] use = egg:swift#proxy [filter:cache] use = egg:swift#memcache memcache_servers = 10.0.0.1:11211,10.0.0.2:11211,10.0.0.3:11211,...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self): # Fix some key bindings self.bind("<Control-Key-a>", self.select_all) # We will need Ctrl-/ for the "stroke", but it cannot be unbound, so # let's prevent it from being passed to the standard handler self.bind("<Control-Key-/>", lambda event: "break") ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def call_vision_api(image_filename, api_keys): api_key = api_keys['microsoft'] post_url = "https://api.projectoxford.ai/vision/v1.0/analyze?visualFeatures=Categories,Tags,Description,Faces,ImageType,Color,Adult&subscription-key=" + api_key image_data = open(image_filename, 'rb').read() result = request...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def insert_accented(self, c, accent): if c.isalpha(): if c.isupper(): cap = 'capital' else: cap = 'small' try: c = lookup("latin %s letter %c with %s" % (cap, c, accent)) self.insert(INSERT, c) # ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def get_standardized_result(api_result): output = { 'tags' : [], 'captions' : [],
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, master=None, **kwargs): Entry.__init__(self, master=None, **kwargs) Diacritical.__init__(self)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def select_all(self, event=None): self.selection_range(0, END) return "break"
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, master=None, **kwargs): ScrolledText.__init__(self, master=None, **kwargs) Diacritical.__init__(self)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def select_all(self, event=None): self.tag_add(SEL, "1.0", "end-1c") self.mark_set(INSERT, "1.0") self.see(INSERT) return "break"
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test(): frame = Frame() frame.pack(fill=BOTH, expand=YES) if os.name == "nt": # Set default font for all widgets; use Windows typical default frame.option_add("*font", "Tahoma 8") # The editors entry = DiacriticalEntry(frame) entry.pack(fill=BOTH, expand=YES) text = Diacr...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def loaded(cls): return 'cudf' in sys.modules
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def applies(cls, obj): if not cls.loaded(): return False import cudf return isinstance(obj, (cudf.DataFrame, cudf.Series))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def init(cls, eltype, data, kdims, vdims): import cudf import pandas as pd element_params = eltype.param.objects() kdim_param = element_params['kdims'] vdim_param = element_params['vdims'] if isinstance(data, (cudf.Series, pd.Series)): data = data.to_frame()...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def range(cls, dataset, dimension): dimension = dataset.get_dimension(dimension, strict=True) column = dataset.data[dimension.name] if dimension.nodata is not None: column = cls.replace_value(column, dimension.nodata) if column.dtype.kind == 'O': return np.NaN, np...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def values(cls, dataset, dim, expanded=True, flat=True, compute=True, keep_index=False): dim = dataset.get_dimension(dim, strict=True) data = dataset.data[dim.name] if not expanded: data = data.unique() return data.values_host if compute else data.values ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def groupby(cls, dataset, dimensions, container_type, group_type, **kwargs): # Get dimensions information dimensions = [dataset.get_dimension(d).name for d in dimensions] kdims = [kdim for kdim in dataset.kdims if kdim not in dimensions] # Update the kwargs appropriately for Element gro...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def select_mask(cls, dataset, selection): """ Given a Dataset object and a dictionary with dimension keys and selection keys (i.e. tuple ranges, slices, sets, lists, or literals) return a boolean mask over the rows in the Dataset object that have been selected. """ ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def select(cls, dataset, selection_mask=None, **selection): df = dataset.data if selection_mask is None: selection_mask = cls.select_mask(dataset, selection) indexed = cls.indexed(dataset, selection) if selection_mask is not None: df = df.loc[selection_mask] ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def concat_fn(cls, dataframes, **kwargs): import cudf return cudf.concat(dataframes, **kwargs)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def add_dimension(cls, dataset, dimension, dim_pos, values, vdim): data = dataset.data.copy() if dimension.name not in data: data[dimension.name] = values return data
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def aggregate(cls, dataset, dimensions, function, **kwargs): data = dataset.data cols = [d.name for d in dataset.kdims if d in dimensions] vdims = dataset.dimensions('value', label='name') reindexed = data[cols+vdims] agg = function.__name__ if len(dimensions): ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def iloc(cls, dataset, index): import cudf rows, cols = index scalar = False columns = list(dataset.data.columns) if isinstance(cols, slice): cols = [d.name for d in dataset.dimensions()][cols] elif np.isscalar(cols): scalar = np.isscalar(rows) ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def sort(cls, dataset, by=[], reverse=False): cols = [dataset.get_dimension(d, strict=True).name for d in by] return dataset.data.sort_values(by=cols, ascending=not reverse)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def dframe(cls, dataset, dimensions): if dimensions: return dataset.data[dimensions].to_pandas() else: return dataset.data.to_pandas()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, key): self.key = key self.prio = random.randint(0, 1000000000) self.size = 1 self.left = None self.right = None
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def GetCompletions_Basic_test( app ): filepath = PathToTestFile( 'basic.py' ) completion_data = BuildRequest( filepath = filepath, filetype = 'python', contents = ReadFile( filepath ), line_num = 7, ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def update(self): self.size = 1 + size(self.left) + size(self.right)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def GetCompletions_UnicodeDescription_test( app ): filepath = PathToTestFile( 'unicode.py' ) completion_data = BuildRequest( filepath = filepath, filetype = 'python', contents = ReadFile( filepath ), force_semantic...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def size(treap): return 0 if treap is None else treap.size
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def CombineRequest( request, data ): kw = request request.update( data ) return BuildRequest( **kw )
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def split(root, minRight): if root is None: return None, None if root.key >= minRight: left, right = split(root.left, minRight) root.left = right root.update() return left, root else: left, right = split(root.right, minRight) root.right = left ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def GetCompletions_NoSuggestions_Fallback_test( app ): # Python completer doesn't raise NO_COMPLETIONS_MESSAGE, so this is a # different code path to the Clang completer cases # TESTCASE2 (general_fallback/lang_python.py) RunTest( app, { 'description': 'param jedi does not know about (id). query="a_p"', ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def merge(left, right): if left is None: return right if right is None: return left if left.prio > right.prio: left.right = merge(left.right, right) left.update() return left else: right.left = merge(left, right.left) right.update() return ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def insert(root, key): left, right = split(root, key) return merge(merge(left, Treap(key)), right)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def remove(root, key): left, right = split(root, key) return merge(left, split(right, key + 1)[1])
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def kth(root, k): if k < size(root.left): return kth(root.left, k) elif k > size(root.left): return kth(root.right, k - size(root.left) - 1) return root.key
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def dfs_print(root): if root is None: return dfs_print(root.left) print(str(root.key) + ' ', end='') dfs_print(root.right)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test(): start = time.time() treap = None s = set() for i in range(100000): key = random.randint(0, 10000) if random.randint(0, 1) == 0: if key in s: treap = remove(treap, key) s.remove(key) elif key not in s: treap = ins...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, region, name, retention_in_days=7): super(LogGroup, self).__init__() self.region = region self.name = name self.retention_in_days = retention_in_days
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _Create(self): """Create the log group.""" create_cmd = util.AWS_PREFIX + [ '--region', self.region, 'logs', 'create-log-group', '--log-group-name', self.name ] vm_util.IssueCommand(create_cmd)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _Delete(self): """Delete the log group.""" delete_cmd = util.AWS_PREFIX + [ '--region', self.region, 'logs', 'delete-log-group', '--log-group-name', self.name ] vm_util.IssueCommand(delete_cmd, raise_on_failure=False)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def Exists(self): """Returns True if the log group exists.""" describe_cmd = util.AWS_PREFIX + [ '--region', self.region, 'logs', 'describe-log-groups', '--log-group-name-prefix', self.name, '--no-paginate' ] stdout, _, _ = vm_util.IssueCommand(describe_cmd) log_group...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _PostCreate(self): """Set the retention policy.""" put_cmd = util.AWS_PREFIX + [ '--region', self.region, 'logs', 'put-retention-policy', '--log-group-name', self.name, '--retention-in-days', str(self.retention_in_days) ] vm_util.IssueCommand(put_cmd)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def GetLogs(region, stream_name, group_name, token=None): """Fetches the JSON formatted log stream starting at the token.""" get_cmd = util.AWS_PREFIX + [ '--region', region, 'logs', 'get-log-events', '--start-from-head', '--log-group-name', group_name, '--log-stream-name', stream_name...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def begin(self): self.append({'cbs': [], 'dirty': False})
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def check_fresh_login(): """Checks if the login is fresh for the current user, otherwise the user has to reauthenticate.""" if not login_fresh(): return current_app.login_manager.needs_refresh()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def commit(self): context = self.pop() if self: # savepoint self[-1]['cbs'].extend(context['cbs']) self[-1]['dirty'] = self[-1]['dirty'] or context['dirty'] else: # transaction for func, args, kwargs in context['cbs']: f...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def overview(): # user and group stats banned_users = User.query.filter( Group.banned == True, Group.id == User.primary_group_id ).count() if not current_app.config["REDIS_ENABLED"]: online_users = User.query.filter(User.lastseen >= time_diff()).count() else: online_u...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def rollback(self): self.pop()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def settings(slug=None): slug = slug if slug else "general" # get the currently active group active_group = SettingsGroup.query.filter_by(key=slug).first_or_404() # get all groups - used to build the navigation all_groups = SettingsGroup.query.all() SettingsForm = Setting.get_form(active_group...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def push(self, item): self[-1]['cbs'].append(item)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def users(): page = request.args.get("page", 1, type=int) search_form = UserSearchForm() if search_form.validate(): users = search_form.get_results().\ paginate(page, flaskbb_config['USERS_PER_PAGE'], False) return render_template("management/users.html", users=users, ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def mark_dirty(self): self[-1]['dirty'] = True
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def edit_user(user_id): user = User.query.filter_by(id=user_id).first_or_404() if not Permission(CanEditUser, identity=current_user): flash(_("You are not allowed to edit this user."), "danger") return redirect(url_for("management.users")) member_group = db.and_(*[db.not_(getattr(Group, p)...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def is_dirty(self): return any(context['dirty'] for context in self)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def delete_user(user_id=None): # ajax request if request.is_xhr: ids = request.get_json()["ids"] data = [] for user in User.query.filter(User.id.in_(ids)).all(): # do not delete current user if current_user.id == user.id: continue if ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self): super(TransactionStates, self).__init__() self._states = defaultdict(TransactionState)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def add_user(): form = AddUserForm() if form.validate_on_submit(): form.save() flash(_("User added."), "success") return redirect(url_for("management.users")) return render_template("management/user_form.html", form=form, title=_("Add User"))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __getitem__(self, key): return self._states[key or DEFAULT_DB_ALIAS]
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def banned_users(): page = request.args.get("page", 1, type=int) search_form = UserSearchForm() users = User.query.filter( Group.banned == True, Group.id == User.primary_group_id ).paginate(page, flaskbb_config['USERS_PER_PAGE'], False) if search_form.validate(): users = se...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def is_dirty(self, dbs): return any(self[db].is_dirty() for db in dbs)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def ban_user(user_id=None): if not Permission(CanBanUser, identity=current_user): flash(_("You do not have the permissions to ban this user."), "danger") return redirect(url_for("management.overview")) # ajax request if request.is_xhr: ids = request.get_json()["ids"] data =...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def queue_when_in_transaction(call): if transaction_states[call.using]: transaction_states[call.using].push((call, (), {})) else: return call()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def unban_user(user_id=None): if not Permission(CanBanUser, identity=current_user): flash(_("You do not have the permissions to unban this user."), "danger") return redirect(url_for("management.overview")) # ajax request if request.is_xhr: ids = request.get_json()["ids...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __enter__(self): entering = not transaction_states[self.using] transaction_states[self.using].begin() self._no_monkey.__enter__(self) if entering: on_commit(transaction_states[self.using].commit, self.using)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def reports(): page = request.args.get("page", 1, type=int) reports = Report.query.\ order_by(Report.id.asc()).\ paginate(page, flaskbb_config['USERS_PER_PAGE'], False) return render_template("management/reports.html", reports=reports)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __exit__(self, exc_type, exc_value, traceback): connection = get_connection(self.using) try: self._no_monkey.__exit__(self, exc_type, exc_value, traceback) except DatabaseError: transaction_states[self.using].rollback() else: if not connection.clos...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def unread_reports(): page = request.args.get("page", 1, type=int) reports = Report.query.\ filter(Report.zapped == None).\ order_by(Report.id.desc()).\ paginate(page, flaskbb_config['USERS_PER_PAGE'], False) return render_template("management/unread_reports.html", reports=reports)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def callproc(self, procname, params=None): result = self._no_monkey.callproc(self, procname, params) if transaction_states[self.db.alias]: transaction_states[self.db.alias].mark_dirty() return result
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def report_markread(report_id=None): # AJAX request if request.is_xhr: ids = request.get_json()["ids"] data = [] for report in Report.query.filter(Report.id.in_(ids)).all(): report.zapped_by = current_user.id report.zapped = time_utcnow() report.save(...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def execute(self, sql, params=None): result = self._no_monkey.execute(self, sql, params) if transaction_states[self.db.alias] and is_sql_dirty(sql): transaction_states[self.db.alias].mark_dirty() return result
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def groups(): page = request.args.get("page", 1, type=int) groups = Group.query.\ order_by(Group.id.asc()).\ paginate(page, flaskbb_config['USERS_PER_PAGE'], False) return render_template("management/groups.html", groups=groups)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def executemany(self, sql, param_list): result = self._no_monkey.executemany(self, sql, param_list) if transaction_states[self.db.alias] and is_sql_dirty(sql): transaction_states[self.db.alias].mark_dirty() return result
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def edit_group(group_id): group = Group.query.filter_by(id=group_id).first_or_404() form = EditGroupForm(group) if form.validate_on_submit(): form.populate_obj(group) group.save() if group.guest: Guest.invalidate_cache() flash(_("Group updated."), "success") ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def is_sql_dirty(sql): # This should not happen as using bytes in Python 3 is against db protocol, # but some people will pass it anyway if isinstance(sql, bytes): sql = sql.decode() # NOTE: not using regex here for speed sql = sql.lower() for action in ('update', 'insert', 'delete'): ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def delete_group(group_id=None): if request.is_xhr: ids = request.get_json()["ids"] if not (set(ids) & set(["1", "2", "3", "4", "5"])): data = [] for group in Group.query.filter(Group.id.in_(ids)).all(): group.delete() data.append({ ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def add_group(): form = AddGroupForm() if form.validate_on_submit(): form.save() flash(_("Group added."), "success") return redirect(url_for("management.groups")) return render_template("management/group_form.html", form=form, title=_("Add Group"))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def forums(): categories = Category.query.order_by(Category.position.asc()).all() return render_template("management/forums.html", categories=categories)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def edit_forum(forum_id): forum = Forum.query.filter_by(id=forum_id).first_or_404() form = EditForumForm(forum) if form.validate_on_submit(): form.save() flash(_("Forum updated."), "success") return redirect(url_for("management.edit_forum", forum_id=forum.id)) else: if f...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def delete_forum(forum_id): forum = Forum.query.filter_by(id=forum_id).first_or_404() involved_users = User.query.filter(Topic.forum_id == forum.id, Post.user_id == User.id).all() forum.delete(involved_users) flash(_("Forum deleted."), "success") return redi...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def add_forum(category_id=None): form = AddForumForm() if form.validate_on_submit(): form.save() flash(_("Forum added."), "success") return redirect(url_for("management.forums")) else: form.groups.data = Group.query.order_by(Group.id.asc()).all() if category_id: ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def add_category(): form = CategoryForm() if form.validate_on_submit(): form.save() flash(_("Category added."), "success") return redirect(url_for("management.forums")) return render_template("management/category_form.html", form=form, title=_("Add Catego...