def user_account(request): """ User account page, or login page """ if request.user.is_authenticated(): # Account dashboard image_objs = Meta_File.objects.filter( is_img=True).order_by('-dt_uploaded')[:6] image_ids = [str(image.id) for image in image_objs] context = { 'docpages': DocPage.objects.order_by('-dt_editted')[:5], 'images': [{ 'id': i, 'url': 'images/' + i } for i in image_ids], } return core.render(request, 'login/dashboard.html', **context) else: # Login page context = { 'form': forms.login, 'formid': 'login-form', 'logid': 'login-log', 'action': reverse('login:login'), 'validators': ['login/login_validator.js'], 'title': 'Editor Log In' } return core.renderform(request, context)
def editor_page(request, pk): ''' Editor for a doc page ''' docPage = get_object_or_404(DocPage, pk=pk) panels_json = [] for panel in docPage.panel_set.all(): # Get panel data panel_json = {'header': panel.title, 'components': []} for comp in panel.component_set.all(): # Get component data comp_json = { 'source': comp.src, 'model': comp.model, 'view': comp.view } panel_json['components'].append(comp_json) panels_json.append(panel_json) context = { 'docpage': docPage, 'panels': json.dumps(panels_json), 'mchoices': json.dumps(mchoices), 'vchoices': json.dumps(vchoices), 'page': { 'user_menu': [(reverse('docpage:view_page', args=(docPage.id, )), 'View This Page')], 'title': docPage.title.title() + ' - PerCMS' } } return core.render(request, 'docpage/editor.html', **context)
def upload(request): ''' Upload file page ''' context = {} if request.method == 'POST' and request.FILES: # Handle saving file fh = request.FILES.values()[0] # file if fh.size > 4*1024*1024: context['too_big'] = True else: now = timezone.now() # Check if file is image try: attempt_image = Image.open(fh) is_image = True except IOError: is_image = False # Create and save file meta_file = save_file( data = fh.read(), category=request.POST['category'], file_name=request.POST['name'], is_image=is_image ) # Pass file information back to page context['file'] = meta_file context['file_url'] = 'images/'+ str(meta_file.id) return core.render(request, 'filemanager/upload.html', **context)
def dashboard(request): ''' Admin dashboard for gametracker ''' context = { 'title': 'Game Tracker Dashboard', 'leagues': League.objects.all() } return core.render(request, 'gametracker/dashboard.html', **context)
def editor_list(request): ''' Top-level editor for leagues ''' context = { 'title' : 'League Manager', 'leagues': League.objects.all() } return core.render(request, 'gametracker/leagueManager.html', **context)
def editor(request, pk): league = get_object_or_404(League, pk=pk) context = { 'title': 'League', 'league': league, 'seasons': league.season_set.all(), 'teams': league.team_set.all() } return core.render(request, 'gametracker/leagueEditor.html', **context)
def render_page(request, docpage): ''' Renders a specific docpage ''' context = build_docpage_context(docpage) context['page']['user_menu'] = [(reverse('docpage:editor_page', args=(docpage.id, )), 'Edit This Page')] page_title = dash_pattern.sub(' ', docpage.title).title() context['page']['title'] = page_title + ' - PerCMS' return core.render(request, 'docpage/docpage.html', **context)
def editor_list(request, pkLeague): ''' Top-level editor for leagues ''' league = get_object_or_404(League, pk=pkLeague) context = { 'title': 'Team Manager', 'league': league, 'teams': league.team_set.all(), 'form': { 'action': 'gametracker:add_team', 'fields': Team(fkLeague=league).to_form_fields() } } return core.render(request, 'gametracker/teamManager.html', **context)
def editor(request, pk): ''' Editor for team ''' team = get_object_or_404(Team, pk=pk) context = { 'title': 'Team Editor', 'team': team, 'league': team.fkLeague, 'form': { 'action': 'gametracker:edit_team', 'fields': team.to_form_fields() } } return core.render(request, 'gametracker/teamEditor.html', **context)
def editor_list(request, pkSeason): ''' Top-level editor for matches ''' season = get_object_or_404(Season, pk=pkSeason) context = { 'title': 'Schedule Manager', 'season': season, 'matches': season.match_set.all(), 'form': { 'action': 'gametracker:add_match', 'fields': Match(round=1, fkSeason=season, date=datetime.today()).to_form_fields() } } return core.render(request, 'gametracker/matchManager.html', **context)
def editor_list(request): ''' Top-level editor page for docs ''' context = {'docpages': DocPage.objects.order_by('-dt_editted')} return core.render(request, 'docpage/editor_list.html', **context)
def describe(request, pk): ''' Shows image meta data ''' meta_file = get_object_or_404(Meta_File, pk=pk) context = {'file': meta_file, 'file_url': 'images/'+str(meta_file.id)} return core.render(request, 'filemanager/describe.html', **context)
def user_login_inactive(request): """ Inactive login page """ return core.render(request, 'login/login-inactive.html')
def user_login_success(request): """ Success login page """ return core.render(request, 'login/login-conf.html')
def view(request, pk): context = { 'title': 'League', 'league': get_object_or_404(League, pk=pk) } return core.render(request, 'gametracker/viewLeague.html', **context)