本文整理汇总了Python中project.models.Project.name方法的典型用法代码示例。如果您正苦于以下问题:Python Project.name方法的具体用法?Python Project.name怎么用?Python Project.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类project.models.Project
的用法示例。
在下文中一共展示了Project.name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_project
# 需要导入模块: from project.models import Project [as 别名]
# 或者: from project.models.Project import name [as 别名]
def create_project(org, name):
p = Project()
p.name = name
p.description = v = paragraphs(random.randint(2, 6))
p.ong = org
p.shipping_address = paragraphs(1)
p.created = timezone.now() + datetime.timedelta(random.randint(-360, 0))
p.save()
for i in range(random.randint(1, 10)):
create_thing(p, "thing%d" % (i+1))
示例2: create
# 需要导入模块: from project.models import Project [as 别名]
# 或者: from project.models.Project import name [as 别名]
def create(self, validated_data):
user = self.context['request'].user
group = [group for group in user.groups.all() if group.name == user.username][0]
instance = Project()
instance.name = validated_data['name']
instance.user = user
instance.group = group
instance.save()
return instance
示例3: github_hook
# 需要导入模块: from project.models import Project [as 别名]
# 或者: from project.models.Project import name [as 别名]
def github_hook(request):
"""
github hook, when we get a request it will check to see if we have
project already,
if not, it will add it and trigger build. If we have it, it just
triggers build.
"""
log.debug("Github Hook")
if request.method == 'POST':
log.debug("Github Hook is POST")
try:
try:
data = json.loads(request.POST['payload'])
except Exception as exc:
log.debug("(Github) parse request error = {0}".format(exc))
return HttpResponse('Invalid payload')
log.debug("-----")
log.debug(data)
log.debug("-----")
repo = data.get('repository', {})
name = repo.get('name', None)
url = repo.get('url', "")
url = url.replace('http://', 'https://')
branch = data.get('ref', "").replace('refs/heads/', '')
log.info("(Github Build) %s:%s" % (url, branch))
try:
project = Project.objects.get(repo_url=url)
log.info("We have the project already {0}".format(project))
except Project.DoesNotExist:
log.info("New Project")
project = Project()
project.repo_url = url
project.name = name
project.save()
log.info("Trigger build")
project.rebuild_score()
except Exception as exc:
log.error("(Github) {0}".format(exc))
else:
log.debug("Github Hook was GET")
log.info("Done webhook")
return HttpResponse('Build Started')
示例4: handle_uploaded_file
# 需要导入模块: from project.models import Project [as 别名]
# 或者: from project.models.Project import name [as 别名]
def handle_uploaded_file(file, user_id):
user_object = User.objects.get(pk=user_id)
csv_reader = csv.DictReader(file, fieldnames=['date','start','end','duration','project','slip'])
line_data = []
for line in csv_reader:
line_data.append(line)
total_time = 0
val = {}
pickles = {'projects': [], 'slips': [], 'slices': []}
for line in line_data[1:]:
begin = datetime.strptime('T'.join((line['date'], line['start'])), '%Y-%m-%dT%H:%M')
end = datetime.strptime('T'.join((line['date'], line['end'])), '%Y-%m-%dT%H:%M')
total_time += int(line['duration'])
if not val.has_key(line['project']):
project_set = Project.objects.filter(name=line['project'], members = user_id)
if project_set:
if len(project_set) >1:
project = Project()
project.name = line['project']
project_created_msg = _('Found more than one project, you are on, with same name. New project will be created.')
project_created_bool = True
else:
project = project_set[0]
project_created_msg = _('Found project, and will add slips and timeslices to the existing project.')
project_created_bool = False
else:
project_set = Project.objects.filter(name=line['project'])
if project_set:
if len(project_set) >1:
project = Project()
project.name = line['project']
project_created_msg = _('Found more than one project, with same name. New project will be created.')
project_created_bool = True
else:
project = project_set[0]
project_created_msg = _('Found project, and will add user profile, slips and timeslices to the existing project.')
project_created_bool = False
else:
project = Project()
project.name = line['project']
project_created_msg = _('No project of that name. New project will be created')
project_created_bool = True
val[line['project']] = {'created': project_created_bool, 'message': project_created_msg, 'project_object': project, 'slips': {}}
pickles['projects'].append(project)
if not val[line['project']]['slips'].has_key(line['slip']):
if val[line['project']]['created']:
slip = Slip()
slip.name = line['slip']
slip.user = user_object
slip.project = val[line['project']]['project_object']
slip.created = line['date']
slip_created_bool = True
else:
slip_set = Slip.objects.filter(name = line['slip'], user = user_object , project = project)
if not slip_set or len(slip_set) > 1:
slip = Slip()
slip.name = line['slip']
slip.user = user_object
slip.project = val[line['project']]['project_object']
slip.created = line['date']
slip_created_bool = True
else:
slip = slip_set[0]
slip_created_bool = False
val[line['project']]['slips'][line['slip']]={'created': slip_created_bool, 'slip_object': slip, 'slices': []}
pickles['slips'].append(slip)
if val[line['project']]['slips'][line['slip']]['created']:
slice = TimeSlice()
slice.begin = begin
slice.end = end
slice.duration = int(line['duration'])
slice.slip = val[line['project']]['slips'][line['slip']]['slip_object']
slice.user = user_object
slice_created_bool = True
else:
slice_set = TimeSlice.objects.filter(begin = begin, end = end, duration = int(line['duration']), slip = slip, user = user_object)
if slice_set:
if len(slice_set) > 1:
pass
slice = slice_set[0]
slice_created_bool = False
else:
slice = TimeSlice()
slice.begin = begin
slice.end = end
slice.duration = int(line['duration'])
slice.slip = val[line['project']]['slips'][line['slip']]['slip_object']
slice.user = user_object
slice_created_bool = True
val[line['project']]['slips'][line['slip']]['slices'].append(slice)
pickles['slices'].append(slice)
total_time = str(int(total_time/3600.0))+'h'
# Okay, now we have processed the data, lets write it to a couple of files.
import_data = DataImport.objects.create(user=user_object)
#.........这里部分代码省略.........