コード例 #1
0
ファイル: views.py プロジェクト: averrin/zdev
def file_modify(request, action, guid='', from_total=False):
    """
        Modify change from pdm_sync
        guid = change id
        action in queries dict
    """
    if guid:
        # cred = MysqlCreds.objects.get(user=request.user)
        states = utmGet('SELECT state_id,cid FROM __pdm_sync_state')
        queries = {'del': '''delete from __release_files where guid = "%s"''' % guid}
        for state in states:
            queries[state['cid']] = '''update __release_files set state_id = %s where guid = "%s"''' % (state['state_id'], guid)

        hist = utmGet('''select * from __release_files where guid = "%s"''' % guid)[0]
        if hist and action in queries:
            query = queries[action]
            utmGet(query, commit=True)
            if from_total:
                return responseTrue({'guid': guid})
            else:
                return responseTrue({'guid': guid})
        else:
            return responseFalse('File not found')
    else:
        return responseFalse('Plz, specify file guid.')
コード例 #2
0
ファイル: views.py プロジェクト: averrin/zdev
def merge(request):
    bases = utmGet('SELECT * FROM abra_bases')
    _tables = utmGet('show tables in UTM')
    tables = []
    for table in _tables:
        tables.append(table.values()[0])
    return {'bases': bases, 'tables': tables}
コード例 #3
0
ファイル: views.py プロジェクト: averrin/zdev
def mass_modify(request):
    states = utmGet('SELECT state_id,cid FROM __pdm_sync_state')
    action = request.POST['action']
    guids = request.POST.getlist('guids[]')
    for guid in guids:
        queries = {'del': '''delete from __release_files where guid = "%s"''' % guid}
        for state in states:
            queries[state['cid']] = '''update __release_files set state_id = %s where guid = "%s"''' % (state['state_id'], guid)
        hist = utmGet('''select * from __release_files where guid = "%s"''' % guid)
        if hist and action in queries:
            query = queries[action]
            utmGet(query, commit=True)
    return responseTrue()
コード例 #4
0
ファイル: views.py プロジェクト: averrin/zdev
def scripts(request):
    scripts = utmGet("""
        SELECT guid, item_caption, selfparent_guid FROM __script_collection order by selfparent_guid
        """)
    _scripts = {}
    for i in scripts:
        _scripts[i['guid']] = i
    scripts = {}

    for guid, item in _scripts.items():
        if not item['selfparent_guid'] or item['selfparent_guid'] is None:
            scripts[guid] = item
        else:
            parent = _scripts[item['selfparent_guid']]
            if 'childs' not in parent:
                parent['childs'] = []
            parent['childs'].append(item)

    # for script in _scripts:
    #     if not script['selfparent_guid'] or script['selfparent_guid'] is None:
    #         script['childs'] = []
    #         scripts.append(script)
    #     else:
    #         for parent in scripts:
    #             if parent['guid'] == script['selfparent_guid']:
    #                 parent['childs'].append(script)
    return {'scripts': scripts}
コード例 #5
0
ファイル: views.py プロジェクト: averrin/zdev
def update(request, guid=""):
    if guid:
        f = utmGet("""
            select rep_name, full_file_name from __release_files f
            join __repositories rep on (rep.rep_id = f.rep_id)
            where f.guid = '%s'
        """ % guid)[0]
        repo = hglib.open(HG_ROOT + f['rep_name'])
        repo.pull()
        file_name = '%s/%s' % (repo.root(), f['full_file_name'])
        tip = repo.log(files=[file_name])[0][1][:12]
        utmGet("""
                update __release_files set changeset_num = '%s' where guid = '%s'
            """ % (tip, guid))
        return responseTrue()
    else:
        return responseFalse('Plz, specify file guid')
コード例 #6
0
ファイル: views.py プロジェクト: averrin/zdev
def main(request):
    query = """
    SELECT *
     FROM vw_redmine_issues
     where release_date is null
     and is_accepted = 1
    """
    issues = utmGet(query)
    return {'issues': issues}
コード例 #7
0
ファイル: views.py プロジェクト: averrin/zdev
def personal_list(request):
    """
        List of files owned by you
    """
    cred = MysqlCreds.objects.get(user=request.user)
    files = Files().getFiles(conditions="and files.developer = '%s'" % cred.db_login)
    for f in files:
        f['path_escaped'] = f['full_file_name'].replace('/', '+')
    repos = Files().getRepos()

    states = utmGet('SELECT * FROM __pdm_sync_state')
    allowed_states = ['pandora', 'in_progress', 'created', 'fast_upd']

    return {'files': files, 'repos': repos,
        'states': states,
        'allowed_states': allowed_states}
コード例 #8
0
ファイル: views.py プロジェクト: averrin/zdev
def total_list(request):
    """
        All files of release tasks. For review.
    """
    repos = Files().getRepos()

    f_users = Files().getUsers()

    states = utmGet('SELECT * FROM __pdm_sync_state')
    allowed_states = ['pandora', 'in_progress', 'created', 'fast_upd']
    cred = MysqlCreds.objects.get(user=request.user)
    return {
        'repos': repos,
        'states': states,
        'allowed_states': allowed_states,
        'my_name': cred.db_login,
        'f_users': f_users}
コード例 #9
0
ファイル: views.py プロジェクト: averrin/zdev
def files_list(request):
    """
        List of files and sql in current release
    """
    files = Files().getFiles(conditions="and redmine.is_accepted = 1")
    repos = Files().getRepos()
    users = Pdm_sync().getUsers()
    f_users = Files().getUsers()
    sql = Pdm_sync().getPdm(conditions="and ri.is_accepted = 1")
    states = utmGet('SELECT * FROM __pdm_sync_state')
    allowed_states = ['pandora', 'in_progress', 'created', 'fast_upd']
    cred = MysqlCreds.objects.get(user=request.user)
    return {'files': files, 'sql': sql,
        'repos': repos,
        'users': users,
        'states': states,
        'allowed_states': allowed_states,
        'my_name': cred.db_login,
        'f_users': f_users}
コード例 #10
0
ファイル: views.py プロジェクト: averrin/zdev
def profile(request):
    """
        Edit mysql creds
    """
    cred = MysqlCreds.objects.get(user=request.user)
    saved = False
    mysql_form = MySQLCreds(instance=cred)
    user_form = UserForm(instance=request.user)
    if request.method == 'POST':
        user_form = UserForm(request.POST, instance=request.user)
        mysql_form = MySQLCreds(request.POST, instance=cred)
        _devs = utmGet("""SELECT login FROM __developers""")
        devs = []
        for dev in _devs:
            devs.append(dev[0])
        if user_form.is_valid() and mysql_form.is_valid():
            if mysql_form.cleaned_data['db_login'] in devs:
                user_form.save()
                mysql_form.save()
                saved = True
            else:
                from django.forms.util import ErrorList
                mysql_form._errors["db_login"] = ErrorList([u"Такой логин отсутствует в таблице __developers"])
    return {'form': mysql_form, 'saved': saved, 'user_form': user_form}
コード例 #11
0
ファイル: views.py プロジェクト: averrin/zdev
def close_task(request, task=""):
    if task:
        utmGet("update __redmine_issues set release_date = now() where redmine_id = %s" % task, commit=True)
        return responseTrue()
    else:
        responseFalse('Plz, specify task number')
コード例 #12
0
ファイル: views.py プロジェクト: averrin/zdev
def accept_task(request, task=""):
    if task:
        utmGet("update __redmine_issues set is_accepted = 1 where redmine_id = %s" % task, commit=True)
        return responseTrue()
    else:
        responseFalse('Plz, specify task number')
コード例 #13
0
ファイル: views.py プロジェクト: averrin/zdev
def register(
    request,
    success_url=None,
    form_class=RegistrationForm,
    profile_callback=None,
    template_name="registration/registration_form.html",
    extra_context=None,
):
    """
    Allow a new user to register an account.

    Following successful registration, issue a redirect; by default,
    this will be whatever URL corresponds to the named URL pattern
    ``registration_complete``, which will be
    ``/accounts/register/complete/`` if using the included URLConf. To
    change this, point that named pattern at another URL, or pass your
    preferred URL as the keyword argument ``success_url``.

    By default, ``registration.forms.RegistrationForm`` will be used
    as the registration form; to change this, pass a different form
    class as the ``form_class`` keyword argument. The form class you
    specify must have a method ``save`` which will create and return
    the new ``User``, and that method must accept the keyword argument
    ``profile_callback`` (see below).

    To enable creation of a site-specific user profile object for the
    new user, pass a function which will create the profile object as
    the keyword argument ``profile_callback``. See
    ``RegistrationManager.create_inactive_user`` in the file
    ``models.py`` for details on how to write this function.

    By default, use the template
    ``registration/registration_form.html``; to change this, pass the
    name of a template as the keyword argument ``template_name``.

    **Required arguments**

    None.

    **Optional arguments**

    ``form_class``
        The form class to use for registration.

    ``extra_context``
        A dictionary of variables to add to the template context. Any
        callable object in this dictionary will be called to produce
        the end result which appears in the context.

    ``profile_callback``
        A function which will be used to create a site-specific
        profile instance for the new ``User``.

    ``success_url``
        The URL to redirect to on successful registration.

    ``template_name``
        A custom template to use.

    **Context:**

    ``form``
        The registration form.

    Any extra variables supplied in the ``extra_context`` argument
    (see above).

    **Template:**

    registration/registration_form.html or ``template_name`` keyword
    argument.

    """
    if request.method == "POST":
        form = form_class(data=request.POST, files=request.FILES)
        _devs = utmGet("""SELECT login FROM __developers""")
        devs = []
        for dev in _devs:
            devs.append(dev["login"])
        if form.is_valid():
            if form.cleaned_data["db_login"] in devs:
                new_user = form.save(profile_callback=profile_callback)
                new_user.is_active = 1
                new_user.save()
                MysqlCreds.objects.create(
                    user=new_user, db_login=form.cleaned_data["db_login"], db_password=form.cleaned_data["db_pass"]
                )
                # success_url needs to be dynamically generated here; setting a
                # a default value using reverse() will cause circular-import
                # problems with the default URLConf for this application, which
                # imports this file.
                return HttpResponseRedirect(success_url or reverse("registration_complete"))
            else:
                from django.forms.util import ErrorList

                form._errors["db_login"] = ErrorList([u"Такой логин отсутствует в таблице __developers"])
                # form.db_login.errors = ['Такой логин отсутствует в таблице __developers']
    else:
        form = form_class()

    if extra_context is None:
        extra_context = {}
    context = RequestContext(request)
    for key, value in extra_context.items():
        context[key] = callable(value) and value() or value
    return render_to_response(template_name, {"form": form}, context_instance=context)