小编Anu*_*TBE的帖子

CakePHP 3:关联属性名称与表的同名字段冲突

我正在使用 CakePHP 3.2。我有两张桌子service_requestscoupon_history

service_requests 桌子

CREATE TABLE `service_requests` (
  `id` char(36) NOT NULL,
  `request_id` bigint(20) NOT NULL,
  `user_id` char(36) NOT NULL,
  `user_address_id` char(36) NOT NULL,
  `service_id` char(36) NOT NULL,
  `service_area_id` char(36) NOT NULL,
  `coupon_used` int(11) NOT NULL DEFAULT '0' COMMENT '0: Not Applied; 1: Applied',
  `coupon_used_id` char(36) NOT NULL,
  `status_code` int(11) NOT NULL,
  `status` varchar(50) NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL
)
Run Code Online (Sandbox Code Playgroud)

coupon_history 桌子

CREATE TABLE `coupon_history` (
  `id` char(36) NOT NULL,
  `user_id` …
Run Code Online (Sandbox Code Playgroud)

cakephp model-associations cakephp-3.2

5
推荐指数
1
解决办法
3596
查看次数

Gitlab 覆盖率徽章不起作用

我正在Django使用Gitlab CI/CDpytest测试代码以及pytest-cov生成覆盖率报告来部署应用程序

我的 .gitlab-ci.yml

stages:
  - test
  - deploy

image: python:3.6

test:
  stage: test
  script:
    - pip install pipenv
    - pipenv install
    - pipenv run py.test src/
  artifacts:
    paths:
      - htmlcov/

pages:
  stage: deploy
  dependencies:
    - test
  script:
    - mv htmlcov/ public/
  artifacts:
    paths:
      - public
    expire_in: 30 days
  only:
    - master

staging:
  stage: deploy
  script:
    - apt-get update -qy
    - apt-get install -y ruby-dev
    - gem install dpl
    - dpl --provider=heroku …
Run Code Online (Sandbox Code Playgroud)

gitlab gitlab-ci-runner

5
推荐指数
2
解决办法
5416
查看次数

找不到模块:错误:无法解析Angular 6中的"./package"

我正在使用Angular 6scraperjs.

在我的组件文件中,使用了示例中给出的代码

import { Component, OnInit } from '@angular/core';

import scraperjs from 'scraperjs';

@Component({
  selector: 'app-express',
  templateUrl: './express.component.html',
  styleUrls: ['./express.component.css']
})
export class ExpressComponent implements OnInit {

  constructor() { }

  ngOnInit() {
    this.aliExpress();
  }

  aliExpress() {
    console.log('loaded ali express');

    scrapperjs.StaticScraper.create('https://news.ycombinator.com')
      .scrape(function ($) {
        return $('.title a').map(function () {
          return $(this).text();
        }).get();
      }).then(function (news) {
      console.log(news);
    });
  }

}
Run Code Online (Sandbox Code Playgroud)

但它给出了错误

Failed to compile.

./node_modules/cheerio/index.js 
Module not found: Error: Can't resolve './package' in '/home/user/code/angular/ali-express/node_modules/cheerio'
Run Code Online (Sandbox Code Playgroud)

cheerio angular angular6

5
推荐指数
1
解决办法
1294
查看次数

不能在Angular 6中的子模块中使用app模块中声明的指令

我正在使用Angular 6.

我通过扩展NbgPopover声明了一个指令StickyPopover并添加了*app.module.ts**declaration

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { AuthLayoutComponent } from './layouts/auth-layout/auth-layout.component';
import {AdminLayoutComponent} from './layouts/admin-layout/admin-layout.component';
import {FormsModule} from '@angular/forms';
import {RouterModule} from '@angular/router';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
import {StickyPopoverDirective} from './sticky-popover.directive';


@NgModule({
  declarations: [
    AppComponent,
    AuthLayoutComponent,
    AdminLayoutComponent,
    StickyPopoverDirective           // custom created directive
  ],
  imports: [
    BrowserModule,
    AppRoutingModule, …
Run Code Online (Sandbox Code Playgroud)

typescript angular-directive angular angular6

5
推荐指数
1
解决办法
1970
查看次数

debconf:延迟包配置,因为没有安装 apt-utils

我正在设置Docker来运行我的CakePHP应用程序,我的Dockerfile就像

FROM php:7.2-apache

# Enable Apache Rewrite + Expires Module
RUN a2enmod rewrite expires

# Install dependencies
RUN apt-get update && apt-get install -y \
    unzip \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    libyaml-dev \
    zlib1g-dev \
    libicu-dev \
    g++ \
    git \
    libzip-dev \
    zip \
    && docker-php-ext-install opcache \
    && docker-php-ext-configure intl \
    && docker-php-ext-install intl \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-configure zip --with-libzip \
    && docker-php-ext-install zip \ …
Run Code Online (Sandbox Code Playgroud)

docker dockerfile docker-compose

5
推荐指数
1
解决办法
6658
查看次数

角度反应形式验证嵌套字段

我正在使用Angular 7

我有一个嵌套的反应形式

this.salonProfileForm = this.fb.group({
  salonName: new FormControl('', [Validators.required]),
  address: this.fb.group({
    city: new FormControl('', [Validators.required])
  })
});

get f() {
    return this.salonProfileForm.controls;
}
Run Code Online (Sandbox Code Playgroud)

我有这样的 HTML 表单

<input type="text" formControlName="salonName" required />
<ng-container *ngIf="submitted && f.salonName.invalid && (f.salonName.dirty || f.salonName.touched)">
   <small *ngIf="f.salonName.errors.required">
      Salon name is required
   </small>
</ng-container>

<div formGroupName="address">
  <input type="text" formControlName="city" />
  <ng-container *ngIf="submitted && f.city.invalid && (f.city.dirty || f.city.touched)">
    <small *ngIf="f.city.errors.required">
        city is required
    </small>
  </ng-container>
</div>
Run Code Online (Sandbox Code Playgroud)

但这会在城市输入ng-container字段上产生错误,如下所示

ERROR TypeError: Cannot read property 'invalid' …
Run Code Online (Sandbox Code Playgroud)

angular angular-reactive-forms

5
推荐指数
1
解决办法
6041
查看次数

警告:toctree 包含对不存在的文档的引用

我正在使用 sphinx 来记录我的 Django 应用程序。

我有以下文档目录结构

docs
|- build
|- source
   |- _static
   |- _templates
   |- conf.py
   |- index.rst
   |- upgrade.rst
|- upgrade_changes
   |- migration
      |- index.rst
   |- index.rst
   |- library_changes.rst
Run Code Online (Sandbox Code Playgroud)

和内容docs/source/index.rst

My App's documentation!
=============================================
App Description

Revamp Upgrade Changes
----------------------

.. toctree::
   :maxdepth: 2

   upgrade
Run Code Online (Sandbox Code Playgroud)

source/upgrade.rst文件包含来自upgrade_changes

.. include:: ../upgrade_changes/index.rst
Run Code Online (Sandbox Code Playgroud)

并且/upgrade_changes/index.rst

Following is the list of all revamp related documentation.

.. toctree::
   :maxdepth: 2

   library_changes
Run Code Online (Sandbox Code Playgroud)

我想为与.oslibrary_changes.rst文件处于同一级别的文件包含一个目录树index.rst。 …

python-sphinx toctree

5
推荐指数
0
解决办法
975
查看次数

Nginx 允许来自任何域的流量

我用nginx的是代理服务器。我的应用程序有一个功能,用户可以使用自己的域而不是我的域。为此,他们需要将其 CNAME 指向我的域。

这是我的 Nginx 配置

server {
  server_name                   scan.mydomain.com anonymous.mydomain.com "";
  access_log                    /etc/nginx/log/local-wc.access.log;
  error_log                     /etc/nginx/log/local-wc.error.log;

  location / {
    root                      /var/www/html/qcg-scanning-frontend/dist/webapp/;
    index                     index.html;
    try_files                 $uri $uri/ /index.html;
    proxy_redirect            off;
    proxy_set_header          Host            $host;
    proxy_set_header          X-Real-IP       $remote_addr;
    proxy_set_header          X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header          X-Forwarded-Protocol $scheme;
  }

  listen 443 ssl; # managed by Certbot
  ssl_certificate /etc/letsencrypt/live/anonymous.mydomain.com-0001/fullchain.pem; # managed by Certbot
  ssl_certificate_key /etc/letsencrypt/live/anonymous.mydomain.com-0001/privkey.pem; # managed by Certbot
  include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
  if ($host …
Run Code Online (Sandbox Code Playgroud)

ssl nginx lets-encrypt certbot

5
推荐指数
1
解决办法
1080
查看次数

Django redirect_authenticated_user:真不起作用

我正在Django 1.11中编写应用程序。

myapp/urls.py 图案看起来像

from django.conf.urls import url, include
from django.contrib import admin
from django.contrib.auth.views import LoginView

urlpatterns = [
    url(r'^login/$', LoginView.as_view(), {'redirect_authenticated_user': True}),
    url('^', include('django.contrib.auth.urls')),
    url('^', include('pages.urls')),
    url(r'^pages/', include('pages.urls')),
    url(r'^search/', include('search.urls')),
    url(r'^admin/', admin.site.urls),
]
Run Code Online (Sandbox Code Playgroud)

我想在尝试访问/login页面时重定向登录用户。为此,我已经按照此处的文档中的设置redirect_authenticated_user进行了设置True

但是,/login成功登录后访问时,它不会重定向。

python django django-authentication

4
推荐指数
1
解决办法
1422
查看次数

模型字段上的 Django 吸气剂

我正在使用Django 2.x

我有一个像

class MyModel(models.Model):
    name = models.CharField()
    balance = models.IntegerField()
Run Code Online (Sandbox Code Playgroud)

我想更改 GET 请求中的 balance 值而不更改数据库中的值。

就像它可能是@Property字段一样,模型看起来像

class MyModel(models.Model):
    name = models.CharField()
    balance = models.IntegerField()

    @property
    def balance(self):
        if balance:
           return balance
        return 0.15 * 50
Run Code Online (Sandbox Code Playgroud)

但不允许重新声明。我该如何解决这个问题?

注意:字段应与ModelAdminDRF Serializer兼容

django django-models

4
推荐指数
1
解决办法
7329
查看次数