我已经使用git flow
了一段时间了.我很想知道具体的用例.
对于我的一个项目,我有一个新网站功能的门票.此票证取决于许多子任务.我想为主故障单创建一个功能分支,然后为每个子任务创建一个父功能分支的功能分支.
我们假设我有一张PROJ-500票,我为它创建了一个功能分支
git flow feature start PROJ-500
Run Code Online (Sandbox Code Playgroud)
然后我想整合门票PROJ-501
通过PROJ-515
到PROJ-500
整个事情纳入前develop
.有没有办法让我做类似的事情
git flow feature start PROJ-511 -b PROJ-500
Run Code Online (Sandbox Code Playgroud)
然后超时这些子任务完成,当他们的功能完成时,分支被合并到PROJ-500
.
git flow feature finish PROJ-511
Run Code Online (Sandbox Code Playgroud)
上面的命令将合并PROJ-511
到PROJ-500
一旦所有子任务完成,那么PROJ-500
将完成并合并到develop
.
通过这种方式,新网站功能可以集成到单个单元而不是零碎的单元中.
我正在尝试使用一个简单的switch语句,但它不能编译.这是代码:
tag = 0
switch tag
when 0 then
alert "0"
when 1 then
alert "1"
Run Code Online (Sandbox Code Playgroud)
coffeescript编译器抱怨switch语句后的行中出现"意外的".我将代码更改为:
switch tag
when 0 then alert "0"
when 1 then alert "1"
Run Code Online (Sandbox Code Playgroud)
它工作正常.
但是我需要在switch语句的那些部分中的多行上有多个语句.这不可能吗?
javascript compiler-construction switch-statement coffeescript
我试图为我的登录路由延迟加载 Login组件.在构建webpack时,我得到:
SyntaxError: Unexpected Token
Run Code Online (Sandbox Code Playgroud)
如果我导入并以与Home路由相同的方式分配它,Login.vue组件工作正常.
我很困惑,因为我相信这段代码应该基于这个博客.
下面失败的行是:
component: () => import('../components/Login.vue'),
Run Code Online (Sandbox Code Playgroud)
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../components/Home.vue'
Vue.use(VueRouter)
export default new VueRouter({
mode: 'history',
routes: [
{
path: '/',
name: 'home',
component: Home,
meta: {
permission: "anonymous",
},
},
{
path: '/login/',
name: 'login',
component: () => import('../components/Login.vue'),
meta: {
permission: "anonymous",
},
},
],
})
Run Code Online (Sandbox Code Playgroud)
"dependencies": {
"vue": "^2.3.4"
},
"devDependencies": {
"babel-core": "^6.25.0",
"babel-eslint": "^7.2.2",
"babel-loader": …
Run Code Online (Sandbox Code Playgroud) 如果我直接导航到管理员保护的路由,http://127.0.0.1:8000/dashboard/
导航总是被拒绝,因为在检查路由器防护时状态尚未加载.
beforeEach
正在Vue之前执行created
,因此无法识别当前登录的用户.
我该如何解决这个鸡蛋和鸡蛋问题?
以下文件被截断以获得相关性
router.beforeEach((to, from, next) => {
//
// This is executed before the Vue created() method, and thus store getter always fails initially for admin guarded routes
//
// The following getter checks if the state's current role is allowed
const allowed = store.getters[`acl/${to.meta.guard}`]
if (!allowed) {
return next(to.meta.fail)
}
next()
})
const app = new Vue({
router,
store,
el: "#app",
created() {
// state loaded from localStorage if …
Run Code Online (Sandbox Code Playgroud) 我很惊讶我找不到与此相关的现有问题.也许有一个明显的答案,我忽略了.但是,让我说我的django项目名为"foo".foo的设置在Two Scoops书的鼓励下在多个文件中定义.
settings/
local.py
dev.py
prod.py
Run Code Online (Sandbox Code Playgroud)
Dev和prod是同一个repo的独立实例,这两个实例都是通过我的Webfaction帐户使用Apache提供的.对于我希望它使用的开发站点以及我希望它使用settings/dev.py
的prod站点settings/prod.py
.我的wsgi.py文件包含以下行:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "foo.settings.prod")
Run Code Online (Sandbox Code Playgroud)
这是我感到困惑的地方.如何加载开发站点foo.settings.dev
?
我可以用多个文件替换wsgi.py,然后在每个httpd.conf文件中将WSGIScriptAlias分配给正确的wsgi文件吗?
wsgi/
dev.py
prod.py
Run Code Online (Sandbox Code Playgroud)
谢谢
我想动态确定适当的 http 方法并进行单个 api 调用。但是,当我调用该方法时会引发异常。
我希望我做错了什么而不是这是一个vue-resource
错误。有人会有什么建议吗?谢谢
例如:
let method = this.$http.post
if (this.model.id) {
method = this.$http.put
}
method(
this.url,
this.model,
options
).then(response => {
this.$router.push(this.redirect_to)
}).catch(response => {
console.log(`Error: ${response.statusText}`)
})
Run Code Online (Sandbox Code Playgroud)
一个 javascriptTypeError
被抛出消息“这不是一个函数”
下面的代码有效,但有点啰嗦。
if (this.model.id) {
this.$http.put(
this.url,
this.model,
options
).then(response => {
this.$router.push(this.redirect_to)
}).catch(response => {
console.log(`Error: ${response.statusText}`)
})
} else {
this.$http.post(
this.url,
this.model,
options
).then(response => {
this.$router.push(this.redirect_to)
}).catch(response => {
console.log(`Error: ${response.statusText}`)
})
}
Run Code Online (Sandbox Code Playgroud) 这个问题与这个问题直接相关,但那个现在似乎已经过时了。
我正在尝试测试视图而无需访问数据库。为此,我需要对RelatedManager
用户进行模拟。
我正在使用pytest
和pytest-mock
。
模型.py
# truncated for brevity, taken from django-rest-knox
class AuthToken(models.Model):
user = models.ForeignKey(
User,
null=False,
blank=False,
related_name='auth_token_set',
on_delete=models.CASCADE
)
Run Code Online (Sandbox Code Playgroud)
视图.py
class ChangeEmail(APIView):
permission_classes = [permissions.IsAdmin]
serializer_class = serializers.ChangeEmail
def post(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
user = request.user
user.email = request.validated_data['email']
user.save()
# Logout user from all devices
user.auth_token_set.all().delete() # <--- How do I mock this?
return Response(status=status.HTTP_200_OK)
Run Code Online (Sandbox Code Playgroud)
测试视图.py
def test_valid(mocker, user_factory):
user = user_factory.build()
user.id = …
Run Code Online (Sandbox Code Playgroud) django pytest python-mock django-rest-framework pytest-django
我正在尝试使用django-endless-pagination在滚动上实现连续分页.
页面的初始渲染工作正常.但是,滚动后,整个 html页面内容将加载到endless_page_template div中,而不是page_template中所需的部分html内容.结果有点像在镜子里面反射另一面镜子.我相信返回的查询集是正确的,因为在不尝试使用"paginateOnScroll"时分页结果是正确的.
我的观点的相关部分如下.我正在使用CreateView,因为我在与分页注释相同的页面上有注释表单.
class MyIndex(CreateView):
form_class = CommentForm
template_name = 'my/index.html'
page_template = 'my/comments.html'
def get_context_data(self, **kwargs):
context = super(MyIndex, self).get_context_data(**kwargs)
context.update({
'comments': Comment.objects.order_by('-id').filter(parent=None),
'page_template': self.page_template,
})
return context
Run Code Online (Sandbox Code Playgroud)
我/ index.html模板的相关部分(主模板)
<script src="{% static 'endless_pagination/js/endless-pagination.js' %}"></script>
<script type="text/javascript">
$.endlessPaginate({
paginateOnScroll: true
});
</script>
<div class="endless_page_template">
{% include page_template %}
</div>
Run Code Online (Sandbox Code Playgroud)
我/ comments.html的相关部分(page_template)
{% load endless %}
{% paginate comments %}
{% for comment in comments %}
<span class="lead">{{ comment.name }}</span>
{{ comment.message}}
{% …
Run Code Online (Sandbox Code Playgroud) django ×3
vue.js ×3
javascript ×2
vue-router ×2
apache ×1
coffeescript ×1
ecmascript-6 ×1
git ×1
git-flow ×1
mod-wsgi ×1
pytest ×1
python-mock ×1
vue-resource ×1
vuejs2 ×1
vuex ×1
webpack ×1