Exemplo n.º 1
0
def projekt_overview_view(request):
    """
    Redirects user to if not authenticated, otherwise shows all projects
    """

    #Redirect unauthenticated users
    if not request.user.is_authenticated:
        return redirect('index:index')

    #Check if user has accepted terms of use
    if not request.user.conventecuser.accepted_tou:
        return redirect('terms:terms')

    if request.user.conventecuser.kanzlei.deadline is not None and request.user.conventecuser.kanzlei.deadline <= datetime.datetime.now(
    ):
        return custom_redirect('login:error', e='deadline')

    if request.method == 'GET':
        #Get sorting method from GET, set default to 'name' and False
        sorted_by = request.GET.get('sort', 'name')
        reverse = (request.GET.get('reverse', '') == 'true')

        #Get active tab
        active = request.GET.get('active', 'aktuelle')

        #Get success
        success = request.GET.get('success', 'false')
        if success != 'false':
            success = Projekt.objects.get(id=int(success))

        #Provide context
        context = {
            'user': request.user,
            'projects': list_all_projects(request.user, sorted_by, reverse,
                                          active),
            'active': {
                'nav': 'projekte',
                'tabs': active
            },
            'success': success
        }

        return render(request, 'projekt_overview.html', context)

    elif request.method == 'POST':
        #Get POST data
        name = request.POST.get('name', False)
        description = request.POST.get('description', False)
        team = request.POST.get('team', False)

        if name and description and team and (
                request.user.conventecuser.role == 'manager'
                or request.user.conventecuser.role == 'admin'):
            projekt = Projekt.create(name, description, int(team))
            return custom_redirect('projekt:projekt_detail',
                                   projekt.id,
                                   active='teams')

        return redirect('projekt:projekt')
Exemplo n.º 2
0
def login_reset_view(request):
    """
    Allows resetting the password
    """
    
    if request.method == 'GET':
        token = request.GET.get('token', False)
        email = request.GET.get('email', False)
        s = request.GET.get('s', False)
        init = request.GET.get('init', False)
        
        
        context = {
            'token' : token,
            'email' : email,
            'success' : s,
            'init' : init
            }
    
        return render(request, 'login_reset.html', context)
        
    elif request.method == 'POST':
        email = request.POST.get('email', False)
        token = request.POST.get('token', False)
        pw1 = request.POST.get('pw1', False)
        pw2 = request.POST.get('pw2', False)
        
        #Get the user or throw error
        try:
            user = User.objects.get(email = email)
             
        except User.DoesNotExist:
            return custom_redirect('login:reset', s = 'ne')
            
        if token:
            if not pw1 or not pw2 or pw1 != pw2:
                return custom_redirect('login:reset', s = 'ms', email=email, token=token)
            
            else:
                if default_token_generator.check_token(user, token):
                    user.set_password(pw1)
                    user.save()
                    return custom_redirect('login:reset', s = 's')
                else:
                    return custom_redirect('login:reset', s = 'it', email=email)
        
        else:
            generated_token = default_token_generator.make_token(user)
            num_sent = send_mail('Conventec Support', 'Guten Tag ' + user.get_full_name() + '\n\nSie können Ihr Passwort mit diesem Link setzen:\nhttps://app.conventec.ch/login/reset?email=' + user.email + '&token=' + generated_token + '\n\nIhr Conventec Team', '*****@*****.**', [user.email])
            logger.info('Sent ' + str(num_sent) + ' pw reset mails to: ' + user.email)
            
            return custom_redirect('login:reset', s = 'ms')
Exemplo n.º 3
0
def team_view(request):
    """
    Redirects user to if not authenticated, otherwise shows team view
    """
     
    #Redirect unauthenticated users
    if not request.user.is_authenticated:
        return redirect('index:index')
    
    #Check if user has accepted terms of use
    if not request.user.conventecuser.accepted_tou:
        return redirect('terms:terms')
    
    if request.user.conventecuser.kanzlei.deadline is not None and request.user.conventecuser.kanzlei.deadline <= datetime.datetime.now():
        return custom_redirect('login:error', e = 'deadline')

    if request.method == 'GET':
        #Get active tab
        active = request.GET.get('active', 'ubersicht')
        
        #Provide name of user and items the user has access to
        context = {
            'user' : request.user,
            'active' : {'nav':'teams', 'tabs' : active}
                }
        
        return render(request, 'team_overview.html', context)
    
    elif request.method == 'POST':
        
        if not request.user.conventecuser.role == 'admin':
            return redirect('index:index')
        
        name = request.POST.get('name', False)
        description = request.POST.get('description', False)
        
        if name and description:
            try:
                team = Team.objects.filter(kanzlei = request.user.conventecuser.kanzlei).get(name = name)
                return custom_redirect('team:team_detail', team.id)
            except Team.DoesNotExist:
                pass
            
            new_team = Team.create(name, description, request.user.conventecuser.kanzlei)
            request.user.conventecuser.teams.add(new_team)
            new_team.save()
            return redirect('team:team_detail', new_team.id )
        else:
            redirect('team:team')
Exemplo n.º 4
0
def form_view(request):
    """
    Shows the form of a Geschaeft
    """

    #Redirect unauthenticated users
    if not request.user.is_authenticated:
        return redirect('index:index')

    #Check if user has accepted terms of use
    if not request.user.conventecuser.accepted_tou:
        return redirect('terms:terms')

    if request.user.conventecuser.kanzlei.deadline is not None and request.user.conventecuser.kanzlei.deadline <= datetime.datetime.now(
    ):
        return custom_redirect('login:error', e='deadline')

    geschaft_id = request.POST.get('geschaft_id', False)
    geschaft = Geschaft.objects.get(id=geschaft_id)

    form = geschaft.template.form

    context = {
        'geschaft': geschaft,
        'form': form.js_file.read().decode("utf-8"),
        'csrf': csrf.get_token(request)
    }

    return render(request, 'form.html', context)
Exemplo n.º 5
0
def kanzlei_view(request, kanzlei_id):
    """
    Redirects user to if not authenticated, otherwise shows kanzlei view
    """

    #Redirect unauthenticated users
    if not request.user.is_authenticated:
        return redirect('index:index')

    #Check if user has accepted terms of use
    if not request.user.conventecuser.accepted_tou:
        return redirect('terms:terms')

    if request.user.conventecuser.kanzlei.deadline is not None and request.user.conventecuser.kanzlei.deadline <= datetime.datetime.now(
    ):
        return custom_redirect('login:error', e='deadline')

    #Check if user is admin
    if not request.user.conventecuser.role == 'admin':
        return redirect('index:index')

    #Get Kanzlei
    kanzlei = Kanzlei.objects.get(id=int(kanzlei_id))

    #Redirect if user not in kanzlei
    if request.user.conventecuser.kanzlei.id != kanzlei.id:
        return redirect('index:index')

    #Provide name of user and items the user has access to
    context = {'user': request.user, 'active': {'nav': 'kanzlei'}}

    return render(request, 'kanzlei.html', context)
Exemplo n.º 6
0
def settings_view(request):
    """
    Redirects logged-in users to their home panel.
    Otherwise renders a login page in case of a get request. In case of a post request it processes the login,
    redirects in case of success and displays an error in case of failure.
    """
    from django.shortcuts import render
    from django.shortcuts import redirect

    #Redirect not logged-in user
    if not request.user.is_authenticated:
        return redirect('index:index')

    #Check if user has accepted terms of use
    if not request.user.conventecuser.accepted_tou:
        return redirect('terms:terms')

    if request.user.conventecuser.kanzlei.deadline is not None and request.user.conventecuser.kanzlei.deadline <= datetime.datetime.now(
    ):
        return custom_redirect('login:error', e='deadline')

    #GET-request
    if request.method == 'GET':
        #Show settings page
        return render_settings_view(request)

    #POST-request means change of data
    else:
        pw_old = request.POST['pw_old']
        pw_new_1 = request.POST['pw_new_1']
        pw_new_2 = request.POST['pw_new_2']

        if request.user.check_password(pw_old) and pw_new_1 == pw_new_2:
            username = request.user.username
            request.user.set_password(pw_new_1)
            request.user.save()
            user = authenticate(request, username=username, password=pw_new_1)
            login(request, user)
            return render_settings_view(request,
                                        error=False,
                                        message="Passwort geändert")
        else:
            #Show login page with error message
            return render_settings_view(
                request,
                error=True,
                message=
                "Altes Passwort ist falsch oder neue Passwörter nicht identisch"
            )
Exemplo n.º 7
0
def terms_view(request):
    
    #Redirect unauthenticated users
    if not request.user.is_authenticated:
        return redirect('index:index')
    
    if request.user.conventecuser.kanzlei.deadline is not None and request.user.conventecuser.kanzlei.deadline <= datetime.datetime.now():
        return custom_redirect('login:error', e = 'deadline')
    
    if request.method == 'GET':
        #REMOVE FOR PRODUCTION
        reset = request.GET.get('reset', False)
        if reset:
            request.user.conventecuser.accepted_tou = False
            request.user.conventecuser.save()
        
        #language
        lang = request.GET.get('lang', False)
        
        #Provide context
        context = {
            'user' : request.user,
            'lang' : lang
        }
            
        return render(request, 'terms.html', context)
    
    elif request.method == 'POST':
        cb1 = request.POST.get('cb1', False)
        cb2 = request.POST.get('cb2', False)
        
        if cb1 == 'on' and cb2 == 'on':
            request.user.conventecuser.accepted_tou = True
            request.user.conventecuser.save()
            return redirect('projekt:projekt')
        else:
            return redirect('terms:terms')
Exemplo n.º 8
0
def projekt_detail_view(request, projekt_id):
    """
    Redirects user to index if not authenticated, otherwise shows a project
    """

    #Redirect unauthenticated users
    if not request.user.is_authenticated:
        return redirect('index:index')

    #Check if user has accepted terms of use
    if not request.user.conventecuser.accepted_tou:
        return redirect('terms:terms')

    if request.user.conventecuser.kanzlei.deadline is not None and request.user.conventecuser.kanzlei.deadline <= datetime.datetime.now(
    ):
        return custom_redirect('login:error', e='deadline')

    projekt = Projekt.objects.get(id=projekt_id)

    #Check if user hase access
    has_access = False
    for team in request.user.conventecuser.teams.all():
        if team in projekt.teams.all():
            has_access = True

    try:
        if request.user.conventecuser.role == 'admin' and projekt.project_folder.get_project(
        ).teams.first().kanzlei == request.user.conventecuser.kanzlei:
            has_access = True
    except:
        pass

    if not has_access:
        return redirect('index:index')

    if request.method == 'GET':
        #Get sorted and reverse
        sorted_by = request.GET.get('sort', 'name')
        reverse = (request.GET.get('reverse', '') == 'true')

        #Get active tab
        active = request.GET.get('active', 'ubersicht')

        #Get success
        success = request.GET.get('success', 'false')

        #Provide context
        context = {
            'user': request.user,
            'projekt': projekt,
            'project_folder': projekt.project_folder,
            'teams_active': list_all_teams(request, projekt, active=True),
            'teams_passive': list_all_teams(request, projekt, active=False),
            'templates': list_all_templates(sorted_by, reverse),
            'active': {
                'nav': 'projekte',
                'tabs': active
            },
            'success': success
        }

        return render(request, 'projekt_detail.html', context)

    elif request.method == 'POST':

        #Get POST data
        #Get active tab
        active = request.POST.get('active', 'ubersicht')

        name = request.POST.get('name', False)
        description = request.POST.get('description', False)
        abschliessen = request.POST.get('abschliessen', False)
        loschen = request.POST.get('loschen', False)

        add_geschaft_id = request.POST.get('add_geschaft_id', False)
        projekt_id = request.POST.get('projekt_id', False)

        add_team = request.POST.get('add_team', False)
        remove_team = request.POST.get('remove_team', False)
        change_lead = request.POST.get('change_lead', False)

        if name:
            projekt.name = name
            projekt.save()

        if description:
            projekt.description = description
            projekt.save()

        if add_team and change_lead:
            projekt.teams.add(Team.objects.get(id=int(add_team)))
            projekt.lead = Team.objects.get(id=int(change_lead))
            projekt.save()
            return custom_redirect('projekt:projekt_detail',
                                   projekt.id,
                                   active='teams')

        if add_team:
            projekt.teams.add(Team.objects.get(id=int(add_team)))
            projekt.save()
            return custom_redirect('projekt:projekt_detail',
                                   projekt.id,
                                   active='teams')

        if remove_team:
            projekt.teams.remove(Team.objects.get(id=int(remove_team)))
            projekt.save()
            return custom_redirect('projekt:projekt_detail',
                                   projekt.id,
                                   active='teams')

        if change_lead:
            projekt.lead = Team.objects.get(id=int(change_lead))
            projekt.save()
            return custom_redirect('projekt:projekt_detail',
                                   projekt.id,
                                   active='teams')

        if abschliessen:
            if abschliessen == 'true':
                projekt.completed = True
                projekt.completed_at = datetime.datetime.now(
                    pytz.timezone('Europe/Zurich'))
            else:
                projekt.completed = False
            projekt.save()

        if loschen:
            projekt.delete()
            return redirect('projekt:projekt')

        if add_geschaft_id and projekt_id:
            geschaft = Geschaft.create(add_geschaft_id, projekt_id)
            geschaft.save()

        #Provide context
        context = {
            'user': request.user,
            'projekt': projekt,
            'project_folder': projekt.project_folder,
            'templates': list_all_templates(None, None),
            'active': {
                'nav': 'projekte',
                'tabs': active
            },
            'success': 'true'
        }

        return render(request, 'projekt_detail.html', context)
Exemplo n.º 9
0
def project_folder_detail_view(request, project_folder_id, container_id=False):
    """
    Redirects user to index if not authenticated, otherwise shows a project
    """
    #Redirect unauthenticated users
    if not request.user.is_authenticated:
        return redirect('index:index')

    #Check if user has accepted terms of use
    if not request.user.conventecuser.accepted_tou:
        return redirect('terms:terms')

    if request.user.conventecuser.kanzlei.deadline is not None and request.user.conventecuser.kanzlei.deadline <= datetime.datetime.now(
    ):
        return custom_redirect('login:error', e='deadline')

    project_folder = ProjectFolder.objects.get(id=project_folder_id)
    projekt = project_folder.get_project()

    #Check if user hase access
    has_access = False
    for team in request.user.conventecuser.teams.all():
        if team in projekt.teams.all():
            has_access = True

    try:
        if request.user.conventecuser.role == 'admin' and project_folder.get_project(
        ).teams.first().kanzlei == request.user.conventecuser.kanzlei:
            has_access = True
    except:
        pass

    if not has_access:
        return redirect('index:index')

    if request.method == 'GET':
        #Get sorted and reverse
        sorted_by = request.GET.get('sort', 'name')
        reverse = (request.GET.get('reverse', '') == 'true')

        container_id = request.GET.get('container', False)
        if container_id:
            container = Container.objects.get(id=int(container_id))
            parent_containers = container.list_parent_containers()

            if container.type == 'container':
                final_containers = sorted(container.container_set.all(),
                                          key=lambda x: x.name)
                final_templates = False
            else:
                final_containers = False
                final_templates = sorted(container.templates.all(),
                                         key=lambda x: x.name)
        else:

            container = False
            parent_containers = False
            final_containers = False
            final_templates = False

        if container and container.kanzleien.count(
        ) != 0 and not container.kanzleien.filter(
                id=request.user.conventecuser.kanzlei.id).exists():
            return redirect('index:index')

        #Provide context
        context = {
            'user': request.user,
            'projekt': projekt,
            'project_folder': project_folder,
            'parent_folders': project_folder.list_parent_folders(),
            'folders': list_all_folders(project_folder, sorted_by, reverse),
            'geschafts': list_all_geschafts(project_folder, sorted_by,
                                            reverse),
            'top_containers': Container.get_top_containers(request.user),
            'container': container,
            'final_containers': final_containers,
            'final_templates': final_templates,
            'parent_containers': parent_containers,
            'active': {
                'nav': 'projekte',
                'tabs': 'ubersicht'
            }
        }

        return render(request, 'project_folder_view.html', context)

    elif request.method == 'POST':
        delete_folder = request.POST.get('delete_folder', False)
        delete_geschaft = request.POST.get('delete_geschaft', False)
        add_folder = request.POST.get('add_folder', False)

        add_geschaft = request.POST.get('add_geschaft', False)
        geschaft_name = request.POST.get('geschaft_name', None)

        if delete_folder:
            folder = ProjectFolder.objects.get(id=int(delete_folder))
            folder.delete()

        if delete_geschaft:
            geschaft = Geschaft.objects.get(id=int(delete_geschaft))
            geschaft.delete()

        if add_folder:
            ProjectFolder.create(add_folder, project_folder)

        if add_geschaft:
            template_temp = Template.objects.get(id=int(add_geschaft))
            if template_temp.kanzleien.count(
            ) == 0 or template_temp.kanzleien.filter(
                    id=request.user.conventecuser.kanzlei.id).exists():
                Geschaft.create(int(add_geschaft), project_folder.id,
                                geschaft_name)

        return redirect('project_folder:project_folder', project_folder.id)
Exemplo n.º 10
0
def team_detail_view(request, team_id):
    """
    Redirects user to index if not authenticated, otherwise shows a project
    """
     
    #Redirect unauthenticated users
    if not request.user.is_authenticated:
        return redirect('index:index')
    
    #Check if user has accepted terms of use
    if not request.user.conventecuser.accepted_tou:
        return redirect('terms:terms')
    
    if request.user.conventecuser.kanzlei.deadline is not None and request.user.conventecuser.kanzlei.deadline <= datetime.datetime.now():
        return custom_redirect('login:error', e = 'deadline')
    
    team = Team.objects.get(id = team_id)
    
    #Check if user has access
    has_access = False
    if team.kanzlei.id == request.user.conventecuser.kanzlei.id:
            has_access = True
            
    if not has_access:
        return redirect('index:index')
    
    if request.method == 'GET':
        #Get sorted and reverse
        sorted_by1 = request.GET.get('sort1', 'f_name')
        reverse1 = (request.GET.get('reverse1', '') == 'true')
        sorted_by2 = request.GET.get('sort2', 'f_name')
        reverse2 = (request.GET.get('reverse2', '') == 'true')

        
        #Provide context
        context = {
            'user' : request.user,
            'team'    : team,
            'n_members' : list_all_n_members(team,sorted_by1, reverse1),
            'members' : list_all_members(team, sorted_by2, reverse2),
            'active' : {'nav' : 'teams'}
                }
        
        return render(request, 'team_detail.html', context)
    
    elif request.method == 'POST':
        if not request.user.conventecuser.role == 'admin':
            return redirect('index:index')
        
        name = request.POST.get('name', False)
        description = request.POST.get('description', False)
        add = request.POST.get('add', False)
        remove = request.POST.get('remove', False)
        loschen = request.POST.get('loschen', False)
        
        if name:
            team.name = name
            team.save()
        
        if description:
            team.description = description
            team.save()
            
        if add:
            c_user = ConventecUser.objects.get(user_id = int(add))
            if c_user.kanzlei.id == request.user.conventecuser.kanzlei.id:
                c_user.teams.add(team)
            
            c_user.save()
        
        if remove:
            c_user = ConventecUser.objects.get(user_id = int(remove))
            if c_user.kanzlei.id == request.user.conventecuser.kanzlei.id:
                c_user.teams.remove(team)
                
            c_user.save()
            
        if loschen:
            team.delete()
            return redirect('team:team')
            
        #Provide context
        context = {
            'user' : request.user,
            'team'    : team,
            'n_members' : list_all_n_members(team,'f_name', False),
            'members' : list_all_members(team, 'f_name', False),
            'active' : {'nav' : 'teams'}
                }
        
        return render(request, 'team_detail.html', context)
Exemplo n.º 11
0
def kanzlei_user(request, kanzlei_id):
    """
    Redirects user to if not authenticated, otherwise shows users of kanzlei
    """

    #Redirect unauthenticated users
    if not request.user.is_authenticated:
        return redirect('index:index')

    #Check if user has accepted terms of use
    if not request.user.conventecuser.accepted_tou:
        return redirect('terms:terms')

    #Get Kanzlei
    kanzlei = Kanzlei.objects.get(id=kanzlei_id)

    #Redirect if user not in kanzlei
    if request.user.conventecuser.kanzlei.id != kanzlei.id:
        return redirect('index:index')

    if request.method == 'GET':
        #Get sorted and reverse
        sorted_by = request.GET.get('sort', 'l_name')
        reverse = (request.GET.get('reverse', '') == 'true')

        vorname = request.GET.get('vorname', '')
        nachname = request.GET.get('nachname', '')
        email = request.GET.get('email', '')
        position = request.GET.get('position', '')
        role = request.GET.get('role', '')

        e = request.GET.get('e', False)

        #Provide name of user and items the user has access to
        context = {
            'user': request.user,
            'kanzlei': request.user.conventecuser.kanzlei,
            'members': list_all_members(request, sorted_by, reverse),
            'active': {
                'nav': 'kanzlei'
            },
            'vorname': vorname,
            'nachname': nachname,
            'email': email,
            'position': position,
            'role': role,
            'e': e
        }

        return render(request, 'kanzlei_user.html', context)

    elif request.method == 'POST':
        if not request.user.conventecuser.role == 'admin':
            return redirect('index:index')

        vorname = request.POST.get('vorname', False)
        nachname = request.POST.get('nachname', False)
        email = request.POST.get('email', False)
        position = request.POST.get('position', False)
        role = request.POST.get('role', False)
        pw1 = request.POST.get('pw1', False)
        pw2 = request.POST.get('pw2', False)

        remove = request.POST.get('remove', False)

        if vorname and nachname and email and position and role and pw1 and pw2 and pw1 == pw2:
            # Check if email is already taken

            try:
                user = User.objects.get(email=email)
                return custom_redirect('kanzlei:kanzlei_user',
                                       kanzlei.id,
                                       e='email',
                                       vorname=vorname,
                                       nachname=nachname,
                                       position=position,
                                       role=role,
                                       scroll_to='erstellen')
            except User.DoesNotExist:
                pass

            new_user = ConventecUser.create(vorname, nachname, email, position,
                                            role, pw1, kanzlei)

        if remove:
            user = User.objects.get(id=int(remove))
            if user.conventecuser.kanzlei.id == kanzlei.id:
                user.delete()

        return redirect('kanzlei:kanzlei_user', kanzlei.id)
Exemplo n.º 12
0
def kanzlei_user_detail(request, kanzlei_id, user_id):
    """
    Redirects user to if not authenticated, otherwise shows users of kanzlei
    """

    #Redirect unauthenticated users
    if not request.user.is_authenticated:
        return redirect('index:index')

    #Check if user has accepted terms of use
    if not request.user.conventecuser.accepted_tou:
        return redirect('terms:terms')

    #Get Kanzlei
    kanzlei = Kanzlei.objects.get(id=int(kanzlei_id))

    #Get User
    user = User.objects.get(id=int(user_id))

    #Redirect if user not in kanzlei
    if request.user.conventecuser.kanzlei.id != kanzlei.id or user.conventecuser.kanzlei.id != kanzlei.id:
        return redirect('index:index')

    if request.method == 'GET':

        s = request.GET.get('s', False)

        #Provide name of user and items the user has access to
        context = {
            'user': user,
            'kanzlei': request.user.conventecuser.kanzlei,
            'active': {
                'nav': 'kanzlei'
            },
            's': s
        }

        return render(request, 'kanzlei_user_detail.html', context)

    elif request.method == 'POST':

        vorname = request.POST.get('vorname', False)
        nachname = request.POST.get('nachname', False)
        email = request.POST.get('email', False)
        position = request.POST.get('position', False)
        role = request.POST.get('role', False)
        pw1 = request.POST.get('pw1', False)
        pw2 = request.POST.get('pw2', False)

        if vorname:
            user.first_name = vorname
            user.save()

        if nachname:
            user.last_name = nachname
            user.save()

        if email:
            if email != user.email:
                try:
                    user = User.objects.get(email=email)
                    return custom_redirect('kanzlei:kanzlei_user_detail',
                                           kanzlei.id,
                                           user.id,
                                           s='fail',
                                           scroll_to='bearbeiten')
                except User.DoesNotExist:
                    pass
            user.email = email
            user.save()

        if pw1 and pw2 and pw1 == pw2:
            user.set_password(pw1)
            user.save()

        if position:
            user.conventecuser.position = position
            user.conventecuser.save()

        if role:
            user.conventecuser.role = role
            user.conventecuser.save()

        return custom_redirect('kanzlei:kanzlei_user_detail',
                               kanzlei.id,
                               user.id,
                               s='success',
                               scroll_to='bearbeiten')
Exemplo n.º 13
0
def feedback_view(request):

    #Redirect unauthenticated users
    if not request.user.is_authenticated:
        return redirect('index:index')

    #Check if user has accepted terms of use
    if not request.user.conventecuser.accepted_tou:
        return redirect('terms:terms')

    if request.user.conventecuser.kanzlei.deadline is not None and request.user.conventecuser.kanzlei.deadline <= datetime.datetime.now(
    ):
        return custom_redirect('login:error', e='deadline')

    if request.method == 'GET' and not request.user.conventecuser.view_feedback:
        active = request.GET.get('active', 'anregung')
        success = request.GET.get('success', 'f')

        context = {
            'user': request.user,
            'active': {
                'nav': 'feedback',
                'tabs': active
            },
            'success': success
        }

        return render(request, 'feedback.html', context)

    elif request.method == 'POST' and not request.user.conventecuser.view_feedback:
        type = request.POST.get('type', '')

        anonymous = request.POST.get('anonymous', '')

        if anonymous != '':
            user = None
        else:
            user = request.user

        if type == 'fehler' or type == 'anregung':
            title = request.POST.get('title', '')
            text = request.POST.get('text', '')

            if text != '' or title != '':
                Feedback.create(user, type, title, text)

        elif type == 'allgemein':
            q1a = escape(request.POST.get('q1a', False))
            q1b = escape(request.POST.get('q1b', False))
            q2a = escape(request.POST.get('q2a', False))
            q2b = escape(request.POST.get('q2b', False))
            q2c = escape(request.POST.get('q2c', False))
            q2d = escape(request.POST.get('q2d', False))
            q2e = escape(request.POST.get('q2e', False))
            q2f = escape(request.POST.get('q2f', False))
            q2g = escape(request.POST.get('q2g', False))
            q3 = escape(request.POST.get('q3', False))
            q4 = escape(request.POST.get('q4', False))
            q5 = escape(request.POST.get('q5', False))
            q6 = escape(request.POST.get('q6', False))
            q7 = escape(request.POST.get('q7', False))
            q8 = escape(request.POST.get('q8', False))
            q9 = escape(request.POST.get('q9', False))
            q10 = escape(request.POST.get('q10', False))
            q11 = escape(request.POST.get('q11', False))

            title = 'Feedback Formular'
            text = ''

            if q1a:
                text += '\n\n<strong>1. Würden Sie Conventec für Ihr Unternehmen nutzen und gegebenenfalls einem Kollegen weiterempfehlen?</strong>\n\n'
                text += (q1a + '\n\n')
                if q1b:
                    text += (q1b + '\n\n')

            text += '\n\n<strong>2. Welche Elemente der Conventec App haben Sie ausprobiert?</strong>\n\n'

            if q2a:
                text += 'Erstellung Projekt (Mandat)\n\n'

            if q2b:
                text += 'Teamverwaltung (z.B. weiteres Team zu Projekt hinzufügen)\n\n'

            if q2c:
                text += 'Erstellung einzelnes Geschäft\n\n'

            if q2d:
                text += '1.4.2. AG Revisionsstelle Opting Out Post Incorporation\n\n'

            if q2e:
                text += '2.1.1. GmbH Gründung bar\n\n'

            if q2f:
                text += 'Formular ausfüllen\n\n'

            if q2g:
                text += 'Dokumente downloaden\n\n'

            if q3:
                text += (
                    '\n\n<strong>3. Haben Sie das Gefühl, dass Conventec Ihnen Ihren juristischen Arbeitsalltag erleichtern kann? Wenn ja, wie? Wenn nein, warum nicht?</strong>\n\n'
                    + q3 + '\n\n')

            if q4:
                text += (
                    '\n\n<strong>4. Wie müsste die Conventec App allenfalls angepasst werden, damit Sie noch besser bzw. effizienter arbeiten können?</strong>\n\n'
                    + q4 + '\n\n')

            if q5:
                text += (
                    '\n\n<strong>5. Empfinden Sie den Webauftritt der Conventec App als ansprechend und bedienungsfreundlich?</strong>\n\n'
                    + q5 + '\n\n')

            if q6:
                text += (
                    '\n\n<strong>6. Von welchen juristischen Geschäften würden Sie sich wünschen, dass sie auf der Conventec App automatisiert verfügbar wären (z.B. AG Kapitalerhöhung)?</strong>\n\n'
                    + q6 + '\n\n')

            if q7:
                text += (
                    '\n\n<strong>7. Wo beobachten Sie Ineffizienzen/Verbesserungspotential in Ihrem juristischen Alltag und wie könnte Conventec Ihnen bei der Behebung/Umsetzung helfen?</strong>\n\n'
                    + q7 + '\n\n')

            if q8:
                text += (
                    '\n\n<strong>8. Würden Sie es als hilfreich empfinden, wenn Sie in der Conventec App in real-time mit Ihren Teamkollegen oder Kunden an Geschäften (insb. Verträgen) arbeiten könnten, beispielsweise mithilfe eines Texteditors?</strong>\n\n'
                    + q8 + '\n\n')

            if q9:
                text += (
                    '\n\n<strong>9. Gibt es ein „Wunschfeature“, welches Sie als sehr nützlich empfinden würden, momentan aber noch nicht durch Conventec implementiert worden ist?</strong>\n\n'
                    + q9 + '\n\n')

            if q10:
                text += (
                    '\n\n<strong>10. Wie hoch wäre Ihre monatliche Zahlungsbereitschaft für die Nutzung der Conventec App angepasst auf Ihre Kanzlei / Unternehmung?</strong>\n\n'
                    + q10 + '\n\n')

            if q11:
                text += (
                    '\n\n<strong>11. Blockchain, Artificial Intelligence, Analytics etc. – Wie könnte Conventec Ihre Kanzlei / Unternehmung auf dem weiteren Weg zur Digitalisierung sonst unterstützen?</strong>\n\n'
                    + q11 + '\n\n')

            Feedback.create(user, type, title, text)

        active = request.GET.get('active', 'anregung')
        success = request.GET.get('success', 'f')

        context = {
            'user': request.user,
            'active': {
                'nav': 'feedback',
                'tabs': active
            },
            'success': success
        }

        return render(request, 'feedback.html', context)

    elif request.method == 'GET' and request.user.conventecuser.view_feedback:
        active = request.GET.get('active', 'alles')

        context = {
            'user': request.user,
            'feedback': Feedback.objects.all(),
            'active': {
                'nav': 'feedback',
                'tabs': active
            }
        }

        return render(request, 'feedback_list.html', context)

    elif request.method == 'POST' and request.user.conventecuser.view_feedback:
        active = request.GET.get('active', 'all')
        loschen = request.POST.get('loschen', 'all')

        Feedback.objects.get(id=int(loschen)).delete()

        context = {
            'user': request.user,
            'feedback': Feedback.objects.all(),
            'active': {
                'nav': 'feedback',
                'tabs': active
            }
        }

        return render(request, 'feedback_list.html', context)
Exemplo n.º 14
0
def geschaft_view(request, geschaft_id):
    """
    Redirects user to index if not authenticated, otherwise shows a geschaft
    """

    #Redirect unauthenticated users
    if not request.user.is_authenticated:
        return redirect('index:index')

    #Check if user has accepted terms of use
    if not request.user.conventecuser.accepted_tou:
        return redirect('terms:terms')

    if request.user.conventecuser.kanzlei.deadline is not None and request.user.conventecuser.kanzlei.deadline <= datetime.datetime.now(
    ):
        return custom_redirect('login:error', e='deadline')

    geschaft = Geschaft.objects.get(id=geschaft_id)

    #Check if user hase access
    has_access = False
    for team in request.user.conventecuser.teams.all():
        for project in team.projekt_set.all():
            if geschaft.project_folder.get_project() == project:
                has_access = True

    try:
        if request.user.conventecuser.role == 'admin' and geschaft.project_folder.get_project(
        ).teams.first().kanzlei == request.user.conventecuser.kanzlei:
            has_access = True
    except:
        pass

    if not has_access:
        return redirect('index:index')

    if request.method == 'GET':
        #Get sorted and reverse
        sorted_by = request.GET.get('sort', 'name')
        reverse = (request.GET.get('reverse', '') == 'true')

        #Get active tab
        active = request.GET.get('active', 'formular')

        #Get success
        success = request.GET.get('success', 'false')

        #Get error
        error = request.GET.get('e', 'false')

        #Provide context
        context = {
            'error': error,
            'user': request.user,
            'geschaft': geschaft,
            'projekt': geschaft.get_project(),
            'parent_folders': geschaft.project_folder.list_parent_folders(),
            'documents': list_all_documents(geschaft, sorted_by, reverse),
            'active': {
                'nav': 'projekte',
                'tabs': active
            },
            'success': success
        }

        return render(request, 'geschaft.html', context)

    elif request.method == 'POST':

        #Get POST data
        #Get active tab
        active = request.POST.get('active', 'dokumente')

        name = request.POST.get('name', False)
        loschen = request.POST.get('loschen', False)

        document_id = request.POST.get('document_id', False)
        all = request.POST.get('all', False)

        variables = request.POST.get('variables', False)

        folder = request.POST.get('folder', False)

        if name:
            geschaft.name = name
            geschaft.save()

        if loschen:
            project_folder_id = geschaft.project_folder.get_project().id
            geschaft.delete()
            return redirect('project_folder:project_folder',
                            project_folder_id=project_folder_id)

        if geschaft_id and document_id:
            document = Document.objects.get(id=document_id)

            if settings.DEBUG:
                download = document.download(geschaft_id)

                if download:
                    return download
                else:
                    return custom_redirect('geschaft:geschaft',
                                           geschaft_id,
                                           e='true',
                                           active='dokumente')

            else:
                try:
                    download = document.download(geschaft_id)

                    if download:
                        return download
                    else:
                        return custom_redirect('geschaft:geschaft',
                                               geschaft_id,
                                               e='true',
                                               active='dokumente')
                except:
                    return custom_redirect('geschaft:geschaft',
                                           geschaft_id,
                                           e='true',
                                           active='dokumente')

        if geschaft_id and all:
            if settings.DEBUG:
                return geschaft.download_all()
            else:
                try:
                    return geschaft.download_all()
                except:
                    return custom_redirect('geschaft:geschaft',
                                           geschaft_id,
                                           e='true',
                                           active='dokumente')

        if variables:
            geschaft.variables = variables
            geschaft.save()
            return custom_redirect('geschaft:geschaft',
                                   geschaft_id,
                                   active='ubersicht')

        if folder:
            geschaft.project_folder = ProjectFolder.objects.get(id=int(folder))
            geschaft.save()

        #Provide context
        context = {
            'user': request.user,
            'geschaft': geschaft,
            'projekt': geschaft.get_project(),
            'active': {
                'nav': 'projekte',
                'tabs': active
            },
            'success': 'true'
        }

        return render(request, 'geschaft.html', context)
Exemplo n.º 15
0
def api_dispatcher(request):
    #Redirect unauthenticated users
    if not request.user.is_authenticated:
        return redirect('index:index')

    if request.user.conventecuser.kanzlei.deadline is not None and request.user.conventecuser.kanzlei.deadline <= datetime.datetime.now(
    ):
        return custom_redirect('login:error', e='deadline')

    #Get the type of the request
    t = request.GET.get('t', None)
    if t is None:
        return JsonResponse({
            'status': 'fail',
            'message': 'No request type specified.'
        })

    #Handle search firm request
    if t == 'search':
        q = request.GET.get('q', None)
        if q is None:
            return JsonResponse({
                'status': 'fail',
                'message': 'No query string given.'
            })

        api = ConventecApi()
        return JsonResponse(api.list_by_name(q))

    #Handle full info by uid request
    elif t == 'uid':
        q = request.GET.get('q', None)
        if q is None:
            return JsonResponse({
                'status': 'fail',
                'message': 'No query string given.'
            })

        api = ConventecApi()
        return JsonResponse(api.get_by_uid_full(q))
    #Grundbuch addres search
    elif t == 'address':
        q = request.GET.get('q', None)
        if q is None:
            return JsonResponse({
                'status': 'fail',
                'message': 'No query string given.'
            })

        api = ConventecApi()
        return JsonResponse(api.get_coords_by_address(q), safe=False)
    #Grundbuch addres search
    elif t == 'coords':
        q = request.GET.get('q', None)
        if q is None:
            return JsonResponse({
                'status': 'fail',
                'message': 'No query string given.'
            })

        api = ConventecApi()
        return JsonResponse(api.get_auszug_by_coords(q), safe=False)
    else:
        return JsonResponse({
            'status': 'fail',
            'message': 'Unknown request type.'
        })