def list_apps(): apps = AdNetwork.all() form = AppForm() if form.validate_on_submit(): file = request.files['app_url'] if file: filedata = file.read() ext = file.filename.rsplit('.', 1)[1] content_type = file.content_type app_filename = file.filename applist = AdNetwork( app_title = request.form['app_title'], app_category = request.form['app_category'], app_name = app_filename, app_url = db.Blob(filedata), ext = ext, content_type = content_type, app_link = request.form['app_link'], new = form.new.data, exclusive = form.exclusive.data ) try: applist.put() app_id = applist.key().id() flash(u'App Profile is %s successfully saved.' % app_id, 'success') return redirect(url_for('apps')) except CapabilityDisabledError: flash(u'App Engine Datastore is currently in read-only mode.', 'info') return redirect(url_for('apps')) return render_template('list_apps.html', apps=apps, form=form) return render_template('list_apps.html', apps=apps, form=form)
def creating(request): user = request.user if request.method == 'POST': form = AppForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] background = form.cleaned_data['background'] applied_date = datetime.now() submitted = True if 'save' in request.POST: submitted = False app = CharApp(char_name=name, background=background, date_applied=applied_date, player_id=user.id, submitted=submitted) app.save() if submitted: # Create the actual character object typeclass = settings.BASE_CHARACTER_TYPECLASS home = ObjectDB.objects.get_id(settings.DEFAULT_HOME) # turn the permissionhandler to a string perms = str(user.permissions) # create the character char = create.create_object(typeclass=typeclass, key=name, home=home, permissions=perms) user.db._playable_characters.append(char) # add the right locks for the character so the player can # puppet it char.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) " "or pperm(Immortals)" % (char.id, user.id)) char.db.background = background # set the character background return HttpResponseRedirect('/chargen') else: form = AppForm() return render(request, 'chargen/create.html', {'form': form})
def register_app(request): if request.method == 'POST': form = AppForm(request.POST) if form.is_valid(): consumer = form.save() consumer.user = request.user consumer.generate_random_codes() messages.success(request, 'The app ' + consumer.name + ' was successfully added to your list.') return redirect(manage_apps) else: form = AppForm() return render_to_response('server/private/register_app.html', {'form': form}, context_instance=RequestContext(request))
def registerApp(request): usr = request.user cUser = CalendarUser.objects.get(user=usr) if not cUser.isDev: return redirect(reverse('editprofile')) context = {} context['errors'] = [] context['messages'] = [] if request.method == 'GET': context['form'] = AppForm() return render(request, 'registerapp.html', context) app = App(owner=cUser) form = AppForm(request.POST, instance=app) context['form'] = form if not form.is_valid(): return render(request, 'registerapp.html', context) form.save() return redirect(reverse('devcenter'))
def editApp(request, idOfApp): """Edit-app call, creates form and submission procedure for App""" usr = request.user cUser = CalendarUser.objects.get(user=usr) if not cUser.isDev: return redirect(reverse('editprofile')) app = get_object_or_404(App, id=idOfApp, owner=cUser) context = {} context['errors'] = [] context['messages'] = [] context['app'] = app if request.method == 'GET': context['form'] = AppForm(instance=app) return render(request, 'editapp.html', context) form = AppForm(request.POST, instance=app) context['form'] = form if not form.is_valid(): return render(request, 'editapp.html', context) form.save() return redirect(reverse('devcenter'))
def get_context_data(self, **kwargs): context = super( ProjectAppListView, self).get_context_data(**kwargs) context['form'] = AppForm() context['project_id'] = self.kwargs.get('pk') return context