forked from guohongze/adminset
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
369 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,6 +95,9 @@ class Project(models.Model): | |
verbose_name=u"服务器" | ||
) | ||
|
||
def __unicode__(self): | ||
return self.name | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from __future__ import unicode_literals | ||
|
||
from django.apps import AppConfig | ||
|
||
|
||
class DeliveryConfig(AppConfig): | ||
name = 'delivery' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#! /usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from django.shortcuts import render, HttpResponseRedirect, RequestContext | ||
from django.core.urlresolvers import reverse | ||
from django.contrib.auth.decorators import login_required | ||
from models import Delivery | ||
from forms import DeliveryFrom | ||
from accounts.permission import permission_verify | ||
|
||
|
||
@login_required() | ||
@permission_verify() | ||
def delivery_list(request): | ||
temp_name = "delivery/delivery-header.html" | ||
all_project = Delivery.objects.all() | ||
results = { | ||
'temp_name': temp_name, | ||
'all_project': all_project, | ||
} | ||
return render(request, 'delivery/delivery_list.html', results) | ||
|
||
|
||
@login_required | ||
@permission_verify() | ||
def delivery_del(request): | ||
project_id = request.GET.get('project_id', '') | ||
if project_id: | ||
Delivery.objects.filter(id=project_id).delete() | ||
|
||
project_id_all = str(request.POST.get('project_id_all', '')) | ||
if project_id_all: | ||
for project_id in project_id_all.split(','): | ||
Delivery.objects.filter(id=project_id).delete() | ||
|
||
return HttpResponseRedirect(reverse('delivery_list'), RequestContext(request)) | ||
|
||
|
||
@login_required | ||
@permission_verify() | ||
def delivery_add(request): | ||
temp_name = "delivery/delivery-header.html" | ||
if request.method == 'POST': | ||
form = DeliveryFrom(request.POST) | ||
if form.is_valid(): | ||
form.save() | ||
return HttpResponseRedirect(reverse('delivery_list'), RequestContext(request)) | ||
else: | ||
form = DeliveryFrom() | ||
|
||
results = { | ||
'form': form, | ||
'request': request, | ||
'temp_name': temp_name, | ||
} | ||
return render(request, 'delivery/delivery_base.html', results) | ||
|
||
|
||
@login_required | ||
@permission_verify() | ||
def delivery_edit(request, project_id): | ||
project = Delivery.objects.get(id=project_id) | ||
temp_name = "delivery/delivery-header.html" | ||
if request.method == 'POST': | ||
form = DeliveryFrom(request.POST, instance=project) | ||
if form.is_valid(): | ||
form.save() | ||
return HttpResponseRedirect(reverse('project_list'), RequestContext(request)) | ||
else: | ||
form = DeliveryFrom(instance=project) | ||
|
||
results = { | ||
'form': form, | ||
'project_id': project_id, | ||
'request': request, | ||
'temp_name': temp_name, | ||
} | ||
return render(request, 'delivery/delivery_base.html', results) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#! /usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
from django import forms | ||
from django.forms import widgets | ||
from models import Delivery | ||
|
||
|
||
class DeliveryFrom(forms.ModelForm): | ||
|
||
class Meta: | ||
model = Delivery | ||
exclude = ("id",) | ||
|
||
widgets = { | ||
'job_name': widgets.Select(attrs={'class': 'form-control','style': 'width:450px;'}), | ||
'description': widgets.Textarea(attrs={'class': 'form-control','style': 'width:450px; height:100px'}), | ||
'deploy_policy': widgets.Select(attrs={'class': 'form-control','style': 'width:450px;'}), | ||
'source_type': widgets.Select(attrs={'class': 'form-control','style': 'width:450px;'}), | ||
'source_address': widgets.TextInput(attrs={'class': 'form-control','style': 'width:450px;'}), | ||
'destination_address': widgets.TextInput(attrs={'class': 'form-control','style': 'width:450px;'}), | ||
'shell': widgets.Select(attrs={'class': 'form-control','style': 'width:450px;'}), | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#! /usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models | ||
from appconf.models import Project | ||
# Create your models here. | ||
DEPLOY_POLICY = ( | ||
("Direct", "Direct"), | ||
("BlueGreen", "BlueGreen"), | ||
) | ||
|
||
SOURCE_TYPE = ( | ||
("svn", "svn"), | ||
("git", "git"), | ||
("file", "file"), | ||
) | ||
|
||
|
||
class Delivery(models.Model): | ||
job_name = models.ForeignKey(Project, null=False, verbose_name=u"项目名") | ||
description = models.CharField(max_length=255, verbose_name=u"描述", null=True, blank=True) | ||
source_type = models.CharField(max_length=255, choices=SOURCE_TYPE, verbose_name=u"源类型") | ||
source_address = models.CharField(max_length=255, verbose_name=u"源地址") | ||
destination_address = models.CharField(max_length=255, verbose_name=u"目标地址") | ||
deploy_policy = models.CharField(max_length=255, choices=DEPLOY_POLICY, verbose_name=u"部署策略") | ||
shell = models.CharField(max_length=255, verbose_name=u"shell", null=True, blank=True) | ||
|
||
def __unicode__(self): | ||
return self.job_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#! /usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
from django.conf.urls import url, include | ||
import delivery | ||
|
||
urlpatterns = [ | ||
url(r'^$', delivery.delivery_list, name='delivery'), | ||
url(r'^delivery/add/$', delivery.delivery_add, name='delivery_add'), | ||
url(r'^delivery/list/$', delivery.delivery_list, name='delivery_list'), | ||
url(r'^delivery/edit/(?P<project_id>\d+)/$', delivery.delivery_edit, name='delivery_edit'), | ||
url(r'^delivery/delete/$', delivery.delivery_del, name='delivery_del'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#! /usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
from django.http import HttpResponse | ||
from django.views.generic.base import TemplateView | ||
from django.shortcuts import render | ||
from models import Delivery | ||
|
||
|
||
def index(request): | ||
temp_name = "delivery/delivery-header.html" | ||
projects = Delivery.objects.all() | ||
return render(request, "delivery/index.html", locals()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<header class="main-header"> | ||
|
||
<!-- Logo --> | ||
<a href="{% url 'index' %}" class="logo"> | ||
<!-- mini logo for sidebar mini 50x50 pixels --> | ||
<span class="logo-mini"><b>AST</b></span> | ||
<!-- logo for regular state and mobile devices --> | ||
<span class="logo-lg"><b>AdminSet</b></span> | ||
</a> | ||
|
||
<!-- Header Navbar --> | ||
<nav class="navbar navbar-static-top" role="navigation"> | ||
<!-- Sidebar toggle button--> | ||
<a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button"> | ||
<span class="sr-only">Toggle navigation</span> | ||
</a> | ||
<div class="collapse navbar-collapse pull-left" id="navbar-collapse"> | ||
<ul class="nav navbar-nav"> | ||
</ul> | ||
</div> | ||
<!-- Navbar Right Menu --> | ||
{% include 'navbar-custom-menu.html' %} | ||
</nav> | ||
</header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{% extends 'base.html' %} | ||
{% block self_head_css_js %} | ||
<script src="/static/layer/layer.js"></script> | ||
<script src="/static/js/jquery.bootstrap-duallistbox.js"></script> | ||
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap-duallistbox.css"> | ||
{% endblock %} | ||
{% block content %} | ||
|
||
<script> | ||
window.onload=init; | ||
function init() { | ||
var box = document.getElementById("delivery"); | ||
box.className="active"; | ||
var box = document.getElementById("delivery_list"); | ||
box.className="active"; | ||
} | ||
</script> | ||
|
||
<div class="content-wrapper"> | ||
<!-- Content Header (Page header) --> | ||
<section class="content-header"> | ||
</section> | ||
|
||
<!-- Main content --> | ||
|
||
<section class="content"> | ||
|
||
<!-- Default box --> | ||
<div class="box"> | ||
<div class="box-header with-border"> | ||
</div> | ||
<div class="box-body"> | ||
{% if project_id %} | ||
<form action="{% url 'delivery_edit' project_id %}" method="post"> | ||
{% else %} | ||
<form action="{% url 'delivery_add' %}" method="post"> | ||
{% endif %} | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<input type="submit" class="btn btn-primary" style="width: 60pt" value="提交"> | ||
<a href="{% url 'delivery_list' %}"><li style="width: 60pt" class="btn btn-primary" value="">返回</li></a><br> | ||
</form> | ||
</div> | ||
<!-- /.box-body --> | ||
<div class="box-footer"> | ||
<i class="fa fa-info-circle"></i> 请勿重复添加条目 | ||
</div> | ||
<!-- /.box-footer--> | ||
</div> | ||
<!-- /.box --> | ||
</section> | ||
|
||
</div> | ||
{# <script>#} | ||
{# var demo1 = $('select[name="serverList"]').bootstrapDualListbox({#} | ||
{# nonSelectedListLabel: '可选择服务器',#} | ||
{# selectedListLabel: '已选择服务器',#} | ||
{# preserveSelectionOnMove: 'moved',#} | ||
{# moveOnSelect: false,#} | ||
{# });#} | ||
{# </script>#} | ||
|
||
{% endblock %} |
Oops, something went wrong.