As GM called it, WWI era DWM with WWII era aluminum bottom mag.
Even without the picture of the top chamber and toggle in the OP, the Imperial inspector and army acceptance marks on the right side barrel extension dated this gun to 1918 or earlier.
Tough to call which war it became a souvenir, but the later mag is a slight hint. If it was WWII, it was one of a fair number of examples which escaped the Treaty of Versailles directive, which essentially destroyed all army 9mm guns, or updated them with a sear safety for police use. These post-treaty Police Lugers were still allowed in 9mm, and will generally have a second date (1920) stamped over the chamber area, the retrofitted safety, and/or additional police unit markings.
DWM also continued new production of what are nicknamed the Alphabet Lugers from roughly 1920 through about 1923 for commercial, police and paramilitary use, in .30 luger caliber. And also made 9mm Weimar military and police units through approx. 1933.
As previously mentioned, a fair number of WWI era Lugers survived through the Weimar Period without being converted to police standards, and came back out of hiding in the early to mid-1930s when the Nazi Party came to rule.
The grip carvings are assuredly non-German Army from either war, and could have been from post-WWI paramilitary, resistance faction, or post-capture by an Allied force.