Why is this function a modular form with character? In Zagier's chapter of The 1-2-3 of Modular Forms, he defines the Theta series of a quadratic form $Q$ as
$$\Theta_Q(z) = \sum_{n=0}^\infty r(Q,n) q^n$$
where $q = e^{2\pi i z}$. He identifies orbits of quadratic forms under an action of $SL_2(\mathbb{Z})$ with ideal classes in $\mathbb{Q}(\sqrt{D})$, and then takes a homomorphism $\chi$ from the ideal class group of $\mathbb{Q}(\sqrt{D})$ to $\mathbb{C}^*$, and sets
$$f_\chi = \frac{1}{w} \sum_{\mathcal{A}} \chi(\mathcal{A}) \Theta_\mathcal{A}(z)$$
where $w$ is a constant, the sum is over ideal classes in $\mathbb{Q}(\sqrt{D})$, and $\Theta_\mathcal{A}(z)$ is $\Theta_Q(z)$ where $\mathcal{A}$ and the orbit of $Q$ under the action of $SL_2(\mathbb{Z})$ are identified.
He then claims that $f_\chi$ is a modular form of weight $1$, but I can't tell why that is the case. I'm guessing that it must be of weight $1$ and character $\chi$, because I don't see how it makes sense otherwise, but the definition I'm familiar with for modular forms of weight $k$ and character $\chi$ is that they are modular forms $f$ of weight $k$ on $\Gamma_1(N)$ such that
$$f\left(\frac{az+b}{cz+d}\right) = \chi(d) (cz+d)^k f(z)$$
for all $\begin{pmatrix} a & b \\ c & d \end{pmatrix} \in \Gamma_0(N)$. Is this the right definition?
Here is the relevant section of the text.
Also, at the end, he claims that the Euler product for the $L$-series of $f_\chi$ means that $f_\chi$ is a normalized eigenform, but I thought that the Euler product must be of the form
$$\prod_{p} \frac{1}{1 - a_p p^{-s} + \chi(p) p^{k-1-2s}}$$
where the product is over primes $p$ and $a_p$ are the Fourier coefficients of $f_\chi$. I can see why the $L$-series has a product over prime ideals of the ring of integers of $\mathbb{Q}(\sqrt{D})$, but not why it has this form.
 A: Suppose that we have a Hecke character $\chi$, in this case a character $\chi:{Cl}(K)\to \mathbb C^*$ for some imaginary quadratic field $K$. 
Using this character Zagier is showing how to construct a modular eigenform $f_\chi$ with the property that
$$L(s,f_\chi) = L(s,\chi).$$
This equality makes complete sense as an equality of complex functions, despite the fact that the Euler product on the right is over the primes of $\mathcal O_K$, whilst the Euler product on the left is over the rational primes. 

If you're happy with the fact that each $\Theta_Q(z)$ is a modular form of weight $1$, then since $f_\chi$ is a finite sum of such forms, it will also be a weight $1$ form. The character of $f_\chi$ will depend on $\chi$, but cannot be $\chi$, since $\chi$ is not a Dirichlet character.
On the one hand, 
$$\begin{align}L(s, f_\chi) &= L\left(s,\frac1w \sum_{\mathcal A}\chi(\mathcal A)\Theta_{\mathcal A}(z)\right)
\\&=\sum_{n=1}^{\infty}n^{-s}\sum_{\mathcal A}\chi(\mathcal A)r(\mathcal A, n).\end{align}$$
On the other hand, since $r(\mathcal A,n)$ is the number of ideals $\mathfrak a$ of $\mathcal O_K$ of norm $n$ belonging to the class $\mathcal A$, it follows that
$$\begin{align}\sum_{n=1}^{\infty}n^{-s}\sum_{\mathcal A}\chi(\mathcal A)r(\mathcal A, n)&=\sum_{n=1}^\infty\sum_{\mathfrak a :N(\mathfrak a) = n}\chi(\mathfrak a)N(\mathfrak a)^{-s}\\&=\sum_{\mathfrak a}\chi(\mathfrak a)N(\mathfrak a)^{-s}=L(s,\chi)\end{align}$$

Since $L(s,\chi)$ has an Euler product, it follows that $L(s,f_\chi)$ does too.
We have
$$\begin{align}L(s,\chi) &= \prod_{\mathfrak p\subset\mathcal O_K}(1-\chi(\mathfrak p)N(\mathfrak p)^{-s})^{-1}\\&=\prod_{p\text{ inert},\ \mathfrak p\mid p}(1-\chi(\mathfrak p)p^{-2s})^{-1}\prod_{p\text{ split},\ \mathfrak p\mid p}(1-\chi(\mathfrak p)p^{-s})^{-1}\prod_{p\text{ ramifies},\ \mathfrak p\mid p}(1-\chi(\mathfrak p)p^{-s})^{-1}.\end{align}$$
Evaluating each of these products individually allows us to view the L-function as an Euler product over $\mathbb Z$, which will be exactly of the form you expect.
