This is one of those cases that seems obvious, until you consult the history books.
You might think to yourself, of course a city can't ban its police officers from contributing to political campaigns -- that's ridiculous. Except, in 1917, the "Bloody Fifth" Ward incident happened: Cops beat up an opposition candidate, killed a detective who tried to intervene, and terrorized the candidate's supporters. Because, ya know, machine politics.
A series of reforms followed, culminating in a 1951 ban on political contributions by cops as a prophylactic against corruption. The ban stood for more than 60 years, until the Third Circuit cut it down this week, citing a few obvious free speech problems.